ActiveAdmin Register Page Batch Action - ruby-on-rails-4

I have Custom page "All Posts"
Can i integrate batch action into this custom page for assigning the post to a particular category
ActiveAdmin.register_page "All Posts" do
menu :priority => 1#, label: proc{ I18n.t("active_admin.dashboard") }
content do #title: proc{ I18n.t("active_admin.dashboard") }
#how can i put here a batch action
end
end
how can i put here a batch action as it gives errors when i write the batch action for resource code.
should i write the page_action and then customize it using javascript and partials.
Thanks in advance

You can try to add batch_action by
batch_action :export do |selection|
keys = Model.find()
redirect_to admin_path_to_page_with_category_selection_path(post_ids: selection)
end
and selectable column
index download_links: [:xlsx] do
selectable_column
.....
end
admin_path_to_page_with_category_selection_path goes to view with category combobox, selected posts and submit button

Related

APEX - double click on interactive gird

Below is my interactive grid. It shows data from v$sql_monitor view based on sql_id from list .
What I would like to do is to create double-click dynamic action on a record. This action would open new modal dialog and pass two parameters : 1. sql_id from list above 2.sql_exec_id from clicked record. Would you give me a few hints how to do it ? I guess a piece of Javascript code will be necessary :(
There are multiple options to do this - here is one way, by using javascript custom events. I created a sample with an IG on the EMP/DEPT sample dataset with page 88 as IG and page 90 as modal. The column ENAME is a link to page 90 that sets a column value and a page item in the link.
Page 88 has an IG and 2 page items:
P88_PAGE_ITEM (a value entered on the page like the list in your screenshot)
P88_ENAME (to hold the selected report column value
Page 90 has 2 page items: P90_PAGE_ITEM and P90_REPORT_COLUMN
Create IG on page 90 on table EMP
On column ENAME, add the following under "JavaScript Initialization Code"
function(config) {
config.defaultGridColumnOptions = {
cellTemplate: '<button type="button" class="t-Button t-Button--link my-ename-js" data-ename="&ENAME.">&ENAME.</button>'
};
return config;
}
This is a button of type "display as link", created with the universal theme button builder that has 2 extra attributes: a class my-ename-js and a data attribute "ename" data-ename="&ENAME."
Create a dynamic action to capture the click and set the page item:
Make sure to set the scope to "Dynamic". This is needed because the event listener needs to be added again after a dom change (a search or filter of the IG).
add a true action of type "Set Value" to set the value of P88_ENAME to the value of the selected row
add a second true action to trigger a custom javascript event:
Create a dynamic action of type "Event: Custom" to capture the custom event triggered in the previous DA.
add a true action of type "Submit Page". Note that "Show Processing" needs to be unchecked.
Almost there. One last thing is to create a branch to the modal page:
Create a branch (process point "After Processing") with server-side condition of "Request = Value" with value OPENMODAL and link attributes below:
And this should be the result:
Well, I modified a bit your scenario.
I added new SelectList P88_FILTER
and added dynamic action ON_CHANGE :
with action
I modified source if IG:
These changes allowes me to filter IG . In our case filter returns always only one record like below.
and now my problem begins. In your scenario clicking the link "ename" updates field P88_ENAME and opens modal dialog with proper values. After my modification neither P88_ENAME updates nor modal dialog opens :(

validation on button without refresh page on APEX5 5.0

Need your suggestions on handling the validation without submitting page in APEX 5.0. I have following items on my apex report page.
"Select list" item which contains some static values
date pickers ( start date and end date)
Submit button ( Once submit is clicked the report date is displayed )
Here I need to add a dynamic action or validation to the submit button so that if user clicks the submit button without selecting a value from the "Select List", an error message should be displayed to the user that he needs to select the item first from the "Select list" page item. With out any selection from the list , the processing should stop and a warning message should be displayed ( either it could be popup message or message can be marked on the select list page item ) .Point to be noted here that during the submit I do not want to refresh the page, just would like a quick error message to display.
Appreciate your help.
in a similar case i used dynamic actions
dynamic actions works on client side
in my case i am not enabling submit button until user changes the select list value
in my dynamic action my config is as below
Event=change
selection=items
item=selectlistID
and true action is
action=disable
button=submitbuttonname
in your case you can choose javascript as action and add your javascript code

ActiveAdmin: Open show page in Facebox

As the title suggests, I am trying to get the view link on the index page for my resource to open the show page in a facebox or other popup window, without the main page redirecting and loading the page there. Is there any way to achieve this?
Replace the view link with your own link logic.
index do
selectable_column
column :name
actions do |resource|
link_to "View", resource.facebook_url
end
end
CITE: http://activeadmin.info/docs/3-index-pages/index-as-table.html

Sitecore Page Editor Publishing items related to content

I have a "Product Page",Product page maps to "ProductPage" Sitecore item. Website/Pages/ProductPage.
I have a text area in that page with page editor, which loads text from "Product Example Text" Sitecore item's "Description" text from Web database. (Sitecore.../CommonText/Product Example Text)
In my ascx file, mark up is pretty straigh forwad,
<sc:FieldRenderer ID="FieldRenderer1" runat="server" />
Codebehind,
FieldRenderer1.Item = //"Product Example Text" Sitecore item
FieldRenderer1.FieldName = "Description";
When I open the page in Page Editor(as a system admin), it allows me to change the "Product Example Text", and when I save using the "Save" button on the Page Editor it get saved to the master database. "Product Example Text" item get saved.
Now, when I try to publish the item using the "Publish" item in the Page Editor ribbon, these changes do not get reflected,reason is "Product Example Text" item does not get published.
When I save the page, somehow Sitecore understands the "Product Example Text" item has to be saved. But why does not it get published?
Am I doing anything wrong.... How can I solve this issue?
While saving an item in Page Editor, Sitecore saves all the field renderers which are displayed on the page, so if you set the Item property of a FieldRenderer1 to "Product Example Test" Sitecore Item, Page Editor know which item should be saved.
The problem with publishing is that you enqueue the current item in the publishing queue, but this item has no link to the "Product Example Test" Sitecore Item in any of its properties cause you're setting the Item property of the field renderer dynamically in the code.
The option would be to add another button to Page Editor next to Edit Related Item button and create a command that will Publish Related Item. The complete description how to add such a command can be found in the answer Sitecore page editor - how to extend page editor item editing panel
Another approach would be to create the "Product Example Test" content item under the "ProductPage" as a sub item. In publish options you can use publish sub items, which will publish all content you want.
But the problem is, if you want a particular content to be shared in several places, this won't work.
Maras's answer is a better solution.

Simplecart additional hidden item attributes

I am trying to add an additional, hidden field to my simplecart items when using the simpleCart_shelfItem div. I've tried hidden inputs, additional spans, and can't get my attribute to show up in the JSON that's passed by Simplecarts form checkout.
Nothing fancy when I init simplecart:
// Init shopping cart
script(type='text/javascript')
simpleCart({
checkout: {
type: "SendForm",
url: "/cart/checkout"
},
currency: "USD",
cartStyle: "table"
});
Here's where I load a shelf item (note that this is using the Jade engine, but HTML is as expected):
div.simpleCart_shelfItem
p.item_name My Special Item
input.item_Quantity(type='text', value='1')
input.item_secretId(type='hidden', value='A hidden identifier')
br
span.item_price $0.99
br
a.item_add(href="javascript:;") Add to Cart
I've also tried using:
span.item_secretId A hidden identifier
And when I pass the cart to /cart/checkout secretId is nowhere to be found when I do a console log of req.body in my server-side code:
Checkout passed with: {"currency":"USD","shipping":"0","tax":"0","taxRate":"0","itemCount":"1","item_name_1":"4x6 Print","item_quantity_1":"4","item_price_1":"0.99","item_options_1":""}
I've seen the ability to add custom columns to the cart in the API docs, but I don't want this field to show up in the cart, it's strictly internal to facilitate server-side processing.
It's not particularly pretty, but I solved this by using div tags around my new data elements, and then hiding them in a stylesheet like this
HTML:
input(class="item_internalId", type='text', value='1234')
CSS:
input.item_internalId {
display: none;
}