ui5_easy_use
Version:
CLI tool for SAP ui5 and SAPUI5 projects to initialize apps, generate pages, insert form and table components, manage routing, and automate i18n bindings
61 lines (49 loc) • 1.89 kB
JavaScript
sap.ui.define([
"sap/ui/core/mvc/Controller"
], function (Controller) {
"use strict";
return Controller.extend("${ez5.appName}.controller.App", {
onBeforeRouteMatched: function (oEvent) {
const fclModel = this.getOwnerComponent().getModel("fclModel");
const routeArguments = oEvent.getParameters().arguments || {};
const layout = routeArguments.layout || this._getDefaultLayout();
if (layout) {
fclModel.setProperty("/layout", layout);
}
},
onRouteMatched: function (oEvent) {
const routeArguments = oEvent.getParameter("arguments") || {};
this._updateUIElements();
this.currentRouteName = oEvent.getParameter("name");
this.currentProduct = routeArguments.product;
this.currentSupplier = routeArguments.supplier;
},
onStateChanged: function (oEvent) {
const isNavigationArrow = oEvent.getParameter("isNavigationArrow");
const layout = oEvent.getParameter("layout");
this._updateUIElements();
if (isNavigationArrow) {
this.oRouter.navTo(this.currentRouteName, {
layout: layout,
id: this.currentProduct
}, true);
}
},
// Keeps FlexibleColumnLayout button visibility and layout state in sync with routing.
_updateUIElements: function () {
const fclModel = this.getOwnerComponent().getModel("fclModel");
const uiState = this.getOwnerComponent().getHelper().getCurrentUIState();
fclModel.setData(uiState);
},
_getDefaultLayout: function () {
return this.getOwnerComponent().getHelper().getNextUIState(0).layout;
},
handleBackButtonPressed: function () {
window.history.go(-1);
},
onExit: function () {
this.oRouter.detachRouteMatched(this.onRouteMatched, this);
this.oRouter.detachBeforeRouteMatched(this.onBeforeRouteMatched, this);
}
});
});