Sha256: fd2100ddb6c315079ff894891531a3195b537c2b8031e99c33c46bbca26ebe78

Contents?: true

Size: 735 Bytes

Versions: 1

Compression:

Stored size: 735 Bytes

Contents

module Trestle
  class Table
    class Automatic < Table
      def initialize(admin)
        super(sortable: true, admin: admin)
        @admin = admin
      end

      def columns
        content_columns + [actions_column]
      end

      def content_columns
        @admin.default_table_attributes.map.with_index do |attribute, index|
          case attribute.type
          when :association
            Column.new(self, attribute.association_name, sort: false)
          else
            Column.new(self, attribute.name, link: index.zero?, align: (:center if [:datetime, :boolean].include?(attribute.type)))
          end
        end
      end

      def actions_column
        ActionsColumn.new(self)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trestle-0.8.4 lib/trestle/table/automatic.rb