Module: Netzke::Basepack::ItemPersistence

Extended by:
ActiveSupport::Concern
Defined in:
lib/netzke/basepack/item_persistence.rb,
lib/netzke/basepack/item_persistence/events_plugin.rb

Overview

When mixed into a component with resizable layout (e.g. border layout), this module enables persistence for regions size and collapsed/expanded state.

Defined Under Namespace

Classes: EventsPlugin

Instance Method Summary collapse

Instance Method Details

#extend_item(item) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/netzke/basepack/item_persistence.rb', line 28

def extend_item(item)
  item = super
  item_id = item[:netzke_component] || item[:item_id] # identify regions by item_id

  if item_id
    item[:width] = state[:"#{item_id}_width"] if state[:"#{item_id}_width"]
    item[:height] = state[:"#{item_id}_height"] if state[:"#{item_id}_height"]
    if state[:"#{item_id}_collapsed"].present?
      item[:collapsed] = state[:"#{item_id}_collapsed"]
    end
  end

  item
end