Sha256: b39ab3543dee5fd578a2e87ba6543b1e2b1b761eccdcc74ed23284f9fa69e915

Contents?: true

Size: 1.94 KB

Versions: 15

Compression:

Stored size: 1.94 KB

Contents

module ActiveScaffold::Config
  class Form < Base
    def initialize(core_config)
      super
      # start with the ActionLink defined globally
      @link = self.class.link.clone unless self.class.link.nil?
      @show_unauthorized_columns = self.class.show_unauthorized_columns
      @refresh_list = self.class.refresh_list
      @persistent = self.class.persistent

      # no global setting here because multipart should only be set for specific forms
      @multipart = false
    end

    # global level configuration
    # --------------------------
    # show value of unauthorized columns instead of skip them
    class_attribute :show_unauthorized_columns

    # whether the form stays open after an update or not
    cattr_accessor :persistent
    @@persistent = false

    # whether we should refresh list after update or not
    cattr_accessor :refresh_list
    @@refresh_list = false

    # instance-level configuration
    # ----------------------------

    # show value of unauthorized columns instead of skip them
    attr_accessor :show_unauthorized_columns
    
    # the ActionLink for this action
    attr_accessor :link

    # the label for this Form action. used for the header.
    attr_writer :label

    # whether the form stays open after a create or not
    attr_accessor :persistent

    # whether we should refresh list after create or not
    attr_accessor :refresh_list

    # provides access to the list of columns specifically meant for the Form to use
    def columns
      unless @columns # lazy evaluation
        self.columns = @core.columns._inheritable
        self.columns.exclude :created_on, :created_at, :updated_on, :updated_at, :as_marked
        self.columns.exclude *@core.columns.collect{|c| c.name if c.polymorphic_association?}.compact
      end
      @columns
    end
    
    public :columns=
    
    # whether the form should be multipart
    attr_writer :multipart
    def multipart?
      @multipart ? true : false
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
active_scaffold-3.3.3 lib/active_scaffold/config/form.rb
active_scaffold-3.3.2 lib/active_scaffold/config/form.rb
active_scaffold-3.3.1 lib/active_scaffold/config/form.rb
active_scaffold-3.3.0 lib/active_scaffold/config/form.rb
active_scaffold-3.2.20 lib/active_scaffold/config/form.rb
active_scaffold-3.3.0.rc3 lib/active_scaffold/config/form.rb
active_scaffold-3.3.0.rc2 lib/active_scaffold/config/form.rb
active_scaffold-3.2.19 lib/active_scaffold/config/form.rb
active_scaffold-3.3.0.rc lib/active_scaffold/config/form.rb
active_scaffold-3.2.17 lib/active_scaffold/config/form.rb
active_scaffold-3.2.16 lib/active_scaffold/config/form.rb
active_scaffold-3.2.15 lib/active_scaffold/config/form.rb
active_scaffold-3.2.14 lib/active_scaffold/config/form.rb
active_scaffold-3.2.13 lib/active_scaffold/config/form.rb
active_scaffold-3.2.12 lib/active_scaffold/config/form.rb