Sha256: 378a87f0b173e807ed14d12f47eb821094d2e95fd6613d6c195cc801b7e4e87c

Contents?: true

Size: 1.03 KB

Versions: 9

Compression:

Stored size: 1.03 KB

Contents

require 'sunrise/config/base'
require 'sunrise/config/has_groups'
require 'sunrise/config/has_fields'

module Sunrise
  module Config
    class List < Base
      include Sunrise::Config::HasFields
      include Sunrise::Config::HasGroups
        
      # Number of items listed per page
      register_instance_option :items_per_page do
        Sunrise::Config.default_items_per_page
      end
      
      # Column to sort
      register_instance_option :sort_column do
        abstract_model.model.primary_key
      end
      
      # Sort direction
      register_instance_option :sort_mode do
        Sunrise::Config.default_sort_mode
      end
      
      # Default scope
      register_instance_option(:scope) do
        nil
      end
      
      # Image path for preview
      register_instance_option(:preview) do
        false
      end
      
      def preview_for(record)
        if preview.respond_to?(:call)
          preview.call(record) || "sunrise/default_ava.png"
        else
          preview
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sunrise-cms-0.5.0.rc2 lib/sunrise/config/list.rb
sunrise-cms-0.5.0.rc1 lib/sunrise/config/list.rb
sunrise-cms-0.4.2 lib/sunrise/config/list.rb
sunrise-cms-0.4.1 lib/sunrise/config/list.rb
sunrise-cms-0.4.0 lib/sunrise/config/list.rb
sunrise-cms-0.3.3 lib/sunrise/config/list.rb
sunrise-cms-0.3.2 lib/sunrise/config/list.rb
sunrise-cms-0.3.1 lib/sunrise/config/list.rb
sunrise-cms-0.3.0 lib/sunrise/config/list.rb