Ui5 v2 adjustments (#1578)

* update

* update

* Update abaplint.jsonc

* update

* update

* fixes
This commit is contained in:
oblomov-dev 2024-11-26 13:57:54 +01:00 committed by GitHub
parent 43550ff667
commit 0f155af743
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 99 additions and 65 deletions

View File

@ -16,4 +16,4 @@ jobs:
with: with:
node-version: '20.11.0' node-version: '20.11.0'
- run: cd app && npm i - run: cd app && npm i
- run: cd app && npm install --global @ui5/linter && ui5lint --details - run: cd app && npm install --global @ui5/linter && ui5lint --ignore-pattern "webapp/index.html" --details

View File

@ -31,7 +31,7 @@
"undeploy": "cf undeploy z2ui5 --delete-services --delete-service-keys --delete-service-brokers", "undeploy": "cf undeploy z2ui5 --delete-services --delete-service-keys --delete-service-brokers",
"deploy-test": "npm run build && fiori deploy --config ui5-deploy.yaml --testMode true", "deploy-test": "npm run build && fiori deploy --config ui5-deploy.yaml --testMode true",
"build:cf": "ui5 build preload --clean-dest --config ui5-deploy.yaml --include-task=generateCachebusterInfo", "build:cf": "ui5 build preload --clean-dest --config ui5-deploy.yaml --include-task=generateCachebusterInfo",
"transform": "node ../ci/app2string/trans2abap.js && abaplint --fix ../ci/app2string/abaplint.jsonc", "transform": "node ../ci/app2string/trans2abap.js",
"build:mta": "rimraf resources mta_archives && mbt build" "build:mta": "rimraf resources mta_archives && mbt build"
}, },
"sapuxLayer": "CUSTOMER_BASE" "sapuxLayer": "CUSTOMER_BASE"

View File

