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-2.0.0.b app/components/express_admin/widget_box.rb
express_admin-2.0.0.a app/components/express_admin/widget_box.rb
express_admin-1.8.1 app/components/express_admin/widget_box.rb
express_admin-1.8.0 app/components/express_admin/widget_box.rb
express_admin-1.7.32 app/components/express_admin/widget_box.rb
express_admin-1.7.31 app/components/express_admin/widget_box.rb
express_admin-1.7.30 app/components/express_admin/widget_box.rb
express_admin-1.7.29 app/components/express_admin/widget_box.rb
express_admin-1.7.28 app/components/express_admin/widget_box.rb
express_admin-1.7.27 app/components/express_admin/widget_box.rb
express_admin-1.7.26 app/components/express_admin/widget_box.rb
express_admin-1.7.25 app/components/express_admin/widget_box.rb
express_admin-1.7.24 app/components/express_admin/widget_box.rb
express_admin-1.7.23 app/components/express_admin/widget_box.rb
express_admin-1.7.22 app/components/express_admin/widget_box.rb
express_admin-1.7.21 app/components/express_admin/widget_box.rb
express_admin-1.7.20 app/components/express_admin/widget_box.rb
express_admin-1.7.19 app/components/express_admin/widget_box.rb
express_admin-1.7.18 app/components/express_admin/widget_box.rb
express_admin-1.7.17 app/components/express_admin/widget_box.rb