Sha256: 299d2260b04b51e5209194b95515b5535d7a42e457a3d8a351b097df55dcb3b7

Contents?: true

Size: 693 Bytes

Versions: 3

Compression:

Stored size: 693 Bytes

Contents

module Trestle
  class Table
    class Automatic < Table
      def initialize(admin)
        super(sortable: true, 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(attribute.association_name, sort: false)
          else
            Column.new(attribute.name, link: index.zero?, align: (:center if [:datetime, :boolean].include?(attribute.type)))
          end
        end
      end

      def actions_column
        ActionsColumn.new
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
trestle-0.9.5 lib/trestle/table/automatic.rb
trestle-0.9.4 lib/trestle/table/automatic.rb
trestle-0.9.3 lib/trestle/table/automatic.rb