lib/admin_it/helpers/table.rb in admin_it-1.0.11 vs lib/admin_it/helpers/table.rb in admin_it-1.1.0
- old
+ new
@@ -1,7 +1,9 @@
module AdminIt
+ #
module Helpers
+ #
class Cell < WrapIt::Base
include WrapIt::TextContainer
default_tag 'td'
attr_accessor :column
option :column
@@ -14,10 +16,11 @@
end
end
end
end
+ #
class ActionsCell < WrapIt::Base
default_tag 'td'
before_capture do
context = parent.parent.context
@@ -25,13 +28,13 @@
resource = parent.parent.resource
single = resource.singles.select { |c| !(c <= NewContext) }
buttons = single.map do |_context|
if _context <= ShowContext && context.show_in_dialog?
'<a class="btn btn-xs btn-info" ' +
- %Q{data-toggle="modal" data-target="#confirm_modal" } +
- %Q{href="#{_context.path(entity)}?layout=dialog">} +
- %Q{<i class="fa fa-#{_context.icon}"></i></a>}
+ %Q(data-toggle="modal" data-target="#confirm_modal" ) +
+ %Q(href="#{_context.path(entity)}?layout=dialog">) +
+ %Q(<i class="fa fa-#{_context.icon}"></i></a>)
else
cl = _context <= ShowContext ? 'info' : 'default'
href = _context.path(entity)
"<a class=\"btn btn-xs btn-#{cl}\" href=\"#{href}\">" \
"<i class=\"fa fa-#{_context.icon}\"></i></a>"
@@ -42,12 +45,12 @@
confirm = single.find { |c| c.context_name == :confirm } ||
single.first { |c| c <= ShowContext }
unless confirm.nil?
buttons <<
'<a class="btn btn-xs btn-danger" ' +
- %Q{data-toggle="modal" data-target="#confirm_modal" } +
- %Q{href="#{confirm.path(entity)}} +
+ %Q(data-toggle="modal" data-target="#confirm_modal" ) +
+ %Q(href="#{confirm.path(entity)}) +
'?layout=dialog&confirm=destroy">' +
'<i class="fa fa-trash-o"></i></a>'
end
else
show = single.first { |c| c <= ShowContext }
@@ -67,27 +70,28 @@
self[:content] = html_safe(html)
end
end
+ #
class Header < WrapIt::Container
default_tag 'tr'
child :cell, Cell, tag: 'th'
end
+ #
class Row < WrapIt::Container
default_tag 'tr'
child :cell, Cell
child :actions, ActionsCell
before_capture do
block = parent.context.row
- unless block.nil?
- instance_exec(parent.context.entity, &block)
- end
+ instance_exec(parent.context.entity, &block) unless block.nil?
end
end
+ #
class Table < WrapIt::Container
default_tag 'table'
html_class %w(table)
attr_writer :context
argument :context, if: AdminIt::Context