Module: Workbench::TableHelper

Defined in:
app/helpers/workbench/table_helper.rb

Overview

Helpers for table rendering

Instance Method Summary (collapse)

Instance Method Details

- (Object) fancy_edit_tag(object)



34
35
36
# File 'app/helpers/workbench/table_helper.rb', line 34

def fancy_edit_tag(object)
  (:td, edit_object_link(object), class: 'table-options', data: {edit: true}) 
end

- (Object) fancy_metadata_cells_tag(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
24
25
26
# File 'app/helpers/workbench/table_helper.rb', line 19

def (object)
  m = metamorphosize_if(object)
  (:td, object_tag(object.updater)) +
    (:td, object_time_since_update_tag(object)) +
    fancy_show_tag(m) +
    fancy_edit_tag(m) + 
    (:td, (link_to 'Destroy', m, method: :delete, data: {confirm: 'Are you sure?'}), class: 'table-options', data: {delete: true})
end

- (Object) fancy_show_tag(object)



28
29
30
31
32
# File 'app/helpers/workbench/table_helper.rb', line 28

def fancy_show_tag(object)
  defined?(object.annotated_object) ? 
    (:td, (link_to 'Show', metamorphosize_if(object.annotated_object)), class: 'table-options', data: {show: true}) :
    (:td, (link_to 'Show', object), class: 'table-options', data: {show: true})
end

- (Object) fancy_th_tag(group: nil, name: '')



4
5
6
7
8
# File 'app/helpers/workbench/table_helper.rb', line 4

def fancy_th_tag(group: nil, name: '')
  (:th, data: {group: group}) do
    (:span, name)
  end
end