Module: Dunlop::TableHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/dunlop/table_helper.rb
Instance Method Summary collapse
- #search_row(&blk) ⇒ Object
- #table_destroy_link(record, path = nil) ⇒ Object
-
#table_download_link(record, path = nil) ⇒ Object
This helper returns the link for showing a record inside a table.
-
#table_edit_link(record, path = nil) ⇒ Object
This helper returns the link for editing a record inside a table.
-
#table_show_link(record, path = nil) ⇒ Object
This helper returns the link for showing a record inside a table.
Instance Method Details
#search_row(&blk) ⇒ Object
2 3 4 5 |
# File 'app/helpers/dunlop/table_helper.rb', line 2 def search_row(&blk) content = capture(&blk) content_tag(:tr, content, class: ['search', @q.conditions.present? ? 'conditions-present' : ''] ) end |
#table_destroy_link(record, path = nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/helpers/dunlop/table_helper.rb', line 25 def table_destroy_link(record, path = nil) return unless can? :destroy, record confirm_text = "Are you sure you want to delete #{record.class.model_name.human}" record_name = nil record_name = record.presentation_name if record.respond_to?(:presentation_name) record_name ||= record.name if record.respond_to?(:name) record_name ||= record.title if record.respond_to?(:title) confirm_text << " #{record_name}" if record_name.present? confirm_text << "?" link_to(content_tag(:span), path || record, method: :delete, data: { confirm: confirm_text }, class: 'table-link destroy') end |
#table_download_link(record, path = nil) ⇒ Object
This helper returns the link for showing a record inside a table
14 15 16 17 |
# File 'app/helpers/dunlop/table_helper.rb', line 14 def table_download_link(record, path = nil) return unless can? :download, record link_to(content_tag(:span), path || [:download, record], class: 'table-link download') end |
#table_edit_link(record, path = nil) ⇒ Object
This helper returns the link for editing a record inside a table
20 21 22 23 |
# File 'app/helpers/dunlop/table_helper.rb', line 20 def table_edit_link(record, path = nil) return unless can? :update, record link_to(content_tag(:span), path || [:edit, record], class: 'table-link edit') end |
#table_show_link(record, path = nil) ⇒ Object
This helper returns the link for showing a record inside a table
8 9 10 11 |
# File 'app/helpers/dunlop/table_helper.rb', line 8 def table_show_link(record, path = nil) return unless can? :show, record link_to(content_tag(:span), path || record, class: 'table-link show') end |