@ -16,9 +16,9 @@ sap.ui.define(["sap/ui/core/UIComponent", "z2ui5/model/models","z2ui5/cc/Server"
z2ui5.oConfig.ComponentData = this.getComponentData(); z2ui5.oConfig.ComponentData = this.getComponentData();
try { try {
z2ui5.oLaunchpadService = await this.getService("ShellUIService"); z2ui5.oLaunchpadService = await this.getService("ShellUIService");
} catch (e) {} } catch (e) {}
let oVersionInfo = await VersionInfo.load(); let oVersionInfo = await VersionInfo.load();
z2ui5.oConfig.UI5VersionInfo = { z2ui5.oConfig.UI5VersionInfo = {
version : oVersionInfo.version, version : oVersionInfo.version,

View File

@ -639,7 +639,7 @@ sap.ui.define("z2ui5/MultiInputExt", ["sap/ui/core/Control", "sap/m/Token", "sap
let table = z2ui5.oView.byId(this.getProperty("MultiInputId")); let table = z2ui5.oView.byId(this.getProperty("MultiInputId"));
if (!table) { if (!table) {
try { try {
table = Core.byId(Element.getElementsByName(this.getProperty("MultiInputName"))[0].id.replace('-inner', '')); // table = Core.byId(Element.getElementsByName(this.getProperty("MultiInputName"))[0].id.replace('-inner', ''));
} catch (e) { } catch (e) {
return; return;
} }
@ -667,8 +667,10 @@ sap.ui.define("z2ui5/MultiInputExt", ["sap/ui/core/Control", "sap/m/Token", "sap
); );
sap.ui.define("z2ui5/CameraPicture" , [ sap.ui.define("z2ui5/CameraPicture" , [
"sap/ui/core/Control" "sap/ui/core/Control",
], function (Control) { "sap/m/Dialog",
"sap/m/Button"
], function (Control, Dialog, Button) {
"use strict"; "use strict";
return Control.extend("z2ui5.CameraPicture", { return Control.extend("z2ui5.CameraPicture", {
metadata: { metadata: {
@ -708,30 +710,30 @@ sap.ui.define("z2ui5/CameraPicture" , [
onPicture: function (oEvent) { onPicture: function (oEvent) {
if (!this._oScanDialog) { if (!this._oScanDialog) {
this._oScanDialog = new sap.m.Dialog({ this._oScanDialog = new Dialog({
title: "Device Photo Function", title: "Device Photo Function",
contentWidth: "640px", contentWidth: "640px",
contentHeight: "480px", contentHeight: "480px",
horizontalScrolling: false, horizontalScrolling: false,
verticalScrolling: false, verticalScrolling: false,
stretchOnPhone: true, stretch: true,
content: [ content: [
new sap.ui.core.HTML({ new HTML({
id: this.getId() + 'PictureContainer', id: this.getId() + 'PictureContainer',
content: '<video width="600px" height="400px" autoplay="true" id="zvideo">' content: '<video width="600px" height="400px" autoplay="true" id="zvideo">'
}), }),
new sap.m.Button({ new Button({
text: "Capture", text: "Capture",
press: function (oEvent) { press: function (oEvent) {
this.capture(); this.capture();
this._oScanDialog.close(); this._oScanDialog.close();
}.bind(this) }.bind(this)
}), }),
new sap.ui.core.HTML({ new HTML({
content: '<canvas hidden id="zcanvas" style="overflow:auto"></canvas>' content: '<canvas hidden id="zcanvas" style="overflow:auto"></canvas>'
}), }),
], ],
endButton: new sap.m.Button({ endButton: new Button({
text: "Cancel", text: "Cancel",
press: function (oEvent) { press: function (oEvent) {
this._oScanDialog.close(); this._oScanDialog.close();
@ -759,7 +761,7 @@ sap.ui.define("z2ui5/CameraPicture" , [
renderer: function (oRM, oControl) { renderer: function (oRM, oControl) {
var oButton = new sap.m.Button({ var oButton = new Button({
icon: "sap-icon://camera", icon: "sap-icon://camera",
text: "Camera", text: "Camera",
press: oControl.onPicture.bind(oControl), press: oControl.onPicture.bind(oControl),
@ -817,7 +819,7 @@ sap.ui.define("z2ui5/Util", [], () => {
"use strict"; "use strict";
return { return {
DateCreateObject: (s) => new Date(s), DateCreateObject: (s) => new Date(s),
DateAbapTimestampToDate: (sTimestamp) => new sap.gantt.misc.Format.abapTimestampToDate(sTimestamp), // DateAbapTimestampToDate: (sTimestamp) => new sap.gantt.misc.Format.abapTimestampToDate(sTimestamp), commented for UI5 2.x compatibility
DateAbapDateToDateObject: (d) => new Date(d.slice(0, 4), parseInt(d.slice(4, 6)) - 1, d.slice(6, 8)), DateAbapDateToDateObject: (d) => new Date(d.slice(0, 4), parseInt(d.slice(4, 6)) - 1, d.slice(6, 8)),
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)), 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)),
}; };

View File

@ -248,26 +248,40 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/
a.click(); a.click();
break; break;
case 'CROSS_APP_NAV_TO_PREV_APP': case 'CROSS_APP_NAV_TO_PREV_APP':
oCrossAppNavigator = sap.ushell.Container.getService("CrossApplicationNavigation"); sap.ui.require([
oCrossAppNavigator.backToPreviousApp(); "sap/ushell/Container"
], async (ushellContainer) => {
// z2ui5.oCrossAppNavigator = await ushellContainer.getServiceAsync("CrossApplicationNavigation");
z2ui5.oCrossAppNavigator = ushellContainer.getService("CrossApplicationNavigation");
z2ui5.oCrossAppNavigator.backToPreviousApp();
});
//oCrossAppNavigator = sap.ushell.Container.getService("CrossApplicationNavigation");
break; break;
case 'CROSS_APP_NAV_TO_EXT': case 'CROSS_APP_NAV_TO_EXT':
oCrossAppNavigator = sap.ushell.Container.getService("CrossApplicationNavigation"); z2ui5.args = args;
const hash = (oCrossAppNavigator.hrefForExternal({ sap.ui.require([
target: args[1], "sap/ushell/Container"
params: args[2] ], async (ushellContainer) => {
})) || ""; // z2ui5.oCrossAppNavigator = await ushellContainer.getServiceAsync("CrossApplicationNavigation");
if (args[3] === 'EXT') { z2ui5.oCrossAppNavigator = ushellContainer.getService("CrossApplicationNavigation");
let url = window.location.href.split('#')[0] + hash; const hash = (z2ui5.oCrossAppNavigator.hrefForExternal({
//todo target: z2ui5.args[1],
//URLHelper.redirect(url, true); params: z2ui5.args[2]
} else { })) || "";
oCrossAppNavigator.toExternal({ if (z2ui5.args[3] === 'EXT') {
target: { let url = window.location.href.split('#')[0] + hash;
shellHash: hash //todo
} //URLHelper.redirect(url, true);
}); } else {
} z2ui5.oCrossAppNavigator.toExternal({
target: {
shellHash: hash
}
});
}
});
break; break;
case 'LOCATION_RELOAD': case 'LOCATION_RELOAD':
window.location = args[1]; window.location = args[1];

View File

@ -82,7 +82,7 @@
"commented_code": false, "commented_code": false,
"constant_classes": true, "constant_classes": true,
"constructor_visibility_public": true, "constructor_visibility_public": true,
"contains_tab": true, "contains_tab": false,
"cyclic_oo": false, "cyclic_oo": false,
"cyclomatic_complexity": { "cyclomatic_complexity": {
"exclude": [], "exclude": [],

View File

@ -661,7 +661,7 @@ CLASS z2ui5_cl_app_app_js IMPLEMENTATION.
` let table = z2ui5.oView.byId(this.getProperty("MultiInputId"));` && |\n| && ` let table = z2ui5.oView.byId(this.getProperty("MultiInputId"));` && |\n| &&
` if (!table) {` && |\n| && ` if (!table) {` && |\n| &&
` try {` && |\n| && ` try {` && |\n| &&
` table = Core.byId(Element.getElementsByName(this.getProperty("MultiInputName"))[0].id.replace('-inner', ''));` && |\n| && ` // table = Core.byId(Element.getElementsByName(this.getProperty("MultiInputName"))[0].id.replace('-inner', ''));` && |\n| &&
` } catch (e) {` && |\n| && ` } catch (e) {` && |\n| &&
` return;` && |\n| && ` return;` && |\n| &&
` }` && |\n| && ` }` && |\n| &&
@ -689,8 +689,10 @@ CLASS z2ui5_cl_app_app_js IMPLEMENTATION.
`);` && |\n| && `);` && |\n| &&
`` && |\n| && `` && |\n| &&
`sap.ui.define("z2ui5/CameraPicture" , [` && |\n| && `sap.ui.define("z2ui5/CameraPicture" , [` && |\n| &&
` "sap/ui/core/Control"` && |\n| && ` "sap/ui/core/Control",` && |\n| &&
`], function (Control) {` && |\n| && ` "sap/m/Dialog",` && |\n| &&
` "sap/m/Button"` && |\n| &&
`], function (Control, Dialog, Button) {` && |\n| &&
` "use strict";` && |\n| && ` "use strict";` && |\n| &&
` return Control.extend("z2ui5.CameraPicture", {` && |\n| && ` return Control.extend("z2ui5.CameraPicture", {` && |\n| &&
` metadata: {` && |\n| && ` metadata: {` && |\n| &&
@ -730,30 +732,30 @@ CLASS z2ui5_cl_app_app_js IMPLEMENTATION.
` onPicture: function (oEvent) {` && |\n| && ` onPicture: function (oEvent) {` && |\n| &&
`` && |\n| && `` && |\n| &&
` if (!this._oScanDialog) {` && |\n| && ` if (!this._oScanDialog) {` && |\n| &&
` this._oScanDialog = new sap.m.Dialog({` && |\n| && ` this._oScanDialog = new Dialog({` && |\n| &&
` title: "Device Photo Function",` && |\n| && ` title: "Device Photo Function",` && |\n| &&
` contentWidth: "640px",` && |\n| && ` contentWidth: "640px",` && |\n| &&
` contentHeight: "480px",` && |\n| && ` contentHeight: "480px",` && |\n| &&
` horizontalScrolling: false,` && |\n| && ` horizontalScrolling: false,` && |\n| &&
` verticalScrolling: false,` && |\n| && ` verticalScrolling: false,` && |\n| &&
` stretchOnPhone: true,` && |\n| && ` stretch: true,` && |\n| &&
` content: [` && |\n| && ` content: [` && |\n| &&
` new sap.ui.core.HTML({` && |\n| && ` new HTML({` && |\n| &&
` id: this.getId() + 'PictureContainer',` && |\n| && ` id: this.getId() + 'PictureContainer',` && |\n| &&
` content: '<video width="600px" height="400px" autoplay="true" id="zvideo">'` && |\n| && ` content: '<video width="600px" height="400px" autoplay="true" id="zvideo">'` && |\n| &&
` }),` && |\n| && ` }),` && |\n| &&
` new sap.m.Button({` && |\n| && ` new Button({` && |\n| &&
` text: "Capture",` && |\n| && ` text: "Capture",` && |\n| &&
` press: function (oEvent) {` && |\n| && ` press: function (oEvent) {` && |\n| &&
` this.capture();` && |\n| && ` this.capture();` && |\n| &&
` this._oScanDialog.close();` && |\n| && ` this._oScanDialog.close();` && |\n| &&
` }.bind(this)` && |\n| && ` }.bind(this)` && |\n| &&
` }),` && |\n| && ` }),` && |\n| &&
` new sap.ui.core.HTML({` && |\n| && ` new HTML({` && |\n| &&
` content: '<canvas hidden id="zcanvas" style="overflow:auto"></canvas>'` && |\n| && ` content: '<canvas hidden id="zcanvas" style="overflow:auto"></canvas>'` && |\n| &&
` }),` && |\n| && ` }),` && |\n| &&
` ],` && |\n| && ` ],` && |\n| &&
` endButton: new sap.m.Button({` && |\n| && ` endButton: new Button({` && |\n| &&
` text: "Cancel",` && |\n| && ` text: "Cancel",` && |\n| &&
` press: function (oEvent) {` && |\n| && ` press: function (oEvent) {` && |\n| &&
` this._oScanDialog.close();` && |\n| && ` this._oScanDialog.close();` && |\n| &&
@ -781,7 +783,7 @@ CLASS z2ui5_cl_app_app_js IMPLEMENTATION.
`` && |\n| && `` && |\n| &&
` renderer: function (oRM, oControl) {` && |\n| && ` renderer: function (oRM, oControl) {` && |\n| &&
`` && |\n| && `` && |\n| &&
` var oButton = new sap.m.Button({` && |\n| && ` var oButton = new Button({` && |\n| &&
` icon: "sap-icon://camera",` && |\n| && ` icon: "sap-icon://camera",` && |\n| &&
` text: "Camera",` && |\n| && ` text: "Camera",` && |\n| &&
` press: oControl.onPicture.bind(oControl),` && |\n| && ` press: oControl.onPicture.bind(oControl),` && |\n| &&
@ -839,7 +841,7 @@ CLASS z2ui5_cl_app_app_js IMPLEMENTATION.
` "use strict";` && |\n| && ` "use strict";` && |\n| &&
` return {` && |\n| && ` return {` && |\n| &&
` DateCreateObject: (s) => new Date(s),` && |\n| && ` DateCreateObject: (s) => new Date(s),` && |\n| &&
` DateAbapTimestampToDate: (sTimestamp) => new sap.gantt.misc.Format.abapTimestampToDate(sTimestamp),` && |\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| && ` DateAbapDateToDateObject: (d) => new Date(d.slice(0, 4), parseInt(d.slice(4, 6)) - 1, d.slice(6, 8)),` && |\n| &&
` 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| && ` 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| &&

View File

@ -37,7 +37,7 @@ CLASS z2ui5_cl_app_component_js IMPLEMENTATION.
`` && |\n| && `` && |\n| &&
` try {` && |\n| && ` try {` && |\n| &&
` z2ui5.oLaunchpadService = await this.getService("ShellUIService");` && |\n| && ` z2ui5.oLaunchpadService = await this.getService("ShellUIService");` && |\n| &&
` } catch (e) {}` && |\n| && ` } catch (e) {}` && |\n| &&
`` && |\n| && `` && |\n| &&
` let oVersionInfo = await VersionInfo.load();` && |\n| && ` let oVersionInfo = await VersionInfo.load();` && |\n| &&
` z2ui5.oConfig.UI5VersionInfo = {` && |\n| && ` z2ui5.oConfig.UI5VersionInfo = {` && |\n| &&

View File

@ -268,26 +268,40 @@ CLASS z2ui5_cl_app_view1_js IMPLEMENTATION.
` a.click();` && |\n| && ` a.click();` && |\n| &&
` break;` && |\n| && ` break;` && |\n| &&
` case 'CROSS_APP_NAV_TO_PREV_APP':` && |\n| && ` case 'CROSS_APP_NAV_TO_PREV_APP':` && |\n| &&
` oCrossAppNavigator = sap.ushell.Container.getService("CrossApplicationNavigation");` && |\n| && ` sap.ui.require([` && |\n| &&
` oCrossAppNavigator.backToPreviousApp();` && |\n| && ` "sap/ushell/Container"` && |\n| &&
` ], async (ushellContainer) => {` && |\n| &&
` // z2ui5.oCrossAppNavigator = await ushellContainer.getServiceAsync("CrossApplicationNavigation");` && |\n| &&
` z2ui5.oCrossAppNavigator = ushellContainer.getService("CrossApplicationNavigation");` && |\n| &&
` z2ui5.oCrossAppNavigator.backToPreviousApp();` && |\n| &&
` });` && |\n| &&
`` && |\n| &&
` //oCrossAppNavigator = sap.ushell.Container.getService("CrossApplicationNavigation");` && |\n| &&
`` && |\n| &&
` break;` && |\n| && ` break;` && |\n| &&
` case 'CROSS_APP_NAV_TO_EXT':` && |\n| && ` case 'CROSS_APP_NAV_TO_EXT':` && |\n| &&
` oCrossAppNavigator = sap.ushell.Container.getService("CrossApplicationNavigation");` && |\n| && ` z2ui5.args = args;` && |\n| &&
` const hash = (oCrossAppNavigator.hrefForExternal({` && |\n| && ` sap.ui.require([` && |\n| &&
` target: args[1],` && |\n| && ` "sap/ushell/Container"` && |\n| &&
` params: args[2]` && |\n| && ` ], async (ushellContainer) => {` && |\n| &&
` })) || "";` && |\n| && ` // z2ui5.oCrossAppNavigator = await ushellContainer.getServiceAsync("CrossApplicationNavigation");` && |\n| &&
` if (args[3] === 'EXT') {` && |\n| && ` z2ui5.oCrossAppNavigator = ushellContainer.getService("CrossApplicationNavigation");` && |\n| &&
` let url = window.location.href.split('#')[0] + hash;` && |\n| && ` const hash = (z2ui5.oCrossAppNavigator.hrefForExternal({` && |\n| &&
` //todo` && |\n| && ` target: z2ui5.args[1],` && |\n| &&
` //URLHelper.redirect(url, true);` && |\n| && ` params: z2ui5.args[2]` && |\n| &&
` } else {` && |\n| && ` })) || "";` && |\n| &&
` oCrossAppNavigator.toExternal({` && |\n| && ` if (z2ui5.args[3] === 'EXT') {` && |\n| &&
` target: {` && |\n| && ` let url = window.location.href.split('#')[0] + hash;` && |\n| &&
` shellHash: hash` && |\n| && ` //todo` && |\n| &&
` }` && |\n| && ` //URLHelper.redirect(url, true);` && |\n| &&
` });` && |\n| && ` } else {` && |\n| &&
` }` && |\n| && ` z2ui5.oCrossAppNavigator.toExternal({` && |\n| &&
` target: {` && |\n| &&
` shellHash: hash` && |\n| &&
` }` && |\n| &&
` });` && |\n| &&
` }` && |\n| &&
` });` && |\n| &&
` break;` && |\n| && ` break;` && |\n| &&
` case 'LOCATION_RELOAD':` && |\n| && ` case 'LOCATION_RELOAD':` && |\n| &&
` window.location = args[1];` && |\n| && ` window.location = args[1];` && |\n| &&
@ -504,6 +518,8 @@ CLASS z2ui5_cl_app_view1_js IMPLEMENTATION.
` }` && |\n| && ` }` && |\n| &&
` });` && |\n| && ` });` && |\n| &&
` z2ui5.oView.setModel(z2ui5.oDeviceModel, "device");` && |\n| && ` z2ui5.oView.setModel(z2ui5.oDeviceModel, "device");` && |\n| &&
|\n|.
result = result &&
` this._oApp.removeAllPages();` && |\n| && ` this._oApp.removeAllPages();` && |\n| &&
` this._oApp.insertPage(z2ui5.oView);` && |\n| && ` this._oApp.insertPage(z2ui5.oView);` && |\n| &&
` },` && |\n| && ` },` && |\n| &&