Skip to content

Commit 7f500ce

Browse files
1 parent 4038e09 commit 7f500ce

File tree

3 files changed

+40
-42
lines changed

3 files changed

+40
-42
lines changed

app/webapp/controller/App.controller.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ sap.ui.define(["sap/ui/core/mvc/Controller",
55

66
onInit: async function () {
77

8-
z2ui5.oConfig.pathname = this.getView().getModel().sServiceUrl;
8+
z2ui5.oModel2 = this.getView().getModel("");
9+
z2ui5.oConfig.pathname = this.getView().getModel("http").sServiceUrl;
910
if (z2ui5?.checkLocal == true ) {
1011
z2ui5.oConfig.pathname = window.location.href;
1112
};

app/webapp/controller/View1.controller.js

Lines changed: 24 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,14 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/
241241
break;
242242
}
243243
break;
244+
case 'SET_ODATA_MODEL':
245+
sap.ui.require([
246+
"sap/ui/model/odata/v2/ODataModel"
247+
], async (ODataModel) => {
248+
var oModel = new ODataModel({ serviceUrl : args[1] });
249+
z2ui5.oView.setModel( oModel , args[2] );
250+
});
251+
break;
244252
case 'DOWNLOAD_B64_FILE':
245253
var a = document.createElement("a");
246254
a.href = args[1];
@@ -337,11 +345,13 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/
337345
z2ui5.isBusy = true;
338346
BusyIndicator.show();
339347
z2ui5.oBody = {};
340-
if (args[0][3]) {
341-
z2ui5.oBody.XX = z2ui5.oView.getModel().getData().XX;
342-
z2ui5.oBody.VIEWNAME = 'MAIN';
343-
} else if (z2ui5.oController == this) {
344-
z2ui5.oBody.XX = z2ui5.oView.getModel().getData().XX;
348+
if (args[0][3] || z2ui5.oController == this ) {
349+
if (z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL == true ){
350+
var oModel = z2ui5.oView.getModel( "http");
351+
}else{
352+
oModel = z2ui5.oView.getModel();
353+
}
354+
z2ui5.oBody.XX = oModel.getData().XX;
345355
z2ui5.oBody.VIEWNAME = 'MAIN';
346356
} else if (z2ui5.oControllerPopup == this) {
347357
if (z2ui5.oViewPopup) {
@@ -364,9 +374,6 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/
364374
}
365375
}
366376
)
367-
// if (args[0][1]) {
368-
// z2ui5.oController.ViewDestroy();
369-
// }
370377
z2ui5.oBody.ID = z2ui5.oResponse.ID;
371378
z2ui5.oBody.ARGUMENTS = args;
372379
z2ui5.oBody.ARGUMENTS.forEach((item, i) => {
@@ -445,48 +452,21 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/
445452
};
446453
if ( oParams.icon = 'None' ) { delete oParams.icon };
447454
MessageBox[params[msgType].TYPE](params[msgType].TEXT, oParams);
448-
return;
449-
450-
switch (params[msgType].TYPE) {
451-
case 'error':
452-
MessageBox.error(params[msgType].TEXT, oParams);
453-
break;
454-
case 'warning':
455-
MessageBox.error(params[msgType].TEXT, oParams);
456-
break;
457-
default:
458-
MessageBox.shwo(params[msgType].TEXT, oParams);
459-
break;
460-
}
461-
return;
462-
463-
if (params[msgType].TYPE) {
464-
MessageBox[params[msgType].TYPE](params[msgType].TEXT);
465-
} else {
466-
MessageBox.show(params[msgType].TEXT, {
467-
styleClass: params[msgType].STYLECLASS ? params[msgType].STYLECLASS : '',
468-
title: params[msgType].TITLE ? params[msgType].TITLE : '',
469-
onClose: params[msgType].ONCLOSE ? Function("sAction", "return " + params[msgType].ONCLOSE) : null,
470-
actions: params[msgType].ACTIONS ? params[msgType].ACTIONS : 'OK',
471-
emphasizedAction: params[msgType].EMPHASIZEDACTION ? params[msgType].EMPHASIZEDACTION : 'OK',
472-
initialFocus: params[msgType].INITIALFOCUS ? params[msgType].INITIALFOCUS : null,
473-
textDirection: params[msgType].TEXTDIRECTION ? params[msgType].TEXTDIRECTION : 'Inherit',
474-
icon: params[msgType].ICON ? params[msgType].ICON : 'NONE',
475-
details: params[msgType].DETAILS ? params[msgType].DETAILS : '',
476-
closeOnNavigation: params[msgType].CLOSEONNAVIGATION ? true : false
477-
})
478455
}
479-
}
480456
}
481457
},
482458
setApp(oApp) {
483459
this._oApp = oApp;
484460
},
485461
async displayView(xml, viewModel) {
486-
let oview_model = new JSONModel(viewModel);
462+
let oview_model = new JSONModel(viewModel);
463+
var oModel = oview_model;
464+
if (z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL == true){
465+
oModel = z2ui5.oModel2;
466+
}
487467
z2ui5.oView = await XMLView.create({
488468
definition: xml,
489-
models: oview_model,
469+
models: oModel,
490470
controller: z2ui5.oController,
491471
id: 'mainView',
492472
preprocessors: {
@@ -498,6 +478,9 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/
498478
}
499479
});
500480
z2ui5.oView.setModel(z2ui5.oDeviceModel, "device");
481+
if (z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL == true){
482+
z2ui5.oView.setModel(oview_model, "http");
483+
}
501484
this._oApp.removeAllPages();
502485
this._oApp.insertPage(z2ui5.oView);
503486
},

app/webapp/manifest.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@
1616
},
1717
"dataSources": {
1818
"mainService": {
19+
"uri": "/sap/opu/odata/DMO/API_TRAVEL_U_V2/",
20+
"type": "OData",
21+
"settings": {
22+
"annotations": [],
23+
"localUri": "localService/metadata.xml",
24+
"odataVersion": "2.0"
25+
}
26+
},
27+
"http": {
1928
"uri": "/sap/bc/z2ui5",
2029
"type": "OData",
2130
"settings": {
@@ -78,6 +87,11 @@
7887
"dataSource": "mainService",
7988
"preload": true,
8089
"settings": {}
90+
},
91+
"http": {
92+
"dataSource": "http",
93+
"preload": true,
94+
"settings": {}
8195
}
8296
},
8397
"resources": {

0 commit comments

Comments
 (0)