From 8304f4e857605fe81413cf7dc4e9bf5cc28d10f3 Mon Sep 17 00:00:00 2001 From: oblomov-dev Date: Sun, 29 Dec 2024 01:51:21 +0000 Subject: [PATCH] [create-pull-request] automated change --- src/01/02/z2ui6_cl_core_srv_json.clas.abap | 25 +++++-- src/01/02/z2ui6_if_core_types.intf.abap | 2 +- src/01/03/z2ui6_cl_app_app_js.clas.abap | 19 ++++-- src/01/03/z2ui6_cl_app_component_js.clas.abap | 17 ++--- src/01/03/z2ui6_cl_app_server_js.clas.abap | 8 +-- src/01/03/z2ui6_cl_app_view1_js.clas.abap | 65 +++++++++++++++---- src/02/01/z2ui6_cl_pop_input_val.clas.abap | 5 +- src/02/z2ui6_if_client.intf.abap | 3 +- 8 files changed, 103 insertions(+), 41 deletions(-) diff --git a/src/01/02/z2ui6_cl_core_srv_json.clas.abap b/src/01/02/z2ui6_cl_core_srv_json.clas.abap index 5587a0c2..2595e3dc 100644 --- a/src/01/02/z2ui6_cl_core_srv_json.clas.abap +++ b/src/01/02/z2ui6_cl_core_srv_json.clas.abap @@ -36,7 +36,10 @@ CLASS z2ui6_cl_core_srv_json DEFINITION ENDCLASS. + CLASS z2ui6_cl_core_srv_json IMPLEMENTATION. + + METHOD model_front_to_back. IF line_exists( t_attri->*[ view = view ] ). @@ -77,6 +80,7 @@ CLASS z2ui6_cl_core_srv_json IMPLEMENTATION. ENDMETHOD. + METHOD model_back_to_front. TRY. @@ -129,6 +133,7 @@ CLASS z2ui6_cl_core_srv_json IMPLEMENTATION. ENDTRY. ENDMETHOD. + METHOD request_json_to_abap. TRY. @@ -163,10 +168,20 @@ CLASS z2ui6_cl_core_srv_json IMPLEMENTATION. CATCH cx_root. ENDTRY. - result-s_control-app_start_draft = z2ui6_cl_util=>c_trim_upper( - z2ui6_cl_util=>url_param_get( val = `z2ui5-xapp-state` - url = result-s_front-search ) ). - + try. + " result-s_control-app_start_draft = z2ui5_cl_util=>c_trim_upper( + " z2ui5_cl_util=>url_param_get( val = `z2ui5-xapp-state` + " url = result-s_front-search ) ). + data(lv_hash) = result-s_front-hash. + split lv_hash at '&/' into data(lv_dummy) lv_hash. + if lv_hash is initial. + lv_hash = result-s_front-hash+2. + endif. + result-s_control-app_start_draft = z2ui6_cl_util=>c_trim_upper( + z2ui6_cl_util=>url_param_get( val = `z2ui5-xapp-state` + url = lv_hash ) ). + catch cx_root. + endtry. IF result-s_control-app_start IS NOT INITIAL. IF result-s_control-app_start(1) = `-`. REPLACE FIRST OCCURRENCE OF `-` IN result-s_control-app_start WITH `/`. @@ -187,6 +202,7 @@ CLASS z2ui6_cl_core_srv_json IMPLEMENTATION. ENDTRY. ENDMETHOD. + METHOD response_abap_to_json. TRY. @@ -208,6 +224,7 @@ CLASS z2ui6_cl_core_srv_json IMPLEMENTATION. ENDTRY. ENDMETHOD. + METHOD z2ui6_if_ajson_filter~keep_node. rv_keep = abap_true. diff --git a/src/01/02/z2ui6_if_core_types.intf.abap b/src/01/02/z2ui6_if_core_types.intf.abap index 93f39476..f957f349 100644 --- a/src/01/02/z2ui6_if_core_types.intf.abap +++ b/src/01/02/z2ui6_if_core_types.intf.abap @@ -137,7 +137,7 @@ INTERFACE z2ui6_if_core_types END OF s_follow_up_action, * handler_attrs TYPE ty_s_http_handler_attributes, set_app_state_active TYPE abap_bool, - set_push_state TYPE abap_bool, + set_push_state TYPE string, set_nav_back TYPE abap_bool, s_stateful TYPE ty_s_http_res-s_stateful, END OF ty_s_next_frontend. diff --git a/src/01/03/z2ui6_cl_app_app_js.clas.abap b/src/01/03/z2ui6_cl_app_app_js.clas.abap index 00853676..18f84982 100644 --- a/src/01/03/z2ui6_cl_app_app_js.clas.abap +++ b/src/01/03/z2ui6_cl_app_app_js.clas.abap @@ -20,7 +20,9 @@ CLASS z2ui6_cl_app_app_js IMPLEMENTATION. result = `sap.ui.define(["sap/ui/core/mvc/Controller",` && |\n| && ` "z2ui5/controller/View1.controller",` && |\n| && - `], function (BaseController, Controller) {` && |\n| && + ` "z2ui5/cc/Server",` && |\n| && + ` "sap/ui/core/routing/HashChanger"` && |\n| && + `], function (BaseController, Controller, Server, HashChanger) {` && |\n| && ` return BaseController.extend("z2ui5.controller.App", {` && |\n| && `` && |\n| && ` onInit() {` && |\n| && @@ -46,6 +48,12 @@ CLASS z2ui6_cl_app_app_js IMPLEMENTATION. `` && |\n| && ` z2ui5.checkNestAfter = false;` && |\n| && `` && |\n| && + ` // if (sap.ui.core.routing.HashChanger.getInstance().getHash().includes("z2ui5-xapp-state")){` && |\n| && + ` if (HashChanger.getInstance().getHash()){` && |\n| && + ` z2ui5.checkInit = true;` && |\n| && + ` Server.Roundtrip();` && |\n| && + ` }` && |\n| && + `` && |\n| && ` }` && |\n| && ` });` && |\n| && `});` && |\n| && @@ -510,6 +518,8 @@ CLASS z2ui6_cl_app_app_js IMPLEMENTATION. ` defaultValue: "Upload"` && |\n| && ` },` && |\n| && ` enabled: {` && |\n| && + |\n|. + result = result && ` type: "boolean",` && |\n| && ` defaultValue: true` && |\n| && ` },` && |\n| && @@ -518,8 +528,6 @@ CLASS z2ui6_cl_app_app_js IMPLEMENTATION. ` defaultValue: "sap-icon://browse-folder"` && |\n| && ` },` && |\n| && ` iconOnly: {` && |\n| && - |\n|. - result = result && ` type: "boolean",` && |\n| && ` defaultValue: false` && |\n| && ` },` && |\n| && @@ -1012,6 +1020,8 @@ CLASS z2ui6_cl_app_app_js IMPLEMENTATION. ` DateCreateObject: (s) => new Date(s),` && |\n| && ` // DateAbapTimestampToDate: (sTimestamp) => new sap.gantt.misc.Format.abapTimestampToDate(sTimestamp), commented for UI5 2.x compatibility` && |\n| && ` DateAbapDateToDateObject: (d) => new Date(d.slice(0, 4), parseInt(d.slice(4, 6)) - 1, d.slice(6, 8)),` && |\n| && + |\n|. + result = result && ` DateAbapDateTimeToDateObject: (d, t = '000000') => new Date(d.slice(0, 4), parseInt(d.slice(4, 6)) - 1, d.slice(6, 8), t.slice(0, 2), t.slice(2, 4), t.slice(4, 6)),` && |\n| && ` };` && |\n| && `}` && |\n| && @@ -1020,8 +1030,6 @@ CLASS z2ui6_cl_app_app_js IMPLEMENTATION. ` z2ui5.Util = Util;` && |\n| && `}` && |\n| && `);` && |\n| && - |\n|. - result = result && `` && |\n| && `sap.ui.define("z2ui5/Favicon", ["sap/ui/core/Control"], (Control) => {` && |\n| && ` "use strict";` && |\n| && @@ -1071,7 +1079,6 @@ CLASS z2ui6_cl_app_app_js IMPLEMENTATION. ` });` && |\n| && `}` && |\n| && `);` && |\n| && - `` && |\n| && ``. ENDMETHOD. diff --git a/src/01/03/z2ui6_cl_app_component_js.clas.abap b/src/01/03/z2ui6_cl_app_component_js.clas.abap index ce643d02..45310f2b 100644 --- a/src/01/03/z2ui6_cl_app_component_js.clas.abap +++ b/src/01/03/z2ui6_cl_app_component_js.clas.abap @@ -22,7 +22,10 @@ CLASS z2ui6_cl_app_component_js IMPLEMENTATION. `], function (UIComponent, Models, Server, VersionInfo, DebugTool) {` && |\n| && ` return UIComponent.extend("z2ui5.Component", {` && |\n| && ` metadata: {` && |\n| && - ` manifest: "json"` && |\n| && + ` manifest: "json",` && |\n| && + ` interfaces: [` && |\n| && + ` "sap.ui.core.IAsyncContentCreation"` && |\n| && + ` ]` && |\n| && ` },` && |\n| && ` async init() {` && |\n| && ` UIComponent.prototype.init.apply(this, arguments);` && |\n| && @@ -30,8 +33,12 @@ CLASS z2ui6_cl_app_component_js IMPLEMENTATION. ` if (typeof z2ui5 == 'undefined') {` && |\n| && ` z2ui5 = {};` && |\n| && ` }` && |\n| && - ` this.getRouter().initialize();` && |\n| && + ` z2ui5 = {};` && |\n| && + `` && |\n| && ` z2ui5.oRouter = this.getRouter();` && |\n| && + ` z2ui5.oRouter.initialize();` && |\n| && + ` z2ui5.oRouter.stop();` && |\n| && + `` && |\n| && ` z2ui5.oDeviceModel = Models.createDeviceModel();` && |\n| && ` this.setModel(z2ui5.oDeviceModel, "device");` && |\n| && `` && |\n| && @@ -64,7 +71,6 @@ CLASS z2ui6_cl_app_component_js IMPLEMENTATION. ` }` && |\n| && ` });` && |\n| && `` && |\n| && - ` // Handle forward/back buttons` && |\n| && ` window.addEventListener("popstate", (event) => {` && |\n| && ` delete event?.state?.response?.PARAMS?.SET_PUSH_STATE;` && |\n| && ` delete event?.state?.response?.PARAMS?.SET_APP_STATE_ACTIVE;` && |\n| && @@ -72,10 +78,6 @@ CLASS z2ui6_cl_app_component_js IMPLEMENTATION. ` z2ui5.oController.ViewDestroy();` && |\n| && ` z2ui5.oResponse = event.state.response;` && |\n| && ` z2ui5.oController.displayView(event.state.view, event.state.model);` && |\n| && - ` }else{` && |\n| && - ` let urlObj = new URL(window.location.href);` && |\n| && - ` urlObj.searchParams.delete("z2ui5-xapp-state");` && |\n| && - ` history.replaceState(null, null, urlObj.pathname + urlObj.search + urlObj.hash);` && |\n| && ` }` && |\n| && ` });` && |\n| && ` },` && |\n| && @@ -96,7 +98,6 @@ CLASS z2ui6_cl_app_component_js IMPLEMENTATION. ` },` && |\n| && ` });` && |\n| && `});` && |\n| && - `` && |\n| && ``. ENDMETHOD. diff --git a/src/01/03/z2ui6_cl_app_server_js.clas.abap b/src/01/03/z2ui6_cl_app_server_js.clas.abap index a50d64a0..806dac31 100644 --- a/src/01/03/z2ui6_cl_app_server_js.clas.abap +++ b/src/01/03/z2ui6_cl_app_server_js.clas.abap @@ -51,10 +51,10 @@ CLASS z2ui6_cl_app_server_js IMPLEMENTATION. ` }` && |\n| && ` };` && |\n| && `` && |\n| && - ` try{` && |\n| && - ` let oState = JSON.parse(JSON.stringify({ view: z2ui5.oView.mProperties.viewContent, model: z2ui5.oView.getModel().getData(), response: z2ui5.oResponse }));` && |\n| && - ` history.replaceState(oState, "", window.location.href );` && |\n| && - ` }catch(e){}` && |\n| && + ` // try{` && |\n| && + ` // let oState = JSON.parse(JSON.stringify({ view: z2ui5.oView.mProperties.viewContent, model: z2ui5.oView.getModel().getData(), response: z2ui5.oResponse }));` && |\n| && + ` // history.replaceState(oState, "", window.location.href );` && |\n| && + ` // }catch(e){}` && |\n| && `` && |\n| && ` z2ui5.oBody ??= {};` && |\n| && ` z2ui5.oBody.S_FRONT = {` && |\n| && diff --git a/src/01/03/z2ui6_cl_app_view1_js.clas.abap b/src/01/03/z2ui6_cl_app_view1_js.clas.abap index 2ea3d352..f775b398 100644 --- a/src/01/03/z2ui6_cl_app_view1_js.clas.abap +++ b/src/01/03/z2ui6_cl_app_view1_js.clas.abap @@ -20,10 +20,10 @@ CLASS z2ui6_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", "sap/ui/model/odata/v2/ODataModel", "sap/m/library"` && |\n| && + ` "sap/ui/VersionInfo", "z2ui5/cc/Server", "sap/ui/model/odata/v2/ODataModel", "sap/m/library", "sap/ui/core/routing/HashChanger"` && |\n| && `],` && |\n| && ` function (Controller, XMLView, JSONModel, BusyIndicator, MessageBox, MessageToast, Fragment, mBusyDialog, VersionInfo,` && |\n| && - ` Server, ODataModel, mobileLibrary) {` && |\n| && + ` Server, ODataModel, mobileLibrary, HashChanger) {` && |\n| && ` "use strict";` && |\n| && ` return Controller.extend("z2ui5.controller.View1", {` && |\n| && `` && |\n| && @@ -77,20 +77,31 @@ CLASS z2ui6_cl_app_view1_js IMPLEMENTATION. ` }` && |\n| && `` && |\n| && ` let oState = JSON.parse(JSON.stringify({ view: z2ui5.oView.mProperties.viewContent, model: z2ui5.oView.getModel().getData(), response: z2ui5.oResponse }));` && |\n| && - ` if (SET_PUSH_STATE) {` && |\n| && - ` history.pushState(oState, "", window.location.href );` && |\n| && - ` }else{` && |\n| && + ` if (SET_PUSH_STATE) {` && |\n| && + ` // sap.ui.core.routing.HashChanger.getInstance().setHash("423143124");` && |\n| && + ` // sap.ui.core.routing.HashChanger.getInstance().replaceHash("423143124");` && |\n| && + ` //history.go(-1);` && |\n| && + ` let urlObj = new URL(window.location.href);` && |\n| && + ` let hash = HashChanger.getInstance().getHash();` && |\n| && + ` if (!hash){` && |\n| && + ` hash = '#';` && |\n| && + ` }` && |\n| && + ` history.pushState(oState, "", urlObj.pathname + urlObj.search + hash + SET_PUSH_STATE);` && |\n| && + ` }else{` && |\n| && + ` // debugger;` && |\n| && ` history.replaceState(oState, "", window.location.href );` && |\n| && ` }` && |\n| && `` && |\n| && ` if (SET_APP_STATE_ACTIVE) {` && |\n| && - ` let urlObj = new URL(window.location.href);` && |\n| && - ` urlObj.searchParams.set("z2ui5-xapp-state", z2ui5.oResponse.ID);` && |\n| && - ` history.replaceState(oState, null, urlObj.pathname + urlObj.search + urlObj.hash);` && |\n| && + ` HashChanger.getInstance().replaceHash("z2ui5-xapp-state=" + z2ui5.oResponse.ID );` && |\n| && + ` // let urlObj = new URL(window.location.href);` && |\n| && + ` // urlObj.searchParams.set("z2ui5-xapp-state", z2ui5.oResponse.ID);` && |\n| && + ` // history.replaceState(oState, null, urlObj.pathname + urlObj.search + urlObj.hash);` && |\n| && ` } else {` && |\n| && - ` let urlObj = new URL(window.location.href);` && |\n| && - ` urlObj.searchParams.delete("z2ui5-xapp-state");` && |\n| && - ` history.replaceState(oState, null, urlObj.pathname + urlObj.search + urlObj.hash);` && |\n| && + ` HashChanger.getInstance().replaceHash("");` && |\n| && + ` // let urlObj = new URL(window.location.href);` && |\n| && + ` // urlObj.searchParams.delete("z2ui5-xapp-state");` && |\n| && + ` // history.replaceState(oState, null, urlObj.pathname + urlObj.search + urlObj.hash);` && |\n| && ` }` && |\n| && `` && |\n| && `` && |\n| && @@ -288,6 +299,33 @@ CLASS z2ui6_cl_app_view1_js IMPLEMENTATION. ` case 'HISTORY_BACK':` && |\n| && ` history.back();` && |\n| && ` break;` && |\n| && + ` case 'CLIPBOARD_APP_STATE':` && |\n| && + ` function copyToClipboard(textToCopy) {` && |\n| && + ` if (navigator.clipboard && typeof navigator.clipboard.writeText === "function") {` && |\n| && + ` navigator.clipboard.writeText(textToCopy)` && |\n| && + ` .then(() => {` && |\n| && + `` && |\n| && + ` })` && |\n| && + ` .catch(err => {` && |\n| && + `` && |\n| && + ` });` && |\n| && + ` } else {` && |\n| && + ` const tempTextArea = document.createElement("textarea");` && |\n| && + ` tempTextArea.value = textToCopy;` && |\n| && + ` document.body.appendChild(tempTextArea);` && |\n| && + `` && |\n| && + ` tempTextArea.select();` && |\n| && + ` try {` && |\n| && + ` document.execCommand("copy");` && |\n| && + `` && |\n| && + ` } catch (err) {` && |\n| && + `` && |\n| && + ` }` && |\n| && + ` document.body.removeChild(tempTextArea);` && |\n| && + ` }` && |\n| && + ` }` && |\n| && + ` copyToClipboard(window.location.href + '#/z2ui5-xapp-state=' + z2ui5.oResponse.ID );` && |\n| && + ` break;` && |\n| && ` case 'SET_ODATA_MODEL':` && |\n| && ` var oModel = new ODataModel({ serviceUrl: args[1], annotationURI: (args.length > 3 ? args[3] : '') });` && |\n| && ` z2ui5.oView.setModel(oModel, args[2] ? args[2] : undefined);` && |\n| && @@ -480,6 +518,8 @@ CLASS z2ui6_cl_app_view1_js IMPLEMENTATION. ` if (params == undefined) {` && |\n| && ` return;` && |\n| && ` }` && |\n| && + |\n|. + result = result && ` if (params[msgType]?.TEXT !== undefined) {` && |\n| && ` if (msgType === 'S_MSG_TOAST') {` && |\n| && ` MessageToast.show(params[msgType].TEXT, {` && |\n| && @@ -518,8 +558,6 @@ CLASS z2ui6_cl_app_view1_js IMPLEMENTATION. ` }` && |\n| && ` }` && |\n| && ` },` && |\n| && - |\n|. - result = result && ` async displayView(xml, viewModel) {` && |\n| && ` let oview_model = new JSONModel(viewModel);` && |\n| && ` var oModel = oview_model;` && |\n| && @@ -551,7 +589,6 @@ CLASS z2ui6_cl_app_view1_js IMPLEMENTATION. ` },` && |\n| && ` })` && |\n| && ` });` && |\n| && - `` && |\n| && ``. ENDMETHOD. diff --git a/src/02/01/z2ui6_cl_pop_input_val.clas.abap b/src/02/01/z2ui6_cl_pop_input_val.clas.abap index c54368dc..e0e014af 100644 --- a/src/02/01/z2ui6_cl_pop_input_val.clas.abap +++ b/src/02/01/z2ui6_cl_pop_input_val.clas.abap @@ -37,7 +37,6 @@ CLASS z2ui6_cl_pop_input_val DEFINITION DATA button_text_confirm TYPE string. DATA button_text_cancel TYPE string. DATA check_initialized TYPE abap_bool. - DATA check_result_confirmed TYPE abap_bool. METHODS view_display. @@ -98,11 +97,11 @@ CLASS z2ui6_cl_pop_input_val IMPLEMENTATION. CASE client->get( )-event. WHEN `BUTTON_CONFIRM`. - check_result_confirmed = abap_true. + ms_result-check_confirmed = abap_true. client->popup_destroy( ). client->nav_app_leave( client->get_app( client->get( )-s_draft-id_prev_app_stack ) ). WHEN `BUTTON_CANCEL`. - check_result_confirmed = abap_false. + ms_result-check_confirmed = abap_false. client->popup_destroy( ). client->nav_app_leave( client->get_app( client->get( )-s_draft-id_prev_app_stack ) ). ENDCASE. diff --git a/src/02/z2ui6_if_client.intf.abap b/src/02/z2ui6_if_client.intf.abap index 65f6f8de..c680fc1f 100644 --- a/src/02/z2ui6_if_client.intf.abap +++ b/src/02/z2ui6_if_client.intf.abap @@ -19,6 +19,7 @@ INTERFACE z2ui6_if_client set_odata_model TYPE string VALUE `SET_ODATA_MODEL`, urlhelper TYPE string VALUE `URLHELPER`, history_back TYPE string VALUE `HISTORY_BACK`, + CLIPBOARD_APP_STATE TYPE string VALUE `CLIPBOARD_APP_STATE`, END OF cs_event. CONSTANTS: @@ -50,7 +51,7 @@ INTERFACE z2ui6_if_client METHODS set_push_state IMPORTING - val TYPE abap_bool DEFAULT abap_true. + val TYPE string optional. METHODS set_nav_back IMPORTING