Module: Admin::TableHelper
- Defined in:
- app/helpers/admin/table_helper.rb
Constant Summary collapse
- ALIGN_CLASSES =
{left: 't-left', center: 't-center', right: 't-right'}
Instance Method Summary collapse
- #delete_link(path) ⇒ Object
- #edit_link(path) ⇒ Object
- #table_for(a_class) ⇒ Object
- #td_class(column) ⇒ Object
- #th_class(column) ⇒ Object
- #tr_class(row_class, item) ⇒ Object
Instance Method Details
#delete_link(path) ⇒ Object
16 17 18 19 20 |
# File 'app/helpers/admin/table_helper.rb', line 16 def delete_link(path) return unless policy.action_enabled?(:destroy) content = "<i class='glyphicon glyphicon-trash'></i>".html_safe link_to content, path, data: {confirm: I18n.t('admin.common.sure')}, method: :delete, class: 'btn btn-danger btn-xs', title: I18n.t('admin.common.delete') end |
#edit_link(path) ⇒ Object
10 11 12 13 14 |
# File 'app/helpers/admin/table_helper.rb', line 10 def edit_link(path) return unless policy.action_enabled?(:edit) content = "<i class='glyphicon glyphicon-pencil'></i>".html_safe link_to content, path, class: 'btn btn-default btn-xs', title: I18n.t('admin.common.edit') end |
#table_for(a_class) ⇒ Object
6 7 8 |
# File 'app/helpers/admin/table_helper.rb', line 6 def table_for(a_class) Coalla::TableBuilder.new(self, a_class) end |
#td_class(column) ⇒ Object
33 34 35 36 37 38 |
# File 'app/helpers/admin/table_helper.rb', line 33 def td_class(column) klass = [] klass << column.col_class klass << ALIGN_CLASSES[column.align] if column.align klass.join(' ') end |
#th_class(column) ⇒ Object
22 23 24 25 26 27 |
# File 'app/helpers/admin/table_helper.rb', line 22 def th_class(column) klass = [] klass << "col-xs-#{column.cols}" if column.cols klass << ALIGN_CLASSES[column.align] if column.align klass.join(' ') end |
#tr_class(row_class, item) ⇒ Object
29 30 31 |
# File 'app/helpers/admin/table_helper.rb', line 29 def tr_class(row_class, item) row_class && row_class.call(item) end |