Odata (#1611)
Some checks are pending
build_downport / build_downport (push) Waiting to run
build_frontend_classic / build_frontend_classic (push) Waiting to run
build_frontend_cloud / build_frontend_cloud (push) Waiting to run
js_transform / Code-Cleanup (push) Waiting to run
ui5lint / test (push) Waiting to run

* update

* update

* update
This commit is contained in:
oblomov-dev 2024-12-04 00:22:24 +01:00 committed by GitHub
parent 6c478d78f9
commit 33e4df3dac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 37 additions and 64 deletions

View File

@ -105,13 +105,15 @@ sap.ui.define(["sap/ui/core/BusyIndicator", "sap/m/MessageBox"
}
; if (z2ui5.oResponse.PARAMS?.S_FOLLOW_UP_ACTION?.CUSTOM_JS) {
setTimeout(() => {
let mParams = z2ui5.oResponse?.PARAMS.S_FOLLOW_UP_ACTION.CUSTOM_JS.split("'");
for ( let i = 0; i < z2ui5.oResponse?.PARAMS.S_FOLLOW_UP_ACTION.CUSTOM_JS.length ; i++ ){
let mParams = z2ui5.oResponse?.PARAMS.S_FOLLOW_UP_ACTION.CUSTOM_JS[i].split("'");
let mParamsEF = mParams.filter((val, index) => index % 2)
if (mParamsEF.length) {
z2ui5.oController.eF.apply(undefined, mParamsEF);
} else {
Function("return " + mParams[0])();
}
}
}, 100);
};
z2ui5.oController.showMessage('S_MSG_TOAST', z2ui5.oResponse.PARAMS);

View File

@ -12,7 +12,7 @@ sap.ui.define(["sap/ui/core/mvc/Controller",
};
z2ui5.oController = new Controller();
z2ui5.oController.setApp(this.getView().byId("app"));
z2ui5.oApp = this.getView().byId("app");
z2ui5.oControllerNest = new Controller();
z2ui5.oControllerNest2 = new Controller();

View File

@ -1,9 +1,9 @@
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",
"sap/ui/VersionInfo", "z2ui5/cc/Server", "sap/ui/model/odata/v2/ODataModel",
],
function (Controller, XMLView, JSONModel, BusyIndicator, MessageBox, MessageToast, Fragment, mBusyDialog, VersionInfo,
Server) {
Server, ODataModel) {
"use strict";
return Controller.extend("z2ui5.controller.View1", {
@ -242,12 +242,12 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/
}
break;
case 'SET_ODATA_MODEL':
sap.ui.require([
"sap/ui/model/odata/v2/ODataModel"
], async (ODataModel) => {
// sap.ui.require([
// "sap/ui/model/odata/v2/ODataModel"
// ], async (ODataModel) => {
var oModel = new ODataModel({ serviceUrl : args[1] });
z2ui5.oView.setModel( oModel , args[2] );
});
// });
break;
case 'DOWNLOAD_B64_FILE':
var a = document.createElement("a");
@ -455,14 +455,12 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/
}
}
},
setApp(oApp) {
this._oApp = oApp;
},
async displayView(xml, viewModel) {
let oview_model = new JSONModel(viewModel);
var oModel = oview_model;
if (z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL){
oModel = z2ui5.oOwnerComponent.getModel(z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL);
oModel = new ODataModel({ serviceUrl : z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL });
// oModel = z2ui5.oOwnerComponent.getModel(z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL);
}
z2ui5.oView = await XMLView.create({
definition: xml,
@ -481,8 +479,8 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/
if (z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL){
z2ui5.oView.setModel(oview_model, "http");
}
this._oApp.removeAllPages();
this._oApp.insertPage(z2ui5.oView);
z2ui5.oApp.removeAllPages();
z2ui5.oApp.insertPage(z2ui5.oView);
},
})
});

View File

