MenuGroup Utility

Overview

The MenuGroup Utility file helps a developer configure the dynamic App Menu items of the Data Aggregation component. It centralizes the methods that configure the widget properties of the Container of the Data Aggregation component. The MenuGroup Utility file is available under the modules/ require folder of the Infinity application.

NOTE: The MenuGroup Utility file is used inside the Mobile Banking application.

The MenuGroup Utility file contains the following methods.

MenuGroup JSON

The MenuGroup Utility file configures the default input JSON structure used by the Data Aggregation component. The MenuGroup JSON has a parent-child structure with the following ten menu groups.

  • accountServices
  • transfers
  • myBills
  • wealth
  • approvals & requests
  • tradeFinance
  • chequeManagement
  • alertsMessages
  • helpSupport
  • settings

Each menu group item in MenuGroup JSON has the properties given below.

Key Description
type
  • Defines the channels specific to the menu group.
  • This key can have the following four values.
    • RETAIL
    • BUSINESS
    • WEALTH
    • ALL_CHANNELS
menuId

Programmatic name of the Menu group item.

name

Name for each menu group item and the i18n value.

icon

Sets the default icon.

parentId

The grouping param used in all menu group items.

parent

Parent name for each menu group item and the i18n value.

notificationDot

Boolean value to enable notifications for each menu group item.

notificationsCount Sets the number of notifications for each menu group item.
weight Sets the order of display of each menu group item child.
entitlements Sets the permissions required to display each menu group item.
entitlementsOperation
  • This key determines the menu group item that appears based on the permissions.
  • This key can have the following two values.
    • and: The user must have all the permissions listed in the entitlements key.
    • or: The user can have any permissions listed in the entitlements key.
target JSON object containing the destination form and the microapp that the application navigates to with the click of the menu group item.

Here is a sample of the Constant declaration provided in the MenuGroup Utility file.

    /**@member {Array}  Contains the list for menu group items */
[{
        "type": "['RETAIL','BUSINESS','WEALTH','ALL_CHANNELS']",
        "menuId": "myCards",
        "name": kony.i18n.getLocalizedString('i18n.common.myCards'),
        "icon": "\ue91e",
        "parentId": "accountServices",
        "parent": kony.i18n.getLocalizedString('i18n.common.accountServices'),
        "notificationDot": false,
        "notificationsCount": "",
        "weight": 10,
        "entitlements": "['TEST_HIDE','TEST_FEATURES']",
        "entitlementsOperation": "or",
        "target": {
            "microApp": "CommonsMA",
            "form": "frmStartup"
        }
    },
    {
        "type": "['RETAIL','BUSINESS','WEALTH','ALL_CHANNELS']",
        "menuId": "exchangeRates",
        "name": kony.i18n.getLocalizedString('i18n.kony.exchangeRates.ExchangeRatesHeader'),
        "icon": "\ue941",
        "parentId": "accountServices",
        "parent": kony.i18n.getLocalizedString('i18n.common.accountServices'),
        "notificationDot": false,
        "notificationsCount": "",
        "weight": 15,
        "entitlements": "['TEST_FEATURES']",
        "entitlementsOperation": "or",
        "target": {
            "microApp": "CommonsMA",
            "form": "frmStartup"
        }
    },
    ...
];

The following sample code shows how to incorporate MenuGroup JSON from the Form Controller.

define(['MenuGroupUtility', 'ComponentUtility'], function(MenuGroupUtility, ComponentUtility) {
    return {
        onNavigate: function() {
            let contextType;
            ...
            let entitlements = {
                "features": configManager.getUserFeatures(),
                "permissions": configManager.getUserPermissions()
            };
            ...
            if (
                !this.componentUtility.isEmptyNullUndefined(
                    userAttributes.CustomerType_id
                ) &&
                configManager.isCombinedUser !== "true"
            ) {
                switch (userAttributes.CustomerType_id) {
                    case "TYPE_ID_BUSINESS":
                        configManager.isSMEUser = "true";
                        break;
                    case "TYPE_ID_RETAIL":
                        configManager.isRBUser = "true";
                        contextType = "['RETAIL']";
                        break;
                }
            }
            let wealthPermissions =
                entitlements.features.includes("WEALTH_WATCHLIST_INSTRUMENT_CREATE") ||
                entitlements.features.includes("WEALTH_WATCHLIST_INSTRUMENT_VIEW");
            if (userAttributes.CustomerType_id !== "TYPE_ID_BUSINESS") {
                if (wealthPermissions && configManager.isCombinedUser !== "true") {
                    contextType = "['RETAIL','WEALTH']";
                } else if (wealthPermissions && configManager.isCombinedUser) {
                    contextType = "['RETAIL','BUSINESS','WEALTH','ALL_CHANNELS']";
                }
            } else {
                contextType = "['RETAIL','BUSINESS']";
            }
            this.footerMenuUtility = new FooterMenuUtility();
            let menuData = this.menuGroupUtility;
            menuData = this.checkEntitlementsAndType(menuData, entitlements, contextType);
            this.view.menuGroup.setContext(menuData);
        }
    };
});      

checkEntitlementsAndType Method

