I'm using tabs
and would like to have some custom buttons that change what is displayed on the screen such as: add an element to an array we are displaying, or reorder the elements in the array and show display it. This causes the admin page to reload every button click, but it reloads to the first tab.
Is there a way I can pass in a tab as a parameter and have the code switch to that tab so they can see the change right away? I need to catch it somewhere I'm assuming that's the update
or before_action only: [:index] do
?
div(style: 'margin: 0 10px;') do
tabs do
tab :bundles do
...
tab :groups do
active_admin_form_for :config_groups, url: add_ancestor_admin_config_group_path, method: :post do |f|
f.inputs do
f.input :new_ancestor_group,
label: "Select a new ancestor to add",
as: :select,
include_blank: false,
include_hidden: false,
collection: ConfigGroup.all.map { |cg| ["#{cg.name}", cg.id] }, # Display's name returns id
multiple: false
f.actions do
f.submit ADD_ANCESTOR_BUTTON, button_html: { style: 'width:20%', display: 'inline', class: 'inline-form' }
end
end
end
end
And the member action which gets the call
member_action :add_ancestor, method: :post do
...db stuff...
flash[:notice] = "This is a test notice!"
redirect_to edit_admin_config_group_path(config_group), notice: "Added config group #{new_config_group}"
end
The tabs have an anchor, so in your redirect you could say
redirect_to edit_admin_config_group_path(config_group, anchor: :groups), notice: "Added config group #{new_config_group}
and it will open the groups
tab.