Skip to content

Commit 6f3cee7

Browse files
1 parent b333db7 commit 6f3cee7

6 files changed

+53
-33
lines changed

src/02/z2ui5 0ec96042f38e7e75ceadd96a5.sicf.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<ICFDOCU>
1111
<ICF_NAME>Z2UI5</ICF_NAME>
1212
<ICF_LANGU>E</ICF_LANGU>
13-
<ICF_DOCU>abap2UI5 Frontend</ICF_DOCU>
13+
<ICF_DOCU>test</ICF_DOCU>
1414
</ICFDOCU>
1515
</asx:values>
1616
</asx:abap>

src/02/z2ui5 cc3e0011031e2f3f4be478dc5.sicf.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<ICFDOCU>
1111
<ICF_NAME>Z2UI5</ICF_NAME>
1212
<ICF_LANGU>E</ICF_LANGU>
13-
<ICF_DOCU>abap2UI5 Frontend</ICF_DOCU>
13+
<ICF_DOCU>test</ICF_DOCU>
1414
</ICFDOCU>
1515
</asx:values>
1616
</asx:abap>

src/02/z2ui5.wapa.cc_-server.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ sap.ui.define(["sap/ui/core/BusyIndicator", "sap/m/MessageBox"
3131
}
3232
};
3333

34-
try{
35-
let oState = JSON.parse(JSON.stringify({ view: z2ui5.oView.mProperties.viewContent, model: z2ui5.oView.getModel().getData(), response: z2ui5.oResponse }));
36-
history.replaceState(oState, "", window.location.href );
37-
}catch(e){}
34+
// try{
35+
// let oState = JSON.parse(JSON.stringify({ view: z2ui5.oView.mProperties.viewContent, model: z2ui5.oView.getModel().getData(), response: z2ui5.oResponse }));
36+
// history.replaceState(oState, "", window.location.href );
37+
// }catch(e){}
3838

3939
z2ui5.oBody ??= {};
4040
z2ui5.oBody.S_FRONT = {

src/02/z2ui5.wapa.component.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,22 @@ sap.ui.define(["sap/ui/core/UIComponent", "z2ui5/model/models", "z2ui5/cc/Server
22
], function (UIComponent, Models, Server, VersionInfo, DebugTool) {
33
return UIComponent.extend("z2ui5.Component", {
44
metadata: {
5-
manifest: "json"
5+
manifest: "json",
6+
interfaces: [
7+
"sap.ui.core.IAsyncContentCreation"
8+
]
69
},
710
async init() {
811
UIComponent.prototype.init.apply(this, arguments);
912

1013
if (typeof z2ui5 == 'undefined') {
1114
z2ui5 = {};
1215
}
13-
this.getRouter().initialize();
16+
1417
z2ui5.oRouter = this.getRouter();
18+
z2ui5.oRouter.initialize();
19+
z2ui5.oRouter.stop();
20+
1521
z2ui5.oDeviceModel = Models.createDeviceModel();
1622
this.setModel(z2ui5.oDeviceModel, "device");
1723

@@ -44,18 +50,13 @@ sap.ui.define(["sap/ui/core/UIComponent", "z2ui5/model/models", "z2ui5/cc/Server
4450
}
4551
});
4652

47-
// Handle forward/back buttons
4853
window.addEventListener("popstate", (event) => {
4954
delete event?.state?.response?.PARAMS?.SET_PUSH_STATE;
5055
delete event?.state?.response?.PARAMS?.SET_APP_STATE_ACTIVE;
5156
if (event?.state?.view) {
5257
z2ui5.oController.ViewDestroy();
5358
z2ui5.oResponse = event.state.response;
5459
z2ui5.oController.displayView(event.state.view, event.state.model);
55-
}else{
56-
let urlObj = new URL(window.location.href);
57-
urlObj.searchParams.delete("z2ui5-xapp-state");
58-
history.replaceState(null, null, urlObj.pathname + urlObj.search + urlObj.hash);
5960
}
6061
});
6162
},
@@ -75,4 +76,4 @@ sap.ui.define(["sap/ui/core/UIComponent", "z2ui5/model/models", "z2ui5/cc/Server
7576
UIComponent.prototype.exit.apply(this, arguments);
7677
},
7778
});
78-
});
79+
});

