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-1.0.26 app/components/marty/tag_grid.rb
marty-1.0.25 app/components/marty/tag_grid.rb
marty-1.0.24 app/components/marty/tag_grid.rb
marty-1.0.23 app/components/marty/tag_grid.rb
marty-1.0.22 app/components/marty/tag_grid.rb
marty-1.0.20 app/components/marty/tag_grid.rb
marty-1.0.19 app/components/marty/tag_grid.rb
marty-1.0.18 app/components/marty/tag_grid.rb
marty-1.0.17 app/components/marty/tag_grid.rb
marty-1.0.15 app/components/marty/tag_grid.rb
marty-1.0.14 app/components/marty/tag_grid.rb
marty-1.0.13 app/components/marty/tag_grid.rb
marty-1.0.12 app/components/marty/tag_grid.rb
marty-1.0.11 app/components/marty/tag_grid.rb
marty-1.0.10 app/components/marty/tag_grid.rb
marty-1.0.9 app/components/marty/tag_grid.rb
marty-1.0.8 app/components/marty/tag_grid.rb
marty-1.0.7 app/components/marty/tag_grid.rb
marty-1.0.6 app/components/marty/tag_grid.rb
marty-1.0.5 app/components/marty/tag_grid.rb