Sha256: da3aad4382ed6489baaf7ffd6cb77246b09255e242890f652721041f291be92f

Contents?: true

Size: 1.6 KB

Versions: 8

Compression:

Stored size: 1.6 KB

Contents

class Marty::ApiConfigView < Marty::Grid
  has_marty_permissions create: :admin,
                        read: :any,
                        update: :admin,
                        delete: :admin

  def configure(c)
    super
    c.model = Marty::ApiConfig
    c.title = 'API Config'
    c.attributes = [
      :script,
      :node,
      :attr,
      :logged,
      :validated,
      :created_at,
      :updated_at,
    ]
    c.paging = :pageination
    c.editing = :in_form
    c.store_config.merge!(
      sorters: [{ property: :script, direction: :ASC},
                { property: :node, direction: :ASC},
                { property: :attr, direction: :ASC},
               ])
    @model = c.model
  end
  attribute :script do |c|
    editor_config = {
      trigger_action: :all,
      xtype:          :combo,
      store:          Marty::Script.where(obsoleted_dt: 'infinity').
        order(:name).pluck(:name),
      forceSelection: true,
    }
    c.merge!(
      column_config: { editor: editor_config },
      field_config:  editor_config,
      type:          :string,
    )
    c.width = 150
  end
  [:node, :attr].each do |a|
    attribute a do |c|
      c.width = 150
      c.setter = lambda { |r, v| r.send("#{a}=", v.blank? ? nil : v) }
    end
  end
  attribute :logged do |c|
    c.width = 100
  end
  attribute :validated do |c|
    c.width = 110
  end
  [:created_at, :updated_at].each do |a|
    attribute a do |c|
      c.read_only = true
    end
  end
  def default_form_items
    [
      :script,
      :node,
      :attr,
      :logged,
      :validated,
    ]
  end

end
ApiConfigView = Marty::ApiConfigView

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
marty-1.0.35 app/components/marty/api_config_view.rb
marty-1.0.34 app/components/marty/api_config_view.rb
marty-1.0.33 app/components/marty/api_config_view.rb
marty-1.0.32 app/components/marty/api_config_view.rb
marty-1.0.31 app/components/marty/api_config_view.rb
marty-1.0.30 app/components/marty/api_config_view.rb
marty-1.0.29 app/components/marty/api_config_view.rb
marty-1.0.28 app/components/marty/api_config_view.rb