Sha256: 8848090e57f4127822ed7444ccb6b3c086ff41cd2c8e1e98b5e14e9d23a650b9

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

class <%= class_name %>Decorator < Tramway::Core::ApplicationDecorator
  # Associations you want to show in admin dashboard
  # decorate_associations :messages, :posts

  class << self
    def collections
      # [ :all, :scope1, :scope2 ]
      [ :all ]
    end

    def list_attributes
      [
<% attributes.first(COLLECTION_ATTRIBUTE_LIMIT).each do |attr| -%>
        :<%= attr %>,
<% end -%>
      ]
    end

    def show_attributes
      [
<% attributes.each do |attr| -%>
        :<%= attr %>,
<% end -%>
      ]
    end

    def show_associations
      # Associations you want to show in admin dashboard
      # [ :messages ]
    end

    def list_filters
      # {
      #   filter_name: {
      #     type: :select,
      #     select_collection: filter_collection,
      #     query: lambda do |list, value|
      #       list.where some_attribute: value
      #     end
      #   },
      #   date_filter_name: {
      #     type: :dates,
      #     query: lambda do |list, begin_date, end_date|
      #       list.where 'created_at > ? AND created_at < ?', begin_date, end_date
      #     end
      #   }
      # }
    end
  end

  # delegate_attributes :title
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tramway-admin-1.32.2.5 lib/tramway/admin/generators/templates/decorator.rb.erb
tramway-admin-1.32.2.4 lib/tramway/admin/generators/templates/decorator.rb.erb