Sha256: d45f1668518e3caacaba67a4f9ff1ea86f89c841b682562128c44c3580cef2d4

Contents?: true

Size: 879 Bytes

Versions: 6

Compression:

Stored size: 879 Bytes

Contents

module ActiveScaffold::Config
  class Mark < Base
    self.crud_type = :read

    def initialize(core_config)
      @core = core_config
      if core_config.actions.include?(:update)
        @core.model.send(:include, ActiveScaffold::MarkedModel) unless @core.model.ancestors.include?(ActiveScaffold::MarkedModel)
        add_mark_column
      else
        raise "Mark action requires update action in controller for model: #{core_config.model.to_s}"
      end
    end
    
    protected
    
    def add_mark_column
      @core.columns.prepend(:marked)
      @core.columns[:marked].label = 'M'
      @core.columns[:marked].form_ui = :checkbox
      @core.columns[:marked].inplace_edit = true
      @core.columns[:marked].sort = false
      @core.list.columns = [:marked] + @core.list.columns.names_without_auth_check unless @core.list.columns.include? :marked
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
active_scaffold-sequel-0.8.0 lib/active_scaffold/config/mark.rb
active_scaffold-sequel-0.7.1 lib/active_scaffold/config/mark.rb
active_scaffold-sequel-0.7.0 lib/active_scaffold/config/mark.rb
active_scaffold-sequel-0.6.2 lib/active_scaffold/config/mark.rb
active_scaffold-sequel-0.6.1 lib/active_scaffold/config/mark.rb
active_scaffold-sequel-0.6.0 lib/active_scaffold/config/mark.rb