Class: Netzke::Workspace::TabPanel

Inherits:
Base
  • Object
show all
Defined in:
lib/netzke/workspace/tab_panel.rb

Overview

A component that allows for dynamical loading/unloading of other Netzke components in tabs.

Call the loadTab method on the client to dynamically load a component:

workspaceTabPanel.loadTab("UserGrid", {newTab: true})
  • will load a UserGrid component from the server in a new tab.

Client-side methods:

loadTab(componentClassName, options) - loads a component in a (new or currently active) tab

* +options+ is an object that may contain the following keys:
    * +newTab+ (boolean) - whether to load a component in a newly created tab
    * +clientConfig+ (object) - config for the loaded Netzke component

closeAllTabs - closes all open tabs

Security

By default, this component allows loading any Netzke component as requested from the client (component class has been sent as a paremeter for the deliver_component endpoint), which may not be secury enough for you. Override the :tab component to do any proper checks (see an example in the specs app).

Instance Method Summary collapse

Instance Method Details

#configure(c) ⇒ Object


34
35
36
37
# File 'lib/netzke/workspace/tab_panel.rb', line 34

def configure(c)
  c.tabs = state[:tabs].presence
  super
end

#update_tab_session_config(c) ⇒ Object


49
50
51
52
53
54
# File 'lib/netzke/workspace/tab_panel.rb', line 49

def update_tab_session_config(c)
  tabs = state[:tabs] ||= {}
  if tab_index = c.delete(:tabIndex)
    tabs[tab_index] = c
  end
end