Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

1: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.

...

Meta data to be considered: ct.metadata.getAppsByLayoutId(workspaceId,layoutId) → Gives the Portlet information of individual apps that have been configured against the sub workspace.
ct.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
languagejs
cbxcanvas.lib.widgetContainer = Class(cbx.core.Component, {
/*

Initializes the widget container.
*/ 
	layoutID: '',
	workspaceID: '',
	odProduct: '',
	odSubProduct: '',
	widgetsArray: null,
	appMVRegistry : null,
	commManager : null,
	totalApps : 0,
constructor: function(config) {
/*
adds the widget container as a child item for the sub-workspace/layout container.
*/
	cbxcanvas.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 = ct.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 = cbx.core.ws.metadata.getAppsByLayoutId( this.workspaceID, this.layoutID);
	this.totalApps = apps.length;
	for( var i = 0, len = apps.length; i < len; i++ ) { 
		if(cbx.isEmpty(apps[i].BLOCK_POSITION)){
		apps[i].BLOCK_POSITION='CENTER';
	}
	var config;
	config = {
	"widgetConfig": apps[i],
	"workspaceID": this.workspaceID,
	"widgetContainer":this
	};
var widgetObj = new cbx.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);