Skip to content

Commit 714be61

Browse files
authored
Merge pull request #29 from abap2UI5-renamed/create-pull-request/patch
2 parents 6865437 + 8304f4e commit 714be61

8 files changed

+103
-41
lines changed

src/01/02/z2ui6_cl_core_srv_json.clas.abap

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ CLASS z2ui6_cl_core_srv_json DEFINITION
3636
ENDCLASS.
3737

3838

39+
3940
CLASS z2ui6_cl_core_srv_json IMPLEMENTATION.
41+
42+
4043
METHOD model_front_to_back.
4144

4245
IF line_exists( t_attri->*[ view = view ] ).
@@ -77,6 +80,7 @@ CLASS z2ui6_cl_core_srv_json IMPLEMENTATION.
7780

7881
ENDMETHOD.
7982

83+
8084
METHOD model_back_to_front.
8185
TRY.
8286

@@ -129,6 +133,7 @@ CLASS z2ui6_cl_core_srv_json IMPLEMENTATION.
129133
ENDTRY.
130134
ENDMETHOD.
131135

136+
132137
METHOD request_json_to_abap.
133138
TRY.
134139

@@ -163,10 +168,20 @@ CLASS z2ui6_cl_core_srv_json IMPLEMENTATION.
163168
CATCH cx_root.
164169
ENDTRY.
165170

166-
result-s_control-app_start_draft = z2ui6_cl_util=>c_trim_upper(
167-
z2ui6_cl_util=>url_param_get( val = `z2ui5-xapp-state`
168-
url = result-s_front-search ) ).
169-
171+
try.
172+
" result-s_control-app_start_draft = z2ui5_cl_util=>c_trim_upper(
173+
" z2ui5_cl_util=>url_param_get( val = `z2ui5-xapp-state`
174+
" url = result-s_front-search ) ).
175+
data(lv_hash) = result-s_front-hash.
176+
split lv_hash at '&/' into data(lv_dummy) lv_hash.
177+
if lv_hash is initial.
178+
lv_hash = result-s_front-hash+2.
179+
endif.
180+
result-s_control-app_start_draft = z2ui6_cl_util=>c_trim_upper(
181+
z2ui6_cl_util=>url_param_get( val = `z2ui5-xapp-state`
182+
url = lv_hash ) ).
183+
catch cx_root.
184+
endtry.
170185
IF result-s_control-app_start IS NOT INITIAL.
171186
IF result-s_control-app_start(1) = `-`.
172187
REPLACE FIRST OCCURRENCE OF `-` IN result-s_control-app_start WITH `/`.
@@ -187,6 +202,7 @@ CLASS z2ui6_cl_core_srv_json IMPLEMENTATION.
187202
ENDTRY.
188203
ENDMETHOD.
189204

205+
190206
METHOD response_abap_to_json.
191207
TRY.
192208

@@ -208,6 +224,7 @@ CLASS z2ui6_cl_core_srv_json IMPLEMENTATION.
208224
ENDTRY.
209225
ENDMETHOD.
210226

227+
211228
METHOD z2ui6_if_ajson_filter~keep_node.
212229

213230
rv_keep = abap_true.

src/01/02/z2ui6_if_core_types.intf.abap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ INTERFACE z2ui6_if_core_types
137137
END OF s_follow_up_action,
138138
* handler_attrs TYPE ty_s_http_handler_attributes,
139139
set_app_state_active TYPE abap_bool,
140-
set_push_state TYPE abap_bool,
140+
set_push_state TYPE string,
141141
set_nav_back TYPE abap_bool,
142142
s_stateful TYPE ty_s_http_res-s_stateful,
143143
END OF ty_s_next_frontend.

src/01/03/z2ui6_cl_app_app_js.clas.abap

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ CLASS z2ui6_cl_app_app_js IMPLEMENTATION.
2020

