Module: Terrazzo::CollectionActionsHelper
- Defined in:
- app/helpers/terrazzo/collection_actions_helper.rb
Instance Method Summary collapse
- #collection_action_path(resource, action = :show) ⇒ Object
- #collection_item_actions(resource) ⇒ Object
- #has_many_pagination_paths(field, resource) ⇒ Object
Instance Method Details
#collection_action_path(resource, action = :show) ⇒ Object
10 11 12 13 14 15 |
# File 'app/helpers/terrazzo/collection_actions_helper.rb', line 10 def collection_action_path(resource, action = :show) return nil unless collection_action_route?(resource, action) return nil unless (resource, action) terrazzo_resource_member_path(resource, action: action) end |
#collection_item_actions(resource) ⇒ Object
3 4 5 6 7 8 |
# File 'app/helpers/terrazzo/collection_actions_helper.rb', line 3 def collection_item_actions(resource) resource_dashboard = "#{resource.class.name}Dashboard".safe_constantize&.new dashboard = resource_dashboard if resource_dashboard&.respond_to?(:collection_item_actions) dashboard ||= Terrazzo::BaseDashboard.new dashboard.collection_item_actions(resource, self) end |
#has_many_pagination_paths(field, resource) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/helpers/terrazzo/collection_actions_helper.rb', line 17 def has_many_pagination_paths(field, resource) param_key = Terrazzo::HasManyPagination.param_key(field.attribute) legacy_param_key = Terrazzo::HasManyPagination.legacy_param_key(field.attribute) query_parameters = request.query_parameters.except( param_key, param_key.to_sym, legacy_param_key, legacy_param_key.to_sym ) base = query_parameters.merge( only_path: true, controller: controller_path, action: :show, id: terrazzo_resource_param(resource), format: nil, props_at: "data.attributes.#{field.attribute}" ) { prevPagePath: (field.current_page > 1 ? url_for(base.merge(param_key => field.current_page - 1)) : nil), nextPagePath: (field.current_page < field.total_pages ? url_for(base.merge(param_key => field.current_page + 1)) : nil) } end |