Method: Effective::Resources::Controller#resource_actions
- Defined in:
- app/models/effective/resources/controller.rb
#resource_actions ⇒ Object
This is the fallback for render_resource_actions when no actions are specified It is used by datatables
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'app/models/effective/resources/controller.rb', line 73 def resource_actions {}.tap do |actions| member_get_actions.reverse_each do |action| next unless crud_actions.include?(action) actions[human_action_name(action)] = { action: action, default: true } end member_get_actions.each do |action| next if crud_actions.include?(action) actions[human_action_name(action)] = { action: action, default: true } end member_post_actions.each do |action| next if crud_actions.include?(action) name = human_action_name(action) confirm = human_action_confirm(action) actions[name] = case action when :archive { action: action, default: true, if: -> { !resource.archived? }, class: 'btn btn-danger', 'data-method' => :post, 'data-confirm' => confirm } when :unarchive { action: action, default: true, if: -> { resource.archived? }, 'data-method' => :post, 'data-confirm' => confirm } else { action: action, default: true, 'data-method' => :post, 'data-confirm' => confirm } end end member_delete_actions.each do |action| name = human_action_name(action) confirm = human_action_confirm(action) actions[name] = { action: action, default: true, 'data-method' => :delete, 'data-confirm' => confirm } end end end |