Sha256: a46d2abe3d8657b9b44de5968868e69755b646c529a4973c723520d97f79ec6e

Contents?: true

Size: 1.74 KB

Versions: 65

Compression:

Stored size: 1.74 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,
      :input_validated,
      :output_validated,
      :strict_validate,
      :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
  [:logged, :input_validated, :output_validated, :strict_validate].each do
    |a|
    attribute a do |c|
      c.width = 110
    end
  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,
      :input_validated,
      :output_validated,
      :strict_validate,
    ]
  end

end
ApiConfigView = Marty::ApiConfigView

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
marty-2.3.15 app/components/marty/api_config_view.rb
marty-2.3.14 app/components/marty/api_config_view.rb
marty-2.3.13 app/components/marty/api_config_view.rb
marty-2.3.12 app/components/marty/api_config_view.rb
marty-2.3.11 app/components/marty/api_config_view.rb
marty-2.3.10 app/components/marty/api_config_view.rb
marty-2.3.9 app/components/marty/api_config_view.rb
marty-2.3.8 app/components/marty/api_config_view.rb
marty-2.3.7 app/components/marty/api_config_view.rb
marty-2.3.5 app/components/marty/api_config_view.rb
marty-2.3.4 app/components/marty/api_config_view.rb
marty-2.1.5 app/components/marty/api_config_view.rb
marty-2.3.2 app/components/marty/api_config_view.rb
marty-2.3.1 app/components/marty/api_config_view.rb
marty-2.3.0 app/components/marty/api_config_view.rb
marty-2.1.4 app/components/marty/api_config_view.rb
marty-2.1.3 app/components/marty/api_config_view.rb
marty-2.1.2 app/components/marty/api_config_view.rb
marty-2.1.1 app/components/marty/api_config_view.rb
marty-2.1.0 app/components/marty/api_config_view.rb