Module: Adminterface::Extensions::Resource::ActionItems
- Defined in:
- lib/adminterface/extensions/resource/action_items.rb
Instance Method Summary collapse
- #action_items_for(action, render_context = nil) ⇒ Object
- #add_default_action_items ⇒ Object
-
#add_default_destroy_action_item ⇒ Object
Adds the default Destroy link on show.
-
#add_default_edit_action_item ⇒ Object
Adds the default Edit link on show.
-
#add_default_new_action_item ⇒ Object
Adds the default New link on index.
Instance Method Details
#action_items_for(action, render_context = nil) ⇒ Object
5 6 7 |
# File 'lib/adminterface/extensions/resource/action_items.rb', line 5 def action_items_for(action, render_context = nil) super.sort_by { |x| [x.group, x.priority] } end |
#add_default_action_items ⇒ Object
9 10 11 12 13 |
# File 'lib/adminterface/extensions/resource/action_items.rb', line 9 def add_default_action_items add_default_new_action_item add_default_edit_action_item add_default_destroy_action_item end |
#add_default_destroy_action_item ⇒ Object
Adds the default Destroy link on show
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/adminterface/extensions/resource/action_items.rb', line 50 def add_default_destroy_action_item add_action_item :destroy, only: proc { components.dig(:action_items, :destroy, :only)&.map(&:to_sym) } do if controller.action_methods.include?("destroy") && (ActiveAdmin::Auth::DESTROY, resource) localizer = ActiveAdmin::Localizers.resource(active_admin_config) icon_class = active_admin_config.components.dig(:action_items, :destroy, :icon_class) confirm_dialog_config = { buttons: { confirm: { text: I18n.t(:confirm, scope: "active_admin.confirm_dialog"), class: active_admin_config.css_classes.dig(:confirm_dialog, :confirm) }, cancel: { text: I18n.t(:cancel, scope: "active_admin.confirm_dialog"), class: active_admin_config.css_classes.dig(:confirm_dialog, :cancel) } } } link_to( safe_join([icon_html(icon_class), content_tag(:span, localizer.t(:delete_model))]), resource_path(resource), title: localizer.t(:delete_model), class: active_admin_config.components.dig(:action_items, :destroy, :css_class), method: :delete, data: {confirm: localizer.t(:delete_confirmation), "aa-confirm-dialog": confirm_dialog_config} ) end end end |
#add_default_edit_action_item ⇒ Object
Adds the default Edit link on show
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/adminterface/extensions/resource/action_items.rb', line 33 def add_default_edit_action_item add_action_item :edit, only: proc { components.dig(:action_items, :edit, :only)&.map(&:to_sym) } do if controller.action_methods.include?("edit") && (ActiveAdmin::Auth::UPDATE, resource) localizer = ActiveAdmin::Localizers.resource(active_admin_config) icon_class = active_admin_config.components.dig(:action_items, :edit, :icon_class) link_to( safe_join([icon_html(icon_class), content_tag(:span, localizer.t(:edit_model))]), edit_resource_path(resource), title: localizer.t(:edit_model), class: active_admin_config.components.dig(:action_items, :edit, :css_class) ) end end end |
#add_default_new_action_item ⇒ Object
Adds the default New link on index
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/adminterface/extensions/resource/action_items.rb', line 16 def add_default_new_action_item add_action_item :new, only: proc { components.dig(:action_items, :new, :only)&.map(&:to_sym) } do if controller.action_methods.include?("new") && (ActiveAdmin::Auth::CREATE, active_admin_config.resource_class) localizer = ActiveAdmin::Localizers.resource(active_admin_config) icon_class = active_admin_config.components.dig(:action_items, :new, :icon_class) link_to( safe_join([icon_html(icon_class), content_tag(:span, localizer.t(:new_model))]), new_resource_path, title: localizer.t(:new_model), class: active_admin_config.components.dig(:action_items, :new, :css_class) ) end end end |