Class Description: This class is responsible for constructing the widget container, i.e the container of all the Apps in a sub workspace and also instantiates the widgets as per meta data.
Called By: cbx canvas.core.LayoutManager
Meta data to be considered: ct canvas.metadata.getAppsByLayoutId(workspaceId,layoutId) → Gives the Portlet information of individual apps that have been configured against the sub workspace.
ctcanvas.workspace.metadata.getUpdatedLayoutDef(layoutId).LAYOUT_LAYOUT → The Configured Layout type of the sub workspace. Sub workspaces today support the following layouts:
...
Sample Code Snippet:
Code Block | ||
---|---|---|
| ||
cbxcanvas.lib.widgetContainer = Class(cbxcanvas.core.Component, { /* Initializes the widget container. */ layoutID: '', workspaceID: '', odProduct: '', odSubProduct: '', widgetsArray: null, appMVRegistry : null, commManager : null, totalApps : 0, constructor: function(config) { /*Adds adds the widget container as a child item for the sub-workspace/layout container. */ cbx canvas.lib.widgetContainer.$super.call(this); this.layoutID = config.layoutID; this.workspaceID = config.workspaceID; this.portal = config.portal; this.addRequestQueue = []; this.widgetsArray = new Array(); this.createContainer(); }, renderContainer : function() { var widgetContainerConf = { "eleType":"div", "class":this.layoutID, "id":this.layoutID+"WIDGET_CONTAINER" } var widgetContainer = new cbxcanvas.lib.layer(widgetContainerConf).getLayer(); this.addItem(widgetContainer); var layout = ctcanvas.workspace.metadata.getUpdatedLayoutDef(this.layoutID).LAYOUT_LAYOUT; switch(layout) { case "STACK": /** * Initialize stack class and assign to this.portal * e.g this.portal = new cbxcanvas.lib.stack() */ break; case "TWO-COLUMN": /** * Initialize two column class and assign to this.portal * e.g this.portal = new cbxcanvas.lib.stack() */ break; case "THREE-COLUMN": /** * Initialize two column class and assign to this.portal * e.g this.portal = new cbxcanvas.lib.stack() */ break; } this.initializeApps(); } /* /Initializes the apps/widgets available for that sub workspace. */ initializeApps: function() { var apps = cbxcanvas.core.ws.metadata.getAppsByLayoutId( this.workspaceID, this.layoutID); this.totalApps = apps.length; for( var i = 0, len = apps.length; i < len; i++ ) { if(cbxcanvas.isEmpty(apps[i].BLOCK_POSITION)) { apps[i].BLOCK_POSITION='CENTER'; } var config; config = { "widgetConfig": apps[i], "workspaceID": this.workspaceID, "widgetContainer":this }; var widgetObj = new cbxcanvas.core.Apps(config); this.widgetsArray[i] = widgetObj; } }, /** * Appending the corresponding app to the left or right column * based on the metadata * * @param : childConfig * { * CHILD : The actual child element * POSITION : The numbered position e.g 1 or 2 * BLOCK_POSITION : "LEFT" or "RIGHT" * } * */ appendChild : function(childConfig) { //TODO : Logic to append the portlet to the portal columns here } }); CLCR.registerCmp({'COMP_TYPE':'WIDGET_CONTAINER'}, cbxcanvas.lib.widgetContainer); |