src/02/z2ui5.wapa.controller_-app.controller.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
sap.ui.define(["sap/ui/core/mvc/Controller",
22
"z2ui5/controller/View1.controller",
3-
], function (BaseController, Controller) {
3+
"z2ui5/cc/Server",
4+
"sap/ui/core/routing/HashChanger"
5+
], function (BaseController, Controller, Server, HashChanger) {
46
return BaseController.extend("z2ui5.controller.App", {
57

68
onInit() {
@@ -26,6 +28,12 @@ sap.ui.define(["sap/ui/core/mvc/Controller",
2628

2729
z2ui5.checkNestAfter = false;
2830

31+
// if (sap.ui.core.routing.HashChanger.getInstance().getHash().includes("z2ui5-xapp-state")){
32+
if (HashChanger.getInstance().getHash()){
33+
z2ui5.checkInit = true;
34+
Server.Roundtrip();
35+
}
36+
2937
}
3038
});
3139
});
@@ -173,7 +181,7 @@ sap.ui.define("z2ui5/LPTitle", ["sap/ui/core/Control"], (Control) => {
173181
z2ui5.ApplicationFullWidth = val;
174182
sap.ui.require([
175183
"sap/ushell/services/AppConfiguration"
176-
], async (AppConfiguration) => {
184+
], async (AppConfiguration) => {
177185
AppConfiguration.setApplicationFullWidth(z2ui5.ApplicationFullWidth);
178186
});
179187

@@ -1046,4 +1054,4 @@ sap.ui.define("z2ui5/Dirty", ["sap/ui/core/Control", "sap/ushell/Container"], (C
10461054
renderer(oRm, oControl) { }
10471055
});
10481056
}
1049-
);
1057+
);

src/02/z2ui5.wapa.controller_-view1.controller.js

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/model/json/JSONModel",
22
"sap/ui/core/BusyIndicator", "sap/m/MessageBox", "sap/m/MessageToast", "sap/ui/core/Fragment", "sap/m/BusyDialog",
3-
"sap/ui/VersionInfo", "z2ui5/cc/Server", "sap/ui/model/odata/v2/ODataModel", "sap/m/library"
3+
"sap/ui/VersionInfo", "z2ui5/cc/Server", "sap/ui/model/odata/v2/ODataModel", "sap/m/library", "sap/ui/core/routing/HashChanger"
44
],
55
function (Controller, XMLView, JSONModel, BusyIndicator, MessageBox, MessageToast, Fragment, mBusyDialog, VersionInfo,
6-
Server, ODataModel, mobileLibrary) {
6+
Server, ODataModel, mobileLibrary, HashChanger) {
77
"use strict";
88
return Controller.extend("z2ui5.controller.View1", {
99

@@ -57,23 +57,34 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/
5757
}
5858

5959
let oState = JSON.parse(JSON.stringify({ view: z2ui5.oView.mProperties.viewContent, model: z2ui5.oView.getModel().getData(), response: z2ui5.oResponse }));
60-
if (SET_PUSH_STATE) {
61-
history.pushState(oState, "", window.location.href );
62-
}else{
60+
if (SET_PUSH_STATE) {
61+
// sap.ui.core.routing.HashChanger.getInstance().setHash("423143124");
62+
// sap.ui.core.routing.HashChanger.getInstance().replaceHash("423143124");
63+
//history.go(-1);
64+
let urlObj = new URL(window.location.href);
65+
let hash = HashChanger.getInstance().getHash();
66+
if (!hash){
67+
hash = '#';
68+
}
69+
history.pushState(oState, "", urlObj.pathname + urlObj.search + hash + SET_PUSH_STATE);
70+
}else{
71+
// debugger;
6372
history.replaceState(oState, "", window.location.href );
6473
}
65-
74+
6675
if (SET_APP_STATE_ACTIVE) {
67-
let urlObj = new URL(window.location.href);
68-
urlObj.searchParams.set("z2ui5-xapp-state", z2ui5.oResponse.ID);
69-
history.replaceState(oState, null, urlObj.pathname + urlObj.search + urlObj.hash);
76+
HashChanger.getInstance().replaceHash("z2ui5-xapp-state=" + z2ui5.oResponse.ID );
77+
// let urlObj = new URL(window.location.href);
78+
// urlObj.searchParams.set("z2ui5-xapp-state", z2ui5.oResponse.ID);
79+
// history.replaceState(oState, null, urlObj.pathname + urlObj.search + urlObj.hash);
7080
} else {
71-
let urlObj = new URL(window.location.href);
72-
urlObj.searchParams.delete("z2ui5-xapp-state");
73-
history.replaceState(oState, null, urlObj.pathname + urlObj.search + urlObj.hash);
81+
HashChanger.getInstance().replaceHash("");
82+
// let urlObj = new URL(window.location.href);
83+
// urlObj.searchParams.delete("z2ui5-xapp-state");
84+
// history.replaceState(oState, null, urlObj.pathname + urlObj.search + urlObj.hash);
7485
}
7586

76-
87+
7788

7889
if (SET_NAV_BACK) {
7990
history.back();
@@ -282,7 +293,7 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/
282293
sap.ui.require([
283294
"sap/ushell/Container"
284295
], async (ushellContainer) => {
285-
// z2ui5.oCrossAppNavigator = await ushellContainer.getServiceAsync("CrossApplicationNavigation");
296+
// z2ui5.oCrossAppNavigator = await ushellContainer.getServiceAsync("CrossApplicationNavigation");
286297
z2ui5.oCrossAppNavigator = ushellContainer.getService("CrossApplicationNavigation");
287298
z2ui5.oCrossAppNavigator.backToPreviousApp();
288299
});
@@ -292,7 +303,7 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/
292303
sap.ui.require([
293304
"sap/ushell/Container"
294305
], async (ushellContainer) => {
295-
// z2ui5.oCrossAppNavigator = await ushellContainer.getServiceAsync("CrossApplicationNavigation");
306+
// z2ui5.oCrossAppNavigator = await ushellContainer.getServiceAsync("CrossApplicationNavigation");
296307
z2ui5.oCrossAppNavigator = ushellContainer.getService("CrossApplicationNavigation");
297308
const hash = (z2ui5.oCrossAppNavigator.hrefForExternal({
298309
target: z2ui5.args[1],
@@ -528,4 +539,4 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/
528539
z2ui5.oApp.insertPage(z2ui5.oView);
529540
},
530541
})
531-
});
542+
});

0 commit comments

Comments
 (0)