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)



39
40
41
# File 'app/helpers/workbench/table_helper.rb', line 39

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
# File 'app/helpers/workbench/table_helper.rb', line 19

def (object)
  (:td, object_tag(object.updater)) +
    (:td, object_time_since_update_tag(object)) +
    fancy_options_cells_tag(object)
end

- (Object) fancy_options_cells_tag(object)



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

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

- (Object) fancy_pin_tag(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?)
    (:td, pin_item_to_pinboard_link(object, sessions_current_user), class: 'table-options', data: {pin: true})
  end
end

- (Object) fancy_show_tag(object)



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

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