Module: Spotlight::CrudLinkHelpers
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/spotlight/crud_link_helpers.rb
Overview
Helpers for building polymorphic links within the exhibit context
Instance Method Summary collapse
- #action_label(model, action) ⇒ Object
- #cancel_link(model, link, link_to_options = {}) ⇒ Object
- #create_link(model, *args) ⇒ Object
- #delete_link(model, *args) ⇒ Object
- #edit_link(model, *args) ⇒ Object
- #exhibit_create_link(model, *args) ⇒ Object
- #exhibit_delete_link(model, *args) ⇒ Object
- #exhibit_edit_link(model, *args) ⇒ Object
- #exhibit_view_link(model, *args) ⇒ Object
- #nav_link(name = nil, options = nil, html_options = nil, &block) ⇒ Object
- #view_link(model, *args) ⇒ Object
Instance Method Details
#action_label(model, action) ⇒ Object
61 62 63 |
# File 'app/helpers/spotlight/crud_link_helpers.rb', line 61 def action_label(model, action) action_default_value model, action end |
#cancel_link(model, link, link_to_options = {}) ⇒ Object
7 8 9 |
# File 'app/helpers/spotlight/crud_link_helpers.rb', line 7 def cancel_link(model, link, = {}) link_to action_default_value(model, :cancel), link, end |
#create_link(model, *args) ⇒ Object
23 24 25 26 27 |
# File 'app/helpers/spotlight/crud_link_helpers.rb', line 23 def create_link(model, *args) = args. link = args.first || polymorphic_path([spotlight, model], action: :new) link_to action_default_value(model), link, end |
#delete_link(model, *args) ⇒ Object
47 48 49 50 51 52 |
# File 'app/helpers/spotlight/crud_link_helpers.rb', line 47 def delete_link(model, *args) = args. link = args.first || [spotlight, model] = { method: :delete, data: { confirm: action_default_value(model, :destroy_are_you_sure) } } link_to action_default_value(model, :destroy), link, .merge() end |
#edit_link(model, *args) ⇒ Object
35 36 37 38 39 |
# File 'app/helpers/spotlight/crud_link_helpers.rb', line 35 def edit_link(model, *args) = args. link = args.first || polymorphic_path([spotlight, model], action: :edit) link_to action_default_value(model), link, end |
#exhibit_create_link(model, *args) ⇒ Object
29 30 31 32 33 |
# File 'app/helpers/spotlight/crud_link_helpers.rb', line 29 def exhibit_create_link(model, *args) = args. link = args.first || polymorphic_path([spotlight, current_exhibit, model], action: :new) link_to action_default_value(model), link, end |
#exhibit_delete_link(model, *args) ⇒ Object
54 55 56 57 58 59 |
# File 'app/helpers/spotlight/crud_link_helpers.rb', line 54 def exhibit_delete_link(model, *args) = args. link = args.first || [spotlight, model.exhibit, model] = { method: :delete, data: { confirm: action_default_value(model, :destroy_are_you_sure) } } link_to action_default_value(model, :destroy), link, .merge() end |
#exhibit_edit_link(model, *args) ⇒ Object
41 42 43 44 45 |
# File 'app/helpers/spotlight/crud_link_helpers.rb', line 41 def exhibit_edit_link(model, *args) = args. link = args.first || polymorphic_path([spotlight, model.exhibit, model], action: :edit) link_to action_default_value(model), link, end |
#exhibit_view_link(model, *args) ⇒ Object
17 18 19 20 21 |
# File 'app/helpers/spotlight/crud_link_helpers.rb', line 17 def exhibit_view_link(model, *args) = args. link = args.first || [spotlight, model.exhibit, model] link_to action_default_value(model, :view), link, end |
#nav_link(name = nil, options = nil, html_options = nil, &block) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/helpers/spotlight/crud_link_helpers.rb', line 65 def nav_link(name = nil, = nil, = nil, &block) # rubocop:disable Style/ParallelAssignment # (Note: this is copied from upstream in Rails) , , name = , name, block if block_given? # rubocop:enable Style/ParallelAssignment ||= {} content_tag(:li, class: 'nav-item') do if block_given? link_to(, (, ), &block) else link_to(name, , (, ), &block) end end end |
#view_link(model, *args) ⇒ Object
11 12 13 14 15 |
# File 'app/helpers/spotlight/crud_link_helpers.rb', line 11 def view_link(model, *args) = args. link = args.first || [spotlight, model] link_to action_default_value(model, :view), link, end |