This method checks the entitlements and channel type for each menu group item.

Parameter Value
Input parameter
  • menuData: Contains the information about the Menu group item.
  • entitlements: Contains the features and permissions required for each Menu Group item.
  • contextType: Contains the Menu group channel type.

How to Consume from Form Controller 

checkEntitlementsAndType: function(menuData, entitlements, contextType) {
    var scope = this;
    try {
        let menuDataEntitled = [];
        ...
        for (let menuItem = 0; menuItem < menuData.length; menuItem++) {
            isMicroAppPresent = true; //!scope.componentUtility.isEmptyNullUndefined(configManager) ? configManager.isMicroAppPresent(menuData[menuItem].target.microApp) : true;
            ...
            if (isMicroAppPresent && isEntitled && hasContextType) {
                menuDataEntitled.push(menuData[menuItem]);
            }
        }
        return menuDataEntitled;
    } catch (err) {
        scope.setError(err, "checkEntitlementsAndType");
    }
},

Return Type

menuData: Contains the entitlement information about the Menu group item.

isEntitled Method

This method checks whether the input entitlements satisfy the permission.

Parameter Value
Input parameter
  • userPermissions: Contains the permissions of the user.
  • entitlements: Contains the features and permissions required for each Menu Group item.
  • entitlementsOperation: Determines if the menu group item appears based on the permissions.

How to Consume from Form Controller 

isEntitled: function(
    userPermissions,
    entitlements,
    entitlementsOperation
) {
    var scope = this;
    try {
        if (userPermissions.length === 0) {
            return true;
        }
        let entitlementFlag = false;
        for (let index = 0; index < userPermissions.length; index++) {
            if (
                entitlements.features.includes(userPermissions[index]) ||
                entitlements.permissions.includes(userPermissions[index])
            ) {
                entitlementFlag = true;
                if (entitlementsOperation === "or") {
                    break;
                }
            } else {
                entitlementFlag = false;
                if (entitlementsOperation === "and") {
                    break;
                }
            }
        }
        return entitlementFlag;
    } catch (err) {
        scope.setError(err, "isEntitled");
    }
},

Return Type

Returns a Boolean value. If the value is true, the input entitlements satisfy the permission.

checkContextType Method

This method checks the input type and the channel type from the Context data object.

Parameter Value
Input parameter
  • userContextType: Contains the user channel type.
  • contextType: Contains the channel type for a menu group item.

How to Consume from Form Controller 

checkContextType: function(userContextType, contextType) {
    var scope = this;
    try {
        if (userContextType.length === 0) {
            return true;
        }
        let typeFlag = false;
        for (let index = 0; index < userContextType.length; index++) {
            if (contextType.includes(userContextType[index])) {
                typeFlag = true;
                break;
            }
        }
        return typeFlag;
    } catch (err) {
        scope.setError(err, "checkContextType");
    }
},

Return Type

Returns a Boolean value. The menu group item has a context type if the value is true.

setError Method

This method handles any error that occurs in the component. This method passes the error object information from the component to the Segment Template controller.

Parameter Value
Input parameter

JSON object contains the following keys.

  • level: This key includes the String value regarding where the error occurs. It can be from the component View controller or the component Business controller.
  • method: This key contains the function that handles the error.
  • error: This key contains the actual error message and the stack.

How to Consume from the App Level Widget Template Controller

var errordata = {
	"level": "FormController",
	"method": "method",
	"error": errorMsg
};
this.view.menugrp.setError(errordata);

Return Type

NA

Handle Menu Group Item Navigation

This method binds the navigation callback actions for each menu item. These callback actions set the destination form for each menu constant. A developer must configure the target property in the MenuGroupUtility file to achieve default navigation. In the menu items where the default navigation does not apply, the developer can customize the navigation for a menu item based on the menu ID, as shown in the image below.

Parameter Value
Input parameter

NA

How to Consume from Form Controller 

preShow: function() {
    ...
    scope.view.menuGroup.onRowClick = this.onBindRowClick.bind(scope);
}

onBindRowClick: function(segData) {
    var scope = this;
    try {
        let informationPC = kony.mvc.MDAApplication.getSharedInstance().getModuleManager().getModule({
            "appName": scope.componentUtility.microAppConstants.ABOUTUS,
            "moduleName": "InformationUIModule"
        });
        switch (segData.menuId) {
            case "contactUs":
                applicationManager.getPresentationUtility().showLoadingScreen();
                let informationUIModule = kony.mvc.MDAApplication.getSharedInstance().getModuleManager().getModule({
                    appName: scope.componentUtility.microAppConstants.ABOUTUS,
                    moduleName: "InformationUIModule"
                });
                informationUIModule.presentationController.showContactUsPage();
                break;
                ...
            default:
                let navManager = applicationManager.getNavigationManager();
                navManager.navigateTo({
                    "appName": segData.target.microApp,
                    "friendlyName": segData.target.form
                });
        }
    } catch (err) {
        scope.setError(err, "onBindRowClick");
    }
},

Return Type

None

 

 

Copyright © 2020- Temenos Headquarters SA

Published on :
Monday, May 2, 2022 5:08:50 PM IST

Feedback
x