Sha256: 096b51cae96bda81b68f69e27551f9da869b37ee862206628def01c4137526f8

Contents?: true

Size: 668 Bytes

Versions: 48

Compression:

Stored size: 668 Bytes

Contents

module ExpressAdmin
  class WidgetBox < ExpressTemplates::Components::Configurable

    has_option :title, 'The title to be displayed.'

    contains -> (&block) {
      header(class: 'title') { box_title }
      div(class: 'widget-body') {
        block.call(self) if block
      }
    }

    before_build -> {
      set_attribute(:id, "#{config[:id].to_s.dasherize}-box")
    }

    protected

      def resource_title
        config[:id].to_s.titleize
      end

      def box_title
        config[:title] || (resource.persisted? ? "Edit #{resource_title}" : "New #{resource_title}")
      end

      def resource
        self.send(config[:id])
      end
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
express_admin-1.7.16 app/components/express_admin/widget_box.rb
express_admin-1.7.16.pre1 app/components/express_admin/widget_box.rb
express_admin-1.7.15 app/components/express_admin/widget_box.rb
express_admin-1.7.14 app/components/express_admin/widget_box.rb
express_admin-1.7.13 app/components/express_admin/widget_box.rb
express_admin-1.7.12 app/components/express_admin/widget_box.rb
express_admin-1.7.11 app/components/express_admin/widget_box.rb
express_admin-1.7.10 app/components/express_admin/widget_box.rb
express_admin-1.7.9 app/components/express_admin/widget_box.rb
express_admin-1.7.8 app/components/express_admin/widget_box.rb
express_admin-1.7.7 app/components/express_admin/widget_box.rb
express_admin-1.7.5 app/components/express_admin/widget_box.rb
express_admin-1.7.4 app/components/express_admin/widget_box.rb
express_admin-1.7.3 app/components/express_admin/widget_box.rb
express_admin-1.7.2 app/components/express_admin/widget_box.rb
express_admin-1.7.1 app/components/express_admin/widget_box.rb
express_admin-1.6.13 app/components/express_admin/widget_box.rb
express_admin-1.6.12 app/components/express_admin/widget_box.rb
express_admin-1.6.11 app/components/express_admin/widget_box.rb
express_admin-1.6.10 app/components/express_admin/widget_box.rb