Skip to content

Set SAPUI5 / SAP Fiori flexibility page variant favorites without user input

License

Notifications You must be signed in to change notification settings

mpah/UI5FlexibilityFavorites

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

UI5FlexibilityFavorites

Set SAPUI5 / SAP Fiori Page Variants automatically without user input by key or name. Additional option preselect a page variant selected as default for all users. This can be done by name or key. Requires the SmartVariantManagement Control in view.

Before:

image

After:

image

Requirements

SAPUI5 Application connected to Flexibility Services. SmartVariantManagement component in view.

Example

JSON Model:

Requires a JSON Model called FavoritePageVariants, for possible properties see example FavoritePageVariants.json Works with either key or name but you can also provide both. Keep in mind name is lcoalization dependant. The default page variant will only be selected if the user has not definined a default page variant already.

Add FavoritePageVariants as a JSON model in the manifest:

"FavoritePageVariants": {
      "type": "sap.ui.model.json.JSONModel",
      "settings": {},
      "uri": "model/FavoritePageVariants.json",
      "preload": true
}

View must have the SmartVariantManagement control. SAP Fiori Elements apps have this if variant management is enabled (it is on default).

<smartVariantManagement:SmartVariantManagement id="smartVariantManagement" persistencyKey="flexibilityexamplePageVariants"/>

Initialize the FlexibilityFavorites Module:

Include the FlexibilityFavorites js module in your controller

sap.ui.define([
	"zmpah/flexibilityexample/controller/FlexibilityFavorites",
], function (FlexibilityFavorites) {
	"use strict";
	return BaseController.extend("zmpah.flexibilityexample.controller.App", {

Initialization must be done after metadata & flexibility data has already arrived but can happen before any actual data is loaded.

onBeforeRebindTable: function (oEvent) {
    if (!this.oSmartVariantManagment) {
       this.oSmartVariantManagment = this.byId("smartVariantManagement");
       var oFlexibilityFavoritesModel = this.getOwnerComponent().getModel("FavoritePageVariants");
       FlexibilityFavorites.setup(this.oSmartVariantManagment, oFlexibilityFavoritesModel);
    }
 }

About

Set SAPUI5 / SAP Fiori flexibility page variant favorites without user input

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published