Home page portlets

You can add new portlets or override existing portlets in the application.

Every portlet has the following files:
  • <portlet_name>.config.js
  • <portlet_name>.controller.js
  • <portlet_name>.tpl.html
  • <portlet_name>-mini.controller.js
  • <portlet_name>.mini.tpl.html

Adding or overriding portlets

Portlets can be registered or overridden by using the registerCustomPortlet() method. A registry mechanism is provided to register custom portlets and also to override the sequence or visibility or personaConfig of the default portlets. A config.js file must be created for a custom portlet and also for a portlet that needs to be overridden.

You cannot change the templateUrl and controller for a default portlet, if you wish to override it. Overriding is supported only for changing the sequence, visibility, resourceId and personaConfig for the portlet. However, to change the templateUrl and controller, it is recommended that you hide the default portlet by overriding and then register a new custom portlet.

  1. Define a new portlet and the relevant template HTML, CSS and Controller JS files in the relevant folder in runtime.
  2. Define a new config file to register the custom portlet as shown in the following code snippet::
    angular.module('store').config(['iscPortletPvdrProvider', function(iscPortletPvdrProvider) {
    		iscPortletPvdrProvider.registerCustomPortlet(customName, customConfigJson);

registerCustomMethodPortlet method

This method is used to add a new portlet to the home page. It must only be used by the customer to register new portlet or override the following default portlet configuration attributes: sequenceNumber, showPortlet, resourceId and personaConfig.
Note: While using this method, ensure that your portlet name does not conflict with that of any default portlets. This can be accomplished by adding an "extn_" before or towards the end of the name of the portlet being defined as a new portlet or to override a default portlet. For example, instead of naming your portlet as "find-products-portlet.config.js" which will clash with the name of default portlet, change the name of your portlet as "extn_find-products-portlet.config.js" or "find-products-portlet_extn.config.js". This is applicable to miniViewTemplateUrl and miniViewController attributes, if defined for custom portlet. It is recommended that you follow this guideline for all portlets defined, including the old specification portlets.
customName {String} Logical name of the portlet. This must be unique for each portlet in the application. In case of 2 or more custom portlets having the same name, the 2nd portlet onwards will be ignored. However, sequenceNumber, showPortlet, resourceId and personaConfig attributes of an default portlet can be overridden using this method by passing the default portlet name.
Note: The customName cannot be "moretasksportlet". This is application reserved.
customConfigJson {object} This is the JSON configuration for various properties of the portlet. Supported attributes that are used are as follows:
  • templateUrl {String}: Mandatory for new custom portlet. It is the URL of the HTML template of the portlet and it is ignored, if passed to override a default portlet.
  • controller {String}: Mandatory for new custom portlet. It is the name of the controller for the portlet and it is ignored if passed to override a default portlet.
  • sequenceNumber {Number}: Portlets are sorted in ascending order of this number. Thus, smaller number means the portlet will appear in the beginning and larger number means portlet will be displayed later in the sequence. This value should not be given in multiples of 10 for custom portlets. It can be passed to override the corresponding value of a default portlet. For new specification portlets this is superseded by personaConfig.personaSequenceNumber.
  • showPortlet {Boolean}: Mandatory for new custom portlet. This is a flag to indicate whether the portlet should be displayed on the UI or not. By setting it to false, you will not show the portlet on UI regardless of whether the user has resource permission to the portlet or not. It can be passed to override the corresponding value of a default portlet.
  • resourceId {String}: Mandatory for new custom portlet. This is the resource permission for the portlet. Multiple resource permissions can be combined by using a pipe |. For example, 'EXTN000015|EXTN000012|EXTN000028'. A portlet is displayed if the user has permissions to view at least one of the resource ids given. It can be passed to override corresponding value of a default portlet.
  • personaConfig {object}: Mandatory for new custom portlet. This is a new JSON configuration that determines whether a portlet is a new specification portlet or not. If not defined, the portlet is treated as an old specification portlet. It contains the attributes that are necessary to make persona-related rendering decisions. Supported attributes are as follows:
    • personaName {String}: Mandatory for new custom portlet. This is the name of a persona that has been defined in Sterling Business Center. It corresponds to the CodeName for the CommonCode CodeType "WSC_HOMEPAGE_PERSONA". It is used on the UI to determine whether the portlet should be one of the available portlets for the currently selected persona or not. It is only considered in the list, if the personaName matches the currently selected persona. This attribute does not guarantee the visibility. Visibility is determined by a combination of showPortlet and resourceId.
    • personaSequenceNumber {Number}: Mandatory for new custom portlet. This supercedes the sequenceNumber attribute for new specification portlets. It must be given in multiples of 5 for the default portlets. All visible portlets for the same persona will be arranged in the ascending order of this number. However, for custom portlets, this value should be non-multiples of 5.
    • miniViewTemplateUrl {String}: Mandatory for new custom portlet. The URL of the template used to create the mini or small view of the portlet, when it overflows into the More Tasks portlet.
    • miniViewController {String}: Mandatory for new custom portlet. The name of the controller used to make mashup/API calls to display numbers on the mini/small view of the portlet when it overflows into the More Tasks portlet.
  • Other attributes applicable to old specification portlets such as templateUrl, controller, sequenceNumber (optional), showPortlet and resourceId are still valid.
  • The default portlets additionally contain site map attributes. These are used to create the Site Map and are not mandatory. Custom portlets need not have site map attributes.
To register a new portlet (new specification):
iscPortletPvdrProvider.registerCustomPortlet('extnfindproductsportlet', {
		templateUrl: './store/views/home/extn_find-products-portlet.tpl.html',
		controller: 'store.views.home.extn_find-products-portlet',
		showPortlet: true,
		resourceId: 'EXTN000031',
		personaConfig: {
			personaName: 'Customer_Service',
			personaSequenceNumber: 11,//these are in non-multiples of 5.
			miniViewTemplateUrl: './store/views/home/extn_find-products-portlet-mini.tpl.html',
			miniViewController: 'store.views.home.extn_find-products-portlet-mini'
		}
	});
To override a default portlet (new specification), change permission, persona and personaSequenceNumber:
iscPortletPvdrProvider.registerCustomPortlet('findproductsportlet', {
		resourceId: 'EXTN000071',
		personaConfig: {
			personaName: 'Custom_Customer_Service',//this is assumed to be a new persona added to SBC.
			personaSequenceNumber: 11//these are in non-multiples of 5.
		}
	});