Sha256: 98c3009d9a9d95e0c80edbb04ed6147729ee613235c3029e124b1dfd3aea8427

Contents?: true

Size: 1.5 KB

Versions: 84

Compression:

Stored size: 1.5 KB

Contents

class Marty::TagGrid < Marty::Grid
  has_marty_permissions \
  read:   :any,
  create: :dev

  def configure(c)
    super

    c.header       = false
    c.model        = "Marty::Tag"
    c.multi_select = false

    c.attributes ||= [:name, :created_dt, :user__name, :comment]

    c.store_config.merge!({sorters: [{property: :created_dt,
                                      direction: 'DESC'}]})
  end

  endpoint :add_window__add_form__submit do |params|
    data = ActiveSupport::JSON.decode(params[:data])

    return client.netzke_notify("Permission Denied") if
      !config[:permissions][:create]

    # FIXME: disallow tag creation when no script has been modified?

    tag = Marty::Tag.do_create(nil, data["comment"])

    if tag.valid?
      client.success = true
      client.netzke_on_submit_success
      return
    end

    client.netzke_notify(model_adapter.errors_array(tag).join("\n"))
  end

  action :add_in_form do |a|
    a.text     = I18n.t("tag_grid.new")
    a.tooltip  = I18n.t("tag_grid.new")
    a.icon     = :time_add
    a.disabled = !config[:permissions][:create]
  end

  def default_bbar
    [:add_in_form]
  end

  def default_context_menu
    []
  end

  def default_form_items
    [:comment]
  end

  attribute :name do |c|
  end

  attribute :created_dt do |c|
    c.text   = "Date/Time"
    c.format = "Y-m-d H:i"
    c.hidden = true
  end

  attribute :user__name do |c|
    c.width  = 100
  end

  attribute :comment do |c|
    c.width  = 100
    c.flex   = 1
  end

end

TagGrid = Marty::TagGrid

Version data entries

84 entries across 84 versions & 1 rubygems

Version Path
marty-2.1.5 app/components/marty/tag_grid.rb
marty-2.1.4 app/components/marty/tag_grid.rb
marty-2.1.3 app/components/marty/tag_grid.rb
marty-2.1.2 app/components/marty/tag_grid.rb
marty-2.1.1 app/components/marty/tag_grid.rb
marty-2.1.0 app/components/marty/tag_grid.rb
marty-2.0.9 app/components/marty/tag_grid.rb
marty-2.0.8 app/components/marty/tag_grid.rb
marty-2.0.7 app/components/marty/tag_grid.rb
marty-2.0.6 app/components/marty/tag_grid.rb
marty-2.0.5 app/components/marty/tag_grid.rb
marty-2.0.4 app/components/marty/tag_grid.rb
marty-2.0.3 app/components/marty/tag_grid.rb
marty-2.0.2 app/components/marty/tag_grid.rb
marty-2.0.1 app/components/marty/tag_grid.rb
marty-2.0.0 app/components/marty/tag_grid.rb
marty-1.2.9 app/components/marty/tag_grid.rb
marty-1.2.8 app/components/marty/tag_grid.rb
marty-1.2.7 app/components/marty/tag_grid.rb
marty-1.2.6 app/components/marty/tag_grid.rb