2121
result = `sap.ui.define(["sap/ui/core/mvc/Controller",` && |\n| &&
2222
` "z2ui5/controller/View1.controller",` && |\n| &&
23-
`], function (BaseController, Controller) {` && |\n| &&
23+
` "z2ui5/cc/Server",` && |\n| &&
24+
` "sap/ui/core/routing/HashChanger"` && |\n| &&
25+
`], function (BaseController, Controller, Server, HashChanger) {` && |\n| &&
2426
` return BaseController.extend("z2ui5.controller.App", {` && |\n| &&
2527
`` && |\n| &&
2628
` onInit() {` && |\n| &&
@@ -46,6 +48,12 @@ CLASS z2ui6_cl_app_app_js IMPLEMENTATION.
4648
`` && |\n| &&
4749
` z2ui5.checkNestAfter = false;` && |\n| &&
4850
`` && |\n| &&
51+
` // if (sap.ui.core.routing.HashChanger.getInstance().getHash().includes("z2ui5-xapp-state")){` && |\n| &&
52+
` if (HashChanger.getInstance().getHash()){` && |\n| &&
53+
` z2ui5.checkInit = true;` && |\n| &&
54+
` Server.Roundtrip();` && |\n| &&
55+
` }` && |\n| &&
56+
`` && |\n| &&
4957
` }` && |\n| &&
5058
` });` && |\n| &&
5159
`});` && |\n| &&
@@ -510,6 +518,8 @@ CLASS z2ui6_cl_app_app_js IMPLEMENTATION.
510518
` defaultValue: "Upload"` && |\n| &&
511519
` },` && |\n| &&
512520
` enabled: {` && |\n| &&
521+
|\n|.
522+
result = result &&
513523
` type: "boolean",` && |\n| &&
514524
` defaultValue: true` && |\n| &&
515525
` },` && |\n| &&
@@ -518,8 +528,6 @@ CLASS z2ui6_cl_app_app_js IMPLEMENTATION.
518528
` defaultValue: "sap-icon://browse-folder"` && |\n| &&
519529
` },` && |\n| &&
520530
` iconOnly: {` && |\n| &&
521-
|\n|.
522-
result = result &&
523531
` type: "boolean",` && |\n| &&
524532
` defaultValue: false` && |\n| &&
525533
` },` && |\n| &&
@@ -1012,6 +1020,8 @@ CLASS z2ui6_cl_app_app_js IMPLEMENTATION.
10121020
` DateCreateObject: (s) => new Date(s),` && |\n| &&
10131021
` // DateAbapTimestampToDate: (sTimestamp) => new sap.gantt.misc.Format.abapTimestampToDate(sTimestamp), commented for UI5 2.x compatibility` && |\n| &&
10141022
` DateAbapDateToDateObject: (d) => new Date(d.slice(0, 4), parseInt(d.slice(4, 6)) - 1, d.slice(6, 8)),` && |\n| &&
1023+
|\n|.
1024+
result = result &&
10151025
` 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| &&
10161026
` };` && |\n| &&
10171027
`}` && |\n| &&
@@ -1020,8 +1030,6 @@ CLASS z2ui6_cl_app_app_js IMPLEMENTATION.
10201030
` z2ui5.Util = Util;` && |\n| &&
10211031
`}` && |\n| &&
10221032
`);` && |\n| &&
1023-
|\n|.
1024-
result = result &&
10251033
`` && |\n| &&
10261034
`sap.ui.define("z2ui5/Favicon", ["sap/ui/core/Control"], (Control) => {` && |\n| &&
10271035
` "use strict";` && |\n| &&
@@ -1071,7 +1079,6 @@ CLASS z2ui6_cl_app_app_js IMPLEMENTATION.
10711079
` });` && |\n| &&
10721080
`}` && |\n| &&
10731081
`);` && |\n| &&
1074-
`` && |\n| &&
10751082
``.
10761083

10771084
ENDMETHOD.

src/01/03/z2ui6_cl_app_component_js.clas.abap

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,23 @@ CLASS z2ui6_cl_app_component_js IMPLEMENTATION.
2222
`], function (UIComponent, Models, Server, VersionInfo, DebugTool) {` && |\n| &&
2323
` return UIComponent.extend("z2ui5.Component", {` && |\n| &&
2424
` metadata: {` && |\n| &&
25-
` manifest: "json"` && |\n| &&
25+
` manifest: "json",` && |\n| &&
26+
` interfaces: [` && |\n| &&
27+
` "sap.ui.core.IAsyncContentCreation"` && |\n| &&
28+
` ]` && |\n| &&
2629
` },` && |\n| &&
2730
` async init() {` && |\n| &&
2831
` UIComponent.prototype.init.apply(this, arguments);` && |\n| &&
2932
`` && |\n| &&
3033
` if (typeof z2ui5 == 'undefined') {` && |\n| &&
3134
` z2ui5 = {};` && |\n| &&
3235
` }` && |\n| &&
33-
` this.getRouter().initialize();` && |\n| &&
36+
` z2ui5 = {};` && |\n| &&
37+
`` && |\n| &&
3438
` z2ui5.oRouter = this.getRouter();` && |\n| &&
39+
` z2ui5.oRouter.initialize();` && |\n| &&
40+
` z2ui5.oRouter.stop();` && |\n| &&
41+
`` && |\n| &&
3542
` z2ui5.oDeviceModel = Models.createDeviceModel();` && |\n| &&
3643
` this.setModel(z2ui5.oDeviceModel, "device");` && |\n| &&
3744
`` && |\n| &&
@@ -64,18 +71,13 @@ CLASS z2ui6_cl_app_component_js IMPLEMENTATION.
6471
` }` && |\n| &&
6572
` });` && |\n| &&
6673
`` && |\n| &&
67-
` // Handle forward/back buttons` && |\n| &&
6874
` window.addEventListener("popstate", (event) => {` && |\n| &&
6975
` delete event?.state?.response?.PARAMS?.SET_PUSH_STATE;` && |\n| &&
7076
` delete event?.state?.response?.PARAMS?.SET_APP_STATE_ACTIVE;` && |\n| &&
7177
` if (event?.state?.view) {` && |\n| &&
7278
` z2ui5.oController.ViewDestroy();` && |\n| &&
7379
` z2ui5.oResponse = event.state.response;` && |\n| &&
7480
` z2ui5.oController.displayView(event.state.view, event.state.model);` && |\n| &&
75-
` }else{` && |\n| &&
76-
` let urlObj = new URL(window.location.href);` && |\n| &&
77-
` urlObj.searchParams.delete("z2ui5-xapp-state");` && |\n| &&
78-
` history.replaceState(null, null, urlObj.pathname + urlObj.search + urlObj.hash);` && |\n| &&
7981
` }` && |\n| &&
8082
` });` && |\n| &&
8183
` },` && |\n| &&
@@ -96,7 +98,6 @@ CLASS z2ui6_cl_app_component_js IMPLEMENTATION.
9698
` },` && |\n| &&
9799
` });` && |\n| &&
98100
`});` && |\n| &&
99-
`` && |\n| &&
100101
``.
101102

102103
ENDMETHOD.

src/01/03/z2ui6_cl_app_server_js.clas.abap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ CLASS z2ui6_cl_app_server_js IMPLEMENTATION.
5151
` }` && |\n| &&
5252
` };` && |\n| &&
5353
`` && |\n| &&
54-
` try{` && |\n| &&
55-
` let oState = JSON.parse(JSON.stringify({ view: z2ui5.oView.mProperties.viewContent, model: z2ui5.oView.getModel().getData(), response: z2ui5.oResponse }));` && |\n| &&
56-
` history.replaceState(oState, "", window.location.href );` && |\n| &&
57-
` }catch(e){}` && |\n| &&
54+
` // try{` && |\n| &&
55+
` // let oState = JSON.parse(JSON.stringify({ view: z2ui5.oView.mProperties.viewContent, model: z2ui5.oView.getModel().getData(), response: z2ui5.oResponse }));` && |\n| &&
56+
` // history.replaceState(oState, "", window.location.href );` && |\n| &&
57+
` // }catch(e){}` && |\n| &&
5858
`` && |\n| &&
5959
` z2ui5.oBody ??= {};` && |\n| &&
6060
` z2ui5.oBody.S_FRONT = {` && |\n| &&

src/01/03/z2ui6_cl_app_view1_js.clas.abap

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ CLASS z2ui6_cl_app_view1_js IMPLEMENTATION.
2020

2121
result = `sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/model/json/JSONModel",` && |\n| &&
2222
` "sap/ui/core/BusyIndicator", "sap/m/MessageBox", "sap/m/MessageToast", "sap/ui/core/Fragment", "sap/m/BusyDialog",` && |\n| &&
23-
` "sap/ui/VersionInfo", "z2ui5/cc/Server", "sap/ui/model/odata/v2/ODataModel", "sap/m/library"` && |\n| &&
23+
` "sap/ui/VersionInfo", "z2ui5/cc/Server", "sap/ui/model/odata/v2/ODataModel", "sap/m/library", "sap/ui/core/routing/HashChanger"` && |\n| &&
2424
`],` && |\n| &&
2525
` function (Controller, XMLView, JSONModel, BusyIndicator, MessageBox, MessageToast, Fragment, mBusyDialog, VersionInfo,` && |\n| &&
26-
` Server, ODataModel, mobileLibrary) {` && |\n| &&
26+
` Server, ODataModel, mobileLibrary, HashChanger) {` && |\n| &&
2727
` "use strict";` && |\n| &&
2828
` return Controller.extend("z2ui5.controller.View1", {` && |\n| &&
2929
`` && |\n| &&
@@ -77,20 +77,31 @@ CLASS z2ui6_cl_app_view1_js IMPLEMENTATION.
7777
` }` && |\n| &&
7878
`` && |\n| &&
7979
` let oState = JSON.parse(JSON.stringify({ view: z2ui5.oView.mProperties.viewContent, model: z2ui5.oView.getModel().getData(), response: z2ui5.oResponse }));` && |\n| &&
80-
` if (SET_PUSH_STATE) {` && |\n| &&
81-
` history.pushState(oState, "", window.location.href );` && |\n| &&
82-
` }else{` && |\n| &&
80+
` if (SET_PUSH_STATE) {` && |\n| &&
81+
` // sap.ui.core.routing.HashChanger.getInstance().setHash("423143124");` && |\n| &&
82+
` // sap.ui.core.routing.HashChanger.getInstance().replaceHash("423143124");` && |\n| &&
83+
` //history.go(-1);` && |\n| &&
84+
` let urlObj = new URL(window.location.href);` && |\n| &&
85+
` let hash = HashChanger.getInstance().getHash();` && |\n| &&
86+
` if (!hash){` && |\n| &&
87+
` hash = '#';` && |\n| &&
88+
` }` && |\n| &&
89+
` history.pushState(oState, "", urlObj.pathname + urlObj.search + hash + SET_PUSH_STATE);` && |\n| &&
90+
` }else{` && |\n| &&
91+
` // debugger;` && |\n| &&
8392
` history.replaceState(oState, "", window.location.href );` && |\n| &&
8493
` }` && |\n| &&
8594
`` && |\n| &&
8695
` if (SET_APP_STATE_ACTIVE) {` && |\n| &&
87-
` let urlObj = new URL(window.location.href);` && |\n| &&
88-
` urlObj.searchParams.set("z2ui5-xapp-state", z2ui5.oResponse.ID);` && |\n| &&
89-
` history.replaceState(oState, null, urlObj.pathname + urlObj.search + urlObj.hash);` && |\n| &&
96+
` HashChanger.getInstance().replaceHash("z2ui5-xapp-state=" + z2ui5.oResponse.ID );` && |\n| &&
97+
` // let urlObj = new URL(window.location.href);` && |\n| &&
98+
` // urlObj.searchParams.set("z2ui5-xapp-state", z2ui5.oResponse.ID);` && |\n| &&
99+
` // history.replaceState(oState, null, urlObj.pathname + urlObj.search + urlObj.hash);` && |\n| &&
90100
` } else {` && |\n| &&
91-
` let urlObj = new URL(window.location.href);` && |\n| &&
92-
` urlObj.searchParams.delete("z2ui5-xapp-state");` && |\n| &&
93-
` history.replaceState(oState, null, urlObj.pathname + urlObj.search + urlObj.hash);` && |\n| &&
101+
` HashChanger.getInstance().replaceHash("");` && |\n| &&
102+
` // let urlObj = new URL(window.location.href);` && |\n| &&
103+
` // urlObj.searchParams.delete("z2ui5-xapp-state");` && |\n| &&
104+
` // history.replaceState(oState, null, urlObj.pathname + urlObj.search + urlObj.hash);` && |\n| &&
94105
` }` && |\n| &&
95106
`` && |\n| &&
96107
`` && |\n| &&
@@ -288,6 +299,33 @@ CLASS z2ui6_cl_app_view1_js IMPLEMENTATION.
288299
` case 'HISTORY_BACK':` && |\n| &&
289300
` history.back();` && |\n| &&
290301
` break;` && |\n| &&
302+
` case 'CLIPBOARD_APP_STATE':` && |\n| &&
303+
` function copyToClipboard(textToCopy) {` && |\n| &&
304+
` if (navigator.clipboard && typeof navigator.clipboard.writeText === "function") {` && |\n| &&
305+
` navigator.clipboard.writeText(textToCopy)` && |\n| &&
306+
` .then(() => {` && |\n| &&
307+
`` && |\n| &&
308+
` })` && |\n| &&
309+
` .catch(err => {` && |\n| &&
310+
`` && |\n| &&
311+
` });` && |\n| &&
312+
` } else {` && |\n| &&
313+
` const tempTextArea = document.createElement("textarea");` && |\n| &&
314+
` tempTextArea.value = textToCopy;` && |\n| &&
315+
` document.body.appendChild(tempTextArea);` && |\n| &&
316+
`` && |\n| &&
317+
` tempTextArea.select();` && |\n| &&
318+
` try {` && |\n| &&
319+
` document.execCommand("copy");` && |\n| &&
320+
`` && |\n| &&
321+
` } catch (err) {` && |\n| &&
322+
`` && |\n| &&
323+
` }` && |\n| &&
324+
` document.body.removeChild(tempTextArea);` && |\n| &&
325+
` }` && |\n| &&
326+
` }` && |\n| &&
327+
` copyToClipboard(window.location.href + '#/z2ui5-xapp-state=' + z2ui5.oResponse.ID );` && |\n| &&
328+
` break;` && |\n| &&
291329
` case 'SET_ODATA_MODEL':` && |\n| &&
292330
` var oModel = new ODataModel({ serviceUrl: args[1], annotationURI: (args.length > 3 ? args[3] : '') });` && |\n| &&
293331
` z2ui5.oView.setModel(oModel, args[2] ? args[2] : undefined);` && |\n| &&
@@ -480,6 +518,8 @@ CLASS z2ui6_cl_app_view1_js IMPLEMENTATION.
480518
` if (params == undefined) {` && |\n| &&
481519
` return;` && |\n| &&
482520
` }` && |\n| &&
521+
|\n|.
522+
result = result &&
483523
` if (params[msgType]?.TEXT !== undefined) {` && |\n| &&
484524
` if (msgType === 'S_MSG_TOAST') {` && |\n| &&
485525
` MessageToast.show(params[msgType].TEXT, {` && |\n| &&
@@ -518,8 +558,6 @@ CLASS z2ui6_cl_app_view1_js IMPLEMENTATION.
518558
` }` && |\n| &&
519559
` }` && |\n| &&
520560
` },` && |\n| &&
521-
|\n|.
522-
result = result &&
523561
` async displayView(xml, viewModel) {` && |\n| &&
524562
` let oview_model = new JSONModel(viewModel);` && |\n| &&
525563
` var oModel = oview_model;` && |\n| &&
@@ -551,7 +589,6 @@ CLASS z2ui6_cl_app_view1_js IMPLEMENTATION.
551589
` },` && |\n| &&
552590
` })` && |\n| &&
553591
` });` && |\n| &&
554-
`` && |\n| &&
555592
``.
556593

557594
ENDMETHOD.

src/02/01/z2ui6_cl_pop_input_val.clas.abap

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ CLASS z2ui6_cl_pop_input_val DEFINITION
3737
DATA button_text_confirm TYPE string.
3838
DATA button_text_cancel TYPE string.
3939
DATA check_initialized TYPE abap_bool.
40-
DATA check_result_confirmed TYPE abap_bool.
4140

4241
METHODS view_display.
4342

@@ -98,11 +97,11 @@ CLASS z2ui6_cl_pop_input_val IMPLEMENTATION.
9897

9998
CASE client->get( )-event.
10099
WHEN `BUTTON_CONFIRM`.
101-
check_result_confirmed = abap_true.
100+
ms_result-check_confirmed = abap_true.
102101
client->popup_destroy( ).
103102
client->nav_app_leave( client->get_app( client->get( )-s_draft-id_prev_app_stack ) ).
104103
WHEN `BUTTON_CANCEL`.
105-
check_result_confirmed = abap_false.
104+
ms_result-check_confirmed = abap_false.
106105
client->popup_destroy( ).
107106
client->nav_app_leave( client->get_app( client->get( )-s_draft-id_prev_app_stack ) ).
108107
ENDCASE.

0 commit comments

Comments
 (0)