@ -15,15 +15,6 @@
"toolsId": "3a966e20-9635-4c28-8861-d1b66f79f1de"
},
"dataSources": {
"test": {
"uri": "/sap/opu/odata/DMO/API_TRAVEL_U_V2/",
"type": "OData",
"settings": {
"annotations": [],
"localUri": "localService/metadata.xml",
"odataVersion": "2.0"
}
},
"http": {
"uri": "/sap/bc/z2ui5",
"type": "OData",
@ -83,11 +74,6 @@
}
},
"models": {
"test": {
"dataSource": "test",
"preload": true,
"settings": {}
},
"http": {
"dataSource": "http",
"preload": true,

View File

@ -91,8 +91,9 @@ CLASS z2ui5_cl_core_action IMPLEMENTATION.
CATCH cx_root INTO DATA(x).
RAISE EXCEPTION TYPE z2ui5_cx_util_error
EXPORTING val = |App with name { mo_http_post->ms_request-s_control-app_start } not found...|
previous = x.
EXPORTING
val = |App with name { mo_http_post->ms_request-s_control-app_start } not found...|
previous = x.
ENDTRY.
ENDMETHOD.
@ -166,10 +167,9 @@ CLASS z2ui5_cl_core_action IMPLEMENTATION.
result->ms_next-s_set-s_popover-check_update_model = abap_false.
IF ms_next-s_set-s_follow_up_action IS NOT INITIAL.
" .eB(['POPUP_CONFIRM'])
" TODO: variable is assigned but never used (ABAP cleaner)
SPLIT ms_next-s_set-s_follow_up_action-custom_js AT `.eB(['` INTO DATA(lv_dummy)
result->ms_actual-event.
DATA(lv_action) = ms_next-s_set-s_follow_up_action-custom_js[ 1 ].
SPLIT lv_action AT `.eB(['` INTO DATA(lv_dummy)
result->ms_actual-event.
SPLIT result->ms_actual-event AT `']` INTO result->ms_actual-event lv_dummy.
ENDIF.
result->ms_actual-r_data = ms_next-r_data.

View File

@ -27,7 +27,8 @@ CLASS z2ui5_cl_core_client IMPLEMENTATION.
METHOD z2ui5_if_client~follow_up_action.
mo_action->ms_next-s_set-s_follow_up_action-custom_js = val.
* mo_action->ms_next-s_set-s_follow_up_action-custom_js = val.
insert val into table mo_action->ms_next-s_set-s_follow_up_action-custom_js.
ENDMETHOD.

View File

@ -132,7 +132,7 @@ INTERFACE z2ui5_if_core_types
closeonbrowsernavigation TYPE string,
END OF s_msg_toast,
BEGIN OF s_follow_up_action,
custom_js TYPE string,
custom_js TYPE string_table,
END OF s_follow_up_action,
* handler_attrs TYPE ty_s_http_handler_attributes,
s_stateful TYPE ty_s_http_res-s_stateful,

View File

@ -32,7 +32,7 @@ CLASS z2ui5_cl_app_app_js IMPLEMENTATION.
` };` && |\n| &&
`` && |\n| &&
` z2ui5.oController = new Controller();` && |\n| &&
` z2ui5.oController.setApp(this.getView().byId("app"));` && |\n| &&
` z2ui5.oApp = this.getView().byId("app");` && |\n| &&
`` && |\n| &&
` z2ui5.oControllerNest = new Controller();` && |\n| &&
` z2ui5.oControllerNest2 = new Controller();` && |\n| &&

View File

@ -35,15 +35,6 @@ CLASS z2ui5_cl_app_manifest_json IMPLEMENTATION.
` "toolsId": "3a966e20-9635-4c28-8861-d1b66f79f1de"` &&
` },` &&
` "dataSources": {` &&
` "test": {` &&
` "uri": "/sap/opu/odata/DMO/API_TRAVEL_U_V2/",` &&
` "type": "OData",` &&
` "settings": {` &&
` "annotations": [],` &&
` "localUri": "localService/metadata.xml",` &&
` "odataVersion": "2.0"` &&
` }` &&
` },` &&
` "http": {` &&
` "uri": "/sap/bc/z2ui5",` &&
` "type": "OData",` &&
@ -103,11 +94,6 @@ CLASS z2ui5_cl_app_manifest_json IMPLEMENTATION.
` }` &&
` },` &&
` "models": {` &&
` "test": {` &&
` "dataSource": "test",` &&
` "preload": true,` &&
` "settings": {}` &&
` },` &&
` "http": {` &&
` "dataSource": "http",` &&
` "preload": true,` &&

View File

@ -125,13 +125,15 @@ CLASS z2ui5_cl_app_server_js IMPLEMENTATION.
` }` && |\n| &&
` ; if (z2ui5.oResponse.PARAMS?.S_FOLLOW_UP_ACTION?.CUSTOM_JS) {` && |\n| &&
` setTimeout(() => {` && |\n| &&
` let mParams = z2ui5.oResponse?.PARAMS.S_FOLLOW_UP_ACTION.CUSTOM_JS.split("'");` && |\n| &&
` for ( let i = 0; i < z2ui5.oResponse?.PARAMS.S_FOLLOW_UP_ACTION.CUSTOM_JS.length ; i++ ){` && |\n| &&
` let mParams = z2ui5.oResponse?.PARAMS.S_FOLLOW_UP_ACTION.CUSTOM_JS[i].split("'");` && |\n| &&
` let mParamsEF = mParams.filter((val, index) => index % 2)` && |\n| &&
` if (mParamsEF.length) {` && |\n| &&
` z2ui5.oController.eF.apply(undefined, mParamsEF);` && |\n| &&
` } else {` && |\n| &&
` Function("return " + mParams[0])();` && |\n| &&
` }` && |\n| &&
` }` && |\n| &&
` }, 100);` && |\n| &&
` };` && |\n| &&
` z2ui5.oController.showMessage('S_MSG_TOAST', z2ui5.oResponse.PARAMS);` && |\n| &&

View File

@ -20,10 +20,10 @@ 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| &&
` "sap/ui/VersionInfo", "z2ui5/cc/Server", "sap/ui/model/odata/v2/ODataModel",` && |\n| &&
`],` && |\n| &&
` function (Controller, XMLView, JSONModel, BusyIndicator, MessageBox, MessageToast, Fragment, mBusyDialog, VersionInfo,` && |\n| &&
` Server) {` && |\n| &&
` Server, ODataModel) {` && |\n| &&
` "use strict";` && |\n| &&
` return Controller.extend("z2ui5.controller.View1", {` && |\n| &&
`` && |\n| &&
@ -262,12 +262,12 @@ CLASS z2ui5_cl_app_view1_js IMPLEMENTATION.
` }` && |\n| &&
` break;` && |\n| &&
` case 'SET_ODATA_MODEL':` && |\n| &&
` sap.ui.require([` && |\n| &&
` "sap/ui/model/odata/v2/ODataModel"` && |\n| &&
` ], async (ODataModel) => {` && |\n| &&
` // sap.ui.require([` && |\n| &&
` // "sap/ui/model/odata/v2/ODataModel"` && |\n| &&
` // ], async (ODataModel) => {` && |\n| &&
` var oModel = new ODataModel({ serviceUrl : args[1] });` && |\n| &&
` z2ui5.oView.setModel( oModel , args[2] );` && |\n| &&
` });` && |\n| &&
` // });` && |\n| &&
` break;` && |\n| &&
` case 'DOWNLOAD_B64_FILE':` && |\n| &&
` var a = document.createElement("a");` && |\n| &&
@ -475,14 +475,12 @@ CLASS z2ui5_cl_app_view1_js IMPLEMENTATION.
` }` && |\n| &&
` }` && |\n| &&
` },` && |\n| &&
` setApp(oApp) {` && |\n| &&
` this._oApp = oApp;` && |\n| &&
` },` && |\n| &&
` async displayView(xml, viewModel) {` && |\n| &&
` let oview_model = new JSONModel(viewModel);` && |\n| &&
` var oModel = oview_model;` && |\n| &&
` if (z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL){` && |\n| &&
` oModel = z2ui5.oOwnerComponent.getModel(z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL);` && |\n| &&
` oModel = new ODataModel({ serviceUrl : z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL });` && |\n| &&
` // oModel = z2ui5.oOwnerComponent.getModel(z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL);` && |\n| &&
` }` && |\n| &&
` z2ui5.oView = await XMLView.create({` && |\n| &&
` definition: xml,` && |\n| &&
@ -501,8 +499,8 @@ CLASS z2ui5_cl_app_view1_js IMPLEMENTATION.
` if (z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL){` && |\n| &&
` z2ui5.oView.setModel(oview_model, "http");` && |\n| &&
` }` && |\n| &&
` this._oApp.removeAllPages();` && |\n| &&
` this._oApp.insertPage(z2ui5.oView);` && |\n| &&
` z2ui5.oApp.removeAllPages();` && |\n| &&
` z2ui5.oApp.insertPage(z2ui5.oView);` && |\n| &&
` },` && |\n| &&
` })` && |\n| &&
` });` && |\n| &&