Sha256: f4549d16c180824cf7bb3036a448e815711905fd4b1363a7bd5653847d1b88c0

Contents?: true

Size: 1.47 KB

Versions: 54

Compression:

Stored size: 1.47 KB

Contents

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

    def initialize(core_config)
      @core = core_config
      self.shallow_delete = self.class.shallow_delete
      @action_group = self.class.action_group.clone if self.class.action_group
    end

    # global level configuration
    # --------------------------
    cattr_accessor :shallow_delete
    @@shallow_delete = true

    # instance-level configuration
    # ----------------------------
    attr_accessor :shallow_delete

    # Add a nested ActionLink
    def add_link(attribute, options = {})
      column = @core.columns[attribute.to_sym]
      unless column.nil? || column.association.nil?
        options.reverse_merge! :security_method => :nested_authorized?, :label => column.association.klass.model_name.human({:count => 2, :default => column.association.klass.name.pluralize}) 
        action_link = @core.link_for_association(column, options)
        @core.action_links.add_to_group(action_link, action_group) unless action_link.nil?
      else
        
      end
    end
    
    def add_scoped_link(named_scope, options = {})
      action_link = @core.link_for_association_as_scope(named_scope.to_sym, options)
      @core.action_links.add_to_group(action_link, action_group) unless action_link.nil?
    end

    # the label for this Nested action. used for the header.
    attr_writer :label
    def label
      @label ? as_(@label) : as_(:add_existing_model, :model => @core.label)
    end

  end
end

Version data entries

54 entries across 54 versions & 3 rubygems

Version Path
active_scaffold_vho-4.0.0 lib/active_scaffold/config/nested.rb
active_scaffold_vho-3.2.14 lib/active_scaffold/config/nested.rb
active_scaffold_vho-3.2.13 lib/active_scaffold/config/nested.rb
active_scaffold_vho-3.2.12 lib/active_scaffold/config/nested.rb
active_scaffold_vho-3.2.11 lib/active_scaffold/config/nested.rb
active_scaffold_vho-3.2.10 lib/active_scaffold/config/nested.rb
active_scaffold_vho-3.2.9 lib/active_scaffold/config/nested.rb
active_scaffold_vho-3.2.8 lib/active_scaffold/config/nested.rb
active_scaffold_vho-3.2.7 lib/active_scaffold/config/nested.rb
active_scaffold_vho-3.2.6 lib/active_scaffold/config/nested.rb
active_scaffold_vho-3.2.5 lib/active_scaffold/config/nested.rb
active_scaffold_vho-3.2.4 lib/active_scaffold/config/nested.rb
active_scaffold_vho-3.2.3 lib/active_scaffold/config/nested.rb
active_scaffold_vho-3.2.2 lib/active_scaffold/config/nested.rb
active_scaffold_vho-3.2.1 lib/active_scaffold/config/nested.rb
active_scaffold_vho-3.2.0 lib/active_scaffold/config/nested.rb
active_scaffold_vho-3.0.31 lib/active_scaffold/config/nested.rb
active_scaffold_vho-3.1.8 lib/active_scaffold/config/nested.rb
active_scaffold_vho-3.0.30 lib/active_scaffold/config/nested.rb
active_scaffold_vho-3.0.29 lib/active_scaffold/config/nested.rb