Module: Workbench::TableHelper
- Defined in:
- app/helpers/workbench/table_helper.rb
Overview
Helpers for table rendering
Instance Method Summary collapse
- #fancy_edit_tag(object) ⇒ Object
-
#fancy_metadata_cells_tag(object) ⇒ Object
Hidden action links data-attributes: data-show data-edit data-delete.
- #fancy_options_cells_tag(object) ⇒ Object
- #fancy_pin_tag(object) ⇒ Object
- #fancy_show_tag(object) ⇒ Object
- #fancy_th_tag(group: nil, name: '') ⇒ Object
Instance Method Details
#fancy_edit_tag(object) ⇒ Object
39 40 41 |
# File 'app/helpers/workbench/table_helper.rb', line 39 def fancy_edit_tag(object) content_tag(:td, edit_object_link(object), class: 'table-options', data: {edit: true}) end |
#fancy_metadata_cells_tag(object) ⇒ Object
Hidden action links data-attributes:
data-show
data-edit
data-delete
This is very important, it must be set to make work the options for the context menu. Use the class “.table-options” to hide those options on the table
19 20 21 22 23 |
# File 'app/helpers/workbench/table_helper.rb', line 19 def (object) content_tag(:td, object_tag(object.updater)) + content_tag(:td, object_time_since_update_tag(object)) + (object) end |
#fancy_options_cells_tag(object) ⇒ Object
25 26 27 28 29 30 31 |
# File 'app/helpers/workbench/table_helper.rb', line 25 def (object) m = (object) fancy_show_tag(m) + fancy_edit_tag(m) + fancy_pin_tag(m) + content_tag(:td, (link_to 'Destroy', m, method: :delete, data: {confirm: 'Are you sure?'}), class: 'table-options', data: {delete: true}) end |
#fancy_pin_tag(object) ⇒ Object
43 44 45 46 47 |
# File 'app/helpers/workbench/table_helper.rb', line 43 def fancy_pin_tag(object) if object.respond_to?(:pinned?) content_tag(:td, pin_item_to_pinboard_link(object, sessions_current_user), class: 'table-options', data: {pin: true}) end end |
#fancy_show_tag(object) ⇒ Object
33 34 35 36 37 |
# File 'app/helpers/workbench/table_helper.rb', line 33 def fancy_show_tag(object) defined?(object.annotated_object) ? content_tag(:td, (link_to 'Show', (object.annotated_object)), class: 'table-options', data: {show: true}) : content_tag(:td, (link_to 'Show', object), class: 'table-options', data: {show: true}) end |
#fancy_th_tag(group: nil, name: '') ⇒ Object
4 5 6 7 8 |
# File 'app/helpers/workbench/table_helper.rb', line 4 def fancy_th_tag(group: nil, name: '') content_tag(:th, data: {group: group}) do content_tag(:span, name) end end |