update message box

This commit is contained in:
Lars Kaldewey 2024-10-26 10:50:41 +00:00
parent db038379ff
commit bd5c3cb045
3 changed files with 906 additions and 856 deletions

View File

@ -11,7 +11,7 @@ Set the correct backend system in the yamls <br>
Replace "/sap/bc/z2ui5" with your endpoint in the manifest
```
npm i
npm run start
npm run start-noflp
```
#### Before PR

View File

@ -1,15 +1,15 @@
sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/model/json/JSONModel",
"sap/ui/core/BusyIndicator", "sap/m/MessageBox", "sap/m/MessageToast", "sap/ui/core/Fragment", "sap/m/BusyDialog",
"sap/ui/VersionInfo", "z2ui5/cc/Server",
],
function(Controller, XMLView, JSONModel, BusyIndicator, MessageBox, MessageToast, Fragment, mBusyDialog, VersionInfo,
Server ) {
],
function (Controller, XMLView, JSONModel, BusyIndicator, MessageBox, MessageToast, Fragment, mBusyDialog, VersionInfo,
Server) {
"use strict";
return Controller.extend("z2ui5.controller.View1", {
onInit (){
onInit() {
z2ui5.oRouter.attachRouteMatched(function(oEvent) {
z2ui5.oRouter.attachRouteMatched(function (oEvent) {
z2ui5.checkInit = true;
Server.Roundtrip();
}, this);
@ -17,7 +17,7 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/
},
async onAfterRendering() {
if (!z2ui5.oResponse){
if (!z2ui5.oResponse) {
return;
}
@ -27,7 +27,7 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/
z2ui5.isBusy = false;
return;
}
const {S_POPUP, S_VIEW_NEST, S_VIEW_NEST2, S_POPOVER} = z2ui5.oResponse.PARAMS;
const { S_POPUP, S_VIEW_NEST, S_VIEW_NEST2, S_POPOVER } = z2ui5.oResponse.PARAMS;
if (S_POPUP?.CHECK_DESTROY) {
z2ui5.oController.PopupDestroy();
}
@ -90,7 +90,7 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/
oFragment.open();
},
async displayPopover(xml, viewProp, openById) {
sap.ui.require(["sap/ui/core/Element"], async function(Element) {
sap.ui.require(["sap/ui/core/Element"], async function (Element) {
const oFragment = await Fragment.load({
definition: xml,
controller: z2ui5.oControllerPopover,
@ -139,7 +139,7 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/
if (oParent) {
try {
oParent[z2ui5.oResponse.PARAMS[viewNestId].METHOD_DESTROY]();
} catch {}
} catch { }
oParent[z2ui5.oResponse.PARAMS[viewNestId].METHOD_INSERT](oView);
}
z2ui5[viewProp] = oView;
@ -162,7 +162,7 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/
if (oParent) {
try {
oParent[z2ui5.oResponse.PARAMS[viewNestId].METHOD_DESTROY]();
} catch {}
} catch { }
oParent[z2ui5.oResponse.PARAMS[viewNestId].METHOD_INSERT](oView);
}
z2ui5[viewProp] = oView;
@ -174,7 +174,7 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/
if (z2ui5.oViewPopup.close) {
try {
z2ui5.oViewPopup.close();
} catch {}
} catch { }
}
z2ui5.oViewPopup.destroy();
},
@ -185,7 +185,7 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/
if (z2ui5.oViewPopover.close) {
try {
z2ui5.oViewPopover.close();
} catch {}
} catch { }
}
z2ui5.oViewPopover.destroy();
},
@ -307,11 +307,6 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/
},
eB(...args) {
// var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
//debugger;
// z2ui5.oRouter.navTo("RouteView2");
// return;
if (!window.navigator.onLine) {
MessageBox.alert('No internet connection! Please reconnect to the server and try again.');
return;
@ -320,7 +315,7 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/
if (!args[0][2]) {
let oBusyDialog = new mBusyDialog();
oBusyDialog.open();
setTimeout( (oBusyDialog) => {
setTimeout((oBusyDialog) => {
oBusyDialog.close()
}
, 100, oBusyDialog);
@ -357,12 +352,12 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/
}
}
)
if (args[0][1]) {
z2ui5.oController.ViewDestroy();
}
// if (args[0][1]) {
// z2ui5.oController.ViewDestroy();
// }
z2ui5.oBody.ID = z2ui5.oResponse.ID;
z2ui5.oBody.ARGUMENTS = args;
z2ui5.oBody.ARGUMENTS.forEach( (item, i) => {
z2ui5.oBody.ARGUMENTS.forEach((item, i) => {
if (i == 0) {
return;
}
@ -397,7 +392,7 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/
}
;
}
;MessageBox.error(err.toLocaleString());
; MessageBox.error(err.toLocaleString());
},
showMessage(msgType, params) {
if (params == undefined) {
@ -423,6 +418,36 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/
}
;
} else if (msgType === 'S_MSG_BOX') {
let oParams = {
styleClass: params[msgType].STYLECLASS ? params[msgType].STYLECLASS : '',
title: params[msgType].TITLE ? params[msgType].TITLE : '',
onClose: params[msgType].ONCLOSE ? Function("sAction", "return " + params[msgType].ONCLOSE) : null,
actions: params[msgType].ACTIONS ? params[msgType].ACTIONS : 'OK',
emphasizedAction: params[msgType].EMPHASIZEDACTION ? params[msgType].EMPHASIZEDACTION : 'OK',
initialFocus: params[msgType].INITIALFOCUS ? params[msgType].INITIALFOCUS : null,
textDirection: params[msgType].TEXTDIRECTION ? params[msgType].TEXTDIRECTION : 'Inherit',
icon: params[msgType].ICON ? params[msgType].ICON : 'NONE',
details: params[msgType].DETAILS ? params[msgType].DETAILS : '',
closeOnNavigation: params[msgType].CLOSEONNAVIGATION ? true : false
};
if ( oParams.icon = 'None' ) { delete oParams.icon };
MessageBox[params[msgType].TYPE](params[msgType].TEXT, oParams);
return;
switch (params[msgType].TYPE) {
case 'error':
MessageBox.error(params[msgType].TEXT, oParams);
break;
case 'warning':
MessageBox.error(params[msgType].TEXT, oParams);
break;
default:
MessageBox.shwo(params[msgType].TEXT, oParams);
break;
}
return;
if (params[msgType].TYPE) {
MessageBox[params[msgType].TYPE](params[msgType].TEXT);
} else {
@ -465,4 +490,4 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/
this._oApp.insertPage(z2ui5.oView);
},
})
});
});

View File

@ -21,15 +21,15 @@ CLASS z2ui5_cl_app_view1_js IMPLEMENTATION.
result = `sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/model/json/JSONModel",` && |\n| &&
` "sap/ui/core/BusyIndicator", "sap/m/MessageBox", "sap/m/MessageToast", "sap/ui/core/Fragment", "sap/m/BusyDialog",` && |\n| &&
` "sap/ui/VersionInfo", "z2ui5/cc/Server",` && |\n| &&
` ],` && |\n| &&
` function(Controller, XMLView, JSONModel, BusyIndicator, MessageBox, MessageToast, Fragment, mBusyDialog, VersionInfo,` && |\n| &&
` Server ) {` && |\n| &&
`],` && |\n| &&
` function (Controller, XMLView, JSONModel, BusyIndicator, MessageBox, MessageToast, Fragment, mBusyDialog, VersionInfo,` && |\n| &&
` Server) {` && |\n| &&
` "use strict";` && |\n| &&
` return Controller.extend("z2ui5.controller.View1", {` && |\n| &&
`` && |\n| &&
` onInit (){` && |\n| &&
` onInit() {` && |\n| &&
`` && |\n| &&
` z2ui5.oRouter.attachRouteMatched(function(oEvent) {` && |\n| &&
` z2ui5.oRouter.attachRouteMatched(function (oEvent) {` && |\n| &&
` z2ui5.checkInit = true;` && |\n| &&
` Server.Roundtrip();` && |\n| &&
` }, this);` && |\n| &&
@ -37,7 +37,7 @@ CLASS z2ui5_cl_app_view1_js IMPLEMENTATION.
` },` && |\n| &&
` async onAfterRendering() {` && |\n| &&
`` && |\n| &&
` if (!z2ui5.oResponse){` && |\n| &&
` if (!z2ui5.oResponse) {` && |\n| &&
` return;` && |\n| &&
` }` && |\n| &&
`` && |\n| &&
@ -47,7 +47,7 @@ CLASS z2ui5_cl_app_view1_js IMPLEMENTATION.
` z2ui5.isBusy = false;` && |\n| &&
` return;` && |\n| &&
` }` && |\n| &&
` const {S_POPUP, S_VIEW_NEST, S_VIEW_NEST2, S_POPOVER} = z2ui5.oResponse.PARAMS;` && |\n| &&
` const { S_POPUP, S_VIEW_NEST, S_VIEW_NEST2, S_POPOVER } = z2ui5.oResponse.PARAMS;` && |\n| &&
` if (S_POPUP?.CHECK_DESTROY) {` && |\n| &&
` z2ui5.oController.PopupDestroy();` && |\n| &&
` }` && |\n| &&
@ -110,7 +110,7 @@ CLASS z2ui5_cl_app_view1_js IMPLEMENTATION.
` oFragment.open();` && |\n| &&
` },` && |\n| &&
` async displayPopover(xml, viewProp, openById) {` && |\n| &&
` sap.ui.require(["sap/ui/core/Element"], async function(Element) {` && |\n| &&
` sap.ui.require(["sap/ui/core/Element"], async function (Element) {` && |\n| &&
` const oFragment = await Fragment.load({` && |\n| &&
` definition: xml,` && |\n| &&
` controller: z2ui5.oControllerPopover,` && |\n| &&
@ -159,7 +159,7 @@ CLASS z2ui5_cl_app_view1_js IMPLEMENTATION.
` if (oParent) {` && |\n| &&
` try {` && |\n| &&
` oParent[z2ui5.oResponse.PARAMS[viewNestId].METHOD_DESTROY]();` && |\n| &&
` } catch {}` && |\n| &&
` } catch { }` && |\n| &&
` oParent[z2ui5.oResponse.PARAMS[viewNestId].METHOD_INSERT](oView);` && |\n| &&
` }` && |\n| &&
` z2ui5[viewProp] = oView;` && |\n| &&
@ -182,7 +182,7 @@ CLASS z2ui5_cl_app_view1_js IMPLEMENTATION.
` if (oParent) {` && |\n| &&
` try {` && |\n| &&
` oParent[z2ui5.oResponse.PARAMS[viewNestId].METHOD_DESTROY]();` && |\n| &&
` } catch {}` && |\n| &&
` } catch { }` && |\n| &&
` oParent[z2ui5.oResponse.PARAMS[viewNestId].METHOD_INSERT](oView);` && |\n| &&
` }` && |\n| &&
` z2ui5[viewProp] = oView;` && |\n| &&
@ -194,7 +194,7 @@ CLASS z2ui5_cl_app_view1_js IMPLEMENTATION.
` if (z2ui5.oViewPopup.close) {` && |\n| &&
` try {` && |\n| &&
` z2ui5.oViewPopup.close();` && |\n| &&
` } catch {}` && |\n| &&
` } catch { }` && |\n| &&
` }` && |\n| &&
` z2ui5.oViewPopup.destroy();` && |\n| &&
` },` && |\n| &&
@ -205,7 +205,7 @@ CLASS z2ui5_cl_app_view1_js IMPLEMENTATION.
` if (z2ui5.oViewPopover.close) {` && |\n| &&
` try {` && |\n| &&
` z2ui5.oViewPopover.close();` && |\n| &&
` } catch {}` && |\n| &&
` } catch { }` && |\n| &&
` }` && |\n| &&
` z2ui5.oViewPopover.destroy();` && |\n| &&
` },` && |\n| &&
@ -327,11 +327,6 @@ CLASS z2ui5_cl_app_view1_js IMPLEMENTATION.
` },` && |\n| &&
` eB(...args) {` && |\n| &&
`` && |\n| &&
` // var oRouter = sap.ui.core.UIComponent.getRouterFor(this);` && |\n| &&
` //debugger;` && |\n| &&
` // z2ui5.oRouter.navTo("RouteView2");` && |\n| &&
` // return;` && |\n| &&
`` && |\n| &&
` if (!window.navigator.onLine) {` && |\n| &&
` MessageBox.alert('No internet connection! Please reconnect to the server and try again.');` && |\n| &&
` return;` && |\n| &&
@ -340,7 +335,7 @@ CLASS z2ui5_cl_app_view1_js IMPLEMENTATION.
` if (!args[0][2]) {` && |\n| &&
` let oBusyDialog = new mBusyDialog();` && |\n| &&
` oBusyDialog.open();` && |\n| &&
` setTimeout( (oBusyDialog) => {` && |\n| &&
` setTimeout((oBusyDialog) => {` && |\n| &&
` oBusyDialog.close()` && |\n| &&
` }` && |\n| &&
` , 100, oBusyDialog);` && |\n| &&
@ -377,12 +372,12 @@ CLASS z2ui5_cl_app_view1_js IMPLEMENTATION.
` }` && |\n| &&
` }` && |\n| &&
` )` && |\n| &&
` if (args[0][1]) {` && |\n| &&
` z2ui5.oController.ViewDestroy();` && |\n| &&
` }` && |\n| &&
` // if (args[0][1]) {` && |\n| &&
` // z2ui5.oController.ViewDestroy();` && |\n| &&
` // }` && |\n| &&
` z2ui5.oBody.ID = z2ui5.oResponse.ID;` && |\n| &&
` z2ui5.oBody.ARGUMENTS = args;` && |\n| &&
` z2ui5.oBody.ARGUMENTS.forEach( (item, i) => {` && |\n| &&
` z2ui5.oBody.ARGUMENTS.forEach((item, i) => {` && |\n| &&
` if (i == 0) {` && |\n| &&
` return;` && |\n| &&
` }` && |\n| &&
@ -417,7 +412,7 @@ CLASS z2ui5_cl_app_view1_js IMPLEMENTATION.
` }` && |\n| &&
` ;` && |\n| &&
` }` && |\n| &&
` ;MessageBox.error(err.toLocaleString());` && |\n| &&
` ; MessageBox.error(err.toLocaleString());` && |\n| &&
` },` && |\n| &&
` showMessage(msgType, params) {` && |\n| &&
` if (params == undefined) {` && |\n| &&
@ -443,6 +438,36 @@ CLASS z2ui5_cl_app_view1_js IMPLEMENTATION.
` }` && |\n| &&
` ;` && |\n| &&
` } else if (msgType === 'S_MSG_BOX') {` && |\n| &&
`` && |\n| &&
` let oParams = {` && |\n| &&
` styleClass: params[msgType].STYLECLASS ? params[msgType].STYLECLASS : '',` && |\n| &&
` title: params[msgType].TITLE ? params[msgType].TITLE : '',` && |\n| &&
` onClose: params[msgType].ONCLOSE ? Function("sAction", "return " + params[msgType].ONCLOSE) : null,` && |\n| &&
` actions: params[msgType].ACTIONS ? params[msgType].ACTIONS : 'OK',` && |\n| &&
` emphasizedAction: params[msgType].EMPHASIZEDACTION ? params[msgType].EMPHASIZEDACTION : 'OK',` && |\n| &&
` initialFocus: params[msgType].INITIALFOCUS ? params[msgType].INITIALFOCUS : null,` && |\n| &&
` textDirection: params[msgType].TEXTDIRECTION ? params[msgType].TEXTDIRECTION : 'Inherit',` && |\n| &&
` icon: params[msgType].ICON ? params[msgType].ICON : 'NONE',` && |\n| &&
` details: params[msgType].DETAILS ? params[msgType].DETAILS : '',` && |\n| &&
` closeOnNavigation: params[msgType].CLOSEONNAVIGATION ? true : false` && |\n| &&
` };` && |\n| &&
` if ( oParams.icon = 'None' ) { delete oParams.icon };` && |\n| &&
` MessageBox[params[msgType].TYPE](params[msgType].TEXT, oParams);` && |\n| &&
` return;` && |\n| &&
`` && |\n| &&
` switch (params[msgType].TYPE) {` && |\n| &&
` case 'error':` && |\n| &&
` MessageBox.error(params[msgType].TEXT, oParams);` && |\n| &&
` break;` && |\n| &&
` case 'warning':` && |\n| &&
` MessageBox.error(params[msgType].TEXT, oParams);` && |\n| &&
` break;` && |\n| &&
` default:` && |\n| &&
` MessageBox.shwo(params[msgType].TEXT, oParams);` && |\n| &&
` break;` && |\n| &&
` }` && |\n| &&
` return;` && |\n| &&
`` && |\n| &&
` if (params[msgType].TYPE) {` && |\n| &&
` MessageBox[params[msgType].TYPE](params[msgType].TEXT);` && |\n| &&
` } else {` && |\n| &&
@ -485,7 +510,7 @@ CLASS z2ui5_cl_app_view1_js IMPLEMENTATION.
` this._oApp.insertPage(z2ui5.oView);` && |\n| &&
` },` && |\n| &&
` })` && |\n| &&
`});` && |\n| &&
` });` && |\n| &&
``.
ENDMETHOD.