Class: Netzke::Communitypack::Portal

Inherits:
Base
  • Object
show all
Defined in:
lib/netzke/communitypack/portal.rb

Overview

A component based on Ext.app.PortalPanel with the following features:

  • dynamic loading of portlets from the server (by calling the `addPortlet` JS method)

  • dynamic deleting of portlets from the server (by pressing the close tool)

  • storing portlets layout in the session while dragging portlets around

TODO: implement other persistence besides the session-based one

Instance Method Summary collapse

Instance Method Details

#componentsObject


39
40
41
42
43
44
# File 'lib/netzke/communitypack/portal.rb', line 39

def components
  # we'll store components in persistence storage
  super.tap do |comps|
    comps.merge!(component_session[:components] || {})
  end
end

#deliver_component_endpoint(params) ⇒ Object


87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/netzke/communitypack/portal.rb', line 87

def deliver_component_endpoint(params)
  if params[:name] =~ /^netzke_/ # TODO: rename to portlet_
    cmp_name = params[:name]
    cmp_index = cmp_name.sub("netzke_", "").to_i

    # add new component to components hash first
    component_session[:components] ||= {}
    component_session[:components].merge!(cmp_name.to_sym => portlet_config(params))

    # add it also into the layout
    component_session[:layout].first[:items] << cmp_name.to_sym
  end

  super
end

#js_configObject


32
33
34
35
36
37
# File 'lib/netzke/communitypack/portal.rb', line 32

def js_config
  super.tap do |c|
    # we'll store the items in persistence storage
    c[:items] = component_session[:layout] ||= c[:items]
  end
end