module AdminIt # module Helpers # class Cell < WrapIt::Base include WrapIt::TextContainer default_tag 'td' attr_accessor :column option :column before_capture do unless column.nil? col = parent.parent.context.field(column) unless col.nil? col.render(parent.parent.context.entity, instance: self) end end end end # class ActionsCell < WrapIt::Base default_tag 'td' before_capture do context = parent.parent.context entity = context.entity resource = parent.parent.resource single = resource.singles.select { |c| !(c <= NewContext) } p_context = context.child? ? context.parent : context params = {} params[:section] = p_context.section if p_context.respond_to?(:section) if context.child? params[:layout] = :dialog params[:parent] = context.parent end buttons = single.map do |_context| if _context <= ShowContext && context.show_in_dialog? ') + %Q() else cl = _context <= ShowContext ? 'info' : 'default' href = _context.url(entity, **params) data = context.child? ? %Q(data-toggle="modal" data-target="#child_modal") : '' "" \ "" end end if resource.destroyable? if context.confirm_destroy? confirm = single.find { |c| c.context_name == :confirm } || single.first { |c| c <= ShowContext } unless confirm.nil? buttons << '' + '' end else show = single.first { |c| c <= ShowContext } unless show.nil? buttons << @template.link_to( html_safe(''), show.path(entity), method: :delete, class: 'btn btn-xs btn-danger' ) end end end html = buttons.join html = "