mirror of
https://github.com/abap2UI5/abap2UI5.git
synced 2025-04-29 02:58:20 +08:00

No display camera window in demo Z2UI5_CL_DEMO_APP_306. so modify App.controller.js of line 903/914 Co-authored-by: oblomov-dev <102328295+oblomov-dev@users.noreply.github.com>
1063 lines
27 KiB
JavaScript
1063 lines
27 KiB
JavaScript
sap.ui.define(["sap/ui/core/mvc/Controller",
|
|
"z2ui5/controller/View1.controller",
|
|
"z2ui5/cc/Server",
|
|
"sap/ui/core/routing/HashChanger"
|
|
], function (BaseController, Controller, Server, HashChanger) {
|
|
return BaseController.extend("z2ui5.controller.App", {
|
|
|
|
onInit() {
|
|
|
|
z2ui5.oOwnerComponent = this.getOwnerComponent();
|
|
z2ui5.oConfig.pathname = z2ui5.oOwnerComponent.getManifest()["sap.app"].dataSources.http.uri;
|
|
if (z2ui5?.checkLocal == true) {
|
|
z2ui5.oConfig.pathname = window.location.href;
|
|
};
|
|
|
|
z2ui5.oController = new Controller();
|
|
z2ui5.oApp = this.getView().byId("app");
|
|
|
|
z2ui5.oControllerNest = new Controller();
|
|
z2ui5.oControllerNest2 = new Controller();
|
|
z2ui5.oControllerPopup = new Controller();
|
|
z2ui5.oControllerPopover = new Controller();
|
|
|
|
z2ui5.onBeforeRoundtrip = [];
|
|
z2ui5.onAfterRendering = [];
|
|
z2ui5.onBeforeEventFrontend = [];
|
|
z2ui5.onAfterRoundtrip = [];
|
|
|
|
z2ui5.checkNestAfter = false;
|
|
|
|
// if (sap.ui.core.routing.HashChanger.getInstance().getHash().includes("z2ui5-xapp-state")){
|
|
if (HashChanger.getInstance().getHash()){
|
|
z2ui5.checkInit = true;
|
|
Server.Roundtrip();
|
|
}
|
|
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
sap.ui.define("z2ui5/Timer", ["sap/ui/core/Control"], (Control) => {
|
|
"use strict";
|
|
|
|
return Control.extend("z2ui5.Timer", {
|
|
metadata: {
|
|
properties: {
|
|
delayMS: {
|
|
type: "string",
|
|
defaultValue: ""
|
|
},
|
|
checkActive: {
|
|
type: "boolean",
|
|
defaultValue: true
|
|
},
|
|
checkRepeat: {
|
|
type: "boolean",
|
|
defaultValue: false
|
|
},
|
|
},
|
|
events: {
|
|
"finished": {
|
|
allowPreventDefault: true,
|
|
parameters: {},
|
|
}
|
|
}
|
|
},
|
|
onAfterRendering() { },
|
|
delayedCall(oControl) {
|
|
|
|
if (oControl.getProperty("checkActive") == false) {
|
|
return;
|
|
}
|
|
setTimeout((oControl) => {
|
|
oControl.setProperty("checkActive", false)
|
|
oControl.fireFinished();
|
|
if (oControl.getProperty("checkRepeat")) {
|
|
oControl.delayedCall(oControl);
|
|
}
|
|
}
|
|
, parseInt(oControl.getProperty("delayMS")), oControl);
|
|
},
|
|
renderer(oRm, oControl) {
|
|
oControl.delayedCall(oControl);
|
|
}
|
|
});
|
|
}
|
|
);
|
|
|
|
sap.ui.define("z2ui5/Focus", ["sap/ui/core/Control",], (Control) => {
|
|
"use strict";
|
|
return Control.extend("z2ui5.Focus", {
|
|
metadata: {
|
|
properties: {
|
|
setUpdate: {
|
|
type: "boolean",
|
|
defaultValue: true
|
|
},
|
|
focusId: {
|
|
type: "string"
|
|
},
|
|
selectionStart: {
|
|
type: "string",
|
|
defaultValue: "0"
|
|
},
|
|
selectionEnd: {
|
|
type: "string",
|
|
defaultValue: "0"
|
|
},
|
|
}
|
|
},
|
|
init() { },
|
|
setFocusId(val) {
|
|
try {
|
|
this.setProperty("focusId", val);
|
|
var oElement = z2ui5.oView.byId(val);
|
|
var oFocus = oElement.getFocusInfo();
|
|
oElement.applyFocusInfo(oFocus);
|
|
} catch (e) { }
|
|
},
|
|
renderer(oRm, oControl) {
|
|
if (!oControl.getProperty("setUpdate")) {
|
|
return;
|
|
}
|
|
oControl.setProperty("setUpdate", false);
|
|
setTimeout((oControl) => {
|
|
var oElement = z2ui5.oView.byId(oControl.getProperty("focusId"));
|
|
var oFocus = oElement.getFocusInfo();
|
|
oFocus.selectionStart = parseInt(oControl.getProperty("selectionStart"));
|
|
oFocus.selectionEnd = parseInt(oControl.getProperty("selectionEnd"));
|
|
oElement.applyFocusInfo(oFocus);
|
|
}
|
|
, 100, oControl);
|
|
}
|
|
});
|
|
}
|
|
);
|
|
|
|
sap.ui.define("z2ui5/Title", ["sap/ui/core/Control"], (Control) => {
|
|
"use strict";
|
|
return Control.extend("z2ui5.Title", {
|
|
metadata: {
|
|
properties: {
|
|
title: {
|
|
type: "string"
|
|
},
|
|
}
|
|
},
|
|
setTitle(val) {
|
|
this.setProperty("title", val);
|
|
document.title = val;
|
|
},
|
|
renderer(oRm, oControl) { }
|
|
});
|
|
}
|
|
);
|
|
sap.ui.define("z2ui5/LPTitle", ["sap/ui/core/Control"], (Control) => {
|
|
"use strict";
|
|
return Control.extend("z2ui5.LPTitle", {
|
|
metadata: {
|
|
properties: {
|
|
title: {
|
|
type: "string"
|
|
},
|
|
ApplicationFullWidth:{
|
|
type : "boolean"
|
|
}
|
|
}
|
|
},
|
|
setTitle(val) {
|
|
try {
|
|
this.setProperty("title", val);
|
|
z2ui5.oLaunchpadService.setTitle(val);
|
|
} catch (e) {
|
|
console.error("Launchpad Service to set Title not found");
|
|
}
|
|
},
|
|
|
|
setApplicationFullWidth(val) {
|
|
this.setProperty("ApplicationFullWidth", val);
|
|
z2ui5.ApplicationFullWidth = val;
|
|
sap.ui.require([
|
|
"sap/ushell/services/AppConfiguration"
|
|
], async (AppConfiguration) => {
|
|
AppConfiguration.setApplicationFullWidth(z2ui5.ApplicationFullWidth);
|
|
});
|
|
|
|
},
|
|
|
|
renderer(oRm, oControl) { }
|
|
});
|
|
}
|
|
);
|
|
sap.ui.define("z2ui5/History", ["sap/ui/core/Control"], (Control) => {
|
|
"use strict";
|
|
return Control.extend("z2ui5.History", {
|
|
metadata: {
|
|
properties: {
|
|
search: {
|
|
type: "string"
|
|
},
|
|
}
|
|
},
|
|
setSearch(val) {
|
|
this.setProperty("search", val);
|
|
history.replaceState(null, null, window.location.pathname + val);
|
|
},
|
|
renderer(oRm, oControl) { }
|
|
});
|
|
}
|
|
);
|
|
|
|
sap.ui.define("z2ui5/Tree", ["sap/ui/core/Control"], (Control) => {
|
|
"use strict";
|
|
|
|
return Control.extend("z2ui5.Tree", {
|
|
metadata: {
|
|
properties: {
|
|
tree_id: {
|
|
type: "string"
|
|
}
|
|
}
|
|
},
|
|
|
|
setBackend() {
|
|
z2ui5.treeState = z2ui5.oView.byId(this.getProperty("tree_id")).getBinding('items').getCurrentTreeState();
|
|
},
|
|
|
|
init() {
|
|
z2ui5.onBeforeRoundtrip.push(this.setBackend.bind(this));
|
|
},
|
|
|
|
renderer(oRm, oControl) {
|
|
if (!z2ui5.treeState) return;
|
|
setTimeout((id) => {
|
|
z2ui5.oView.byId(id).getBinding('items').setTreeState(z2ui5.treeState);
|
|
}, 100, oControl.getProperty("tree_id"));
|
|
}
|
|
});
|
|
});
|
|
|
|
sap.ui.define("z2ui5/Scrolling", ["sap/ui/core/Control"], (Control) => {
|
|
"use strict";
|
|
|
|
return Control.extend("z2ui5.Scrolling", {
|
|
metadata: {
|
|
properties: {
|
|
setUpdate: {
|
|
type: "boolean",
|
|
defaultValue: true
|
|
},
|
|
items: {
|
|
type: "Array"
|
|
}
|
|
}
|
|
},
|
|
|
|
setBackend() {
|
|
const items = this.getProperty("items");
|
|
|
|
if (items) {
|
|
items.forEach(item => {
|
|
try {
|
|
const scrollDelegate = z2ui5.oView.byId(item.N).getScrollDelegate();
|
|
item.V = scrollDelegate ? scrollDelegate.getScrollTop() : 0;
|
|
} catch {
|
|
try {
|
|
const element = document.getElementById(`${z2ui5.oView.byId(item.ID).getId()}-inner`);
|
|
item.V = element ? element.scrollTop : 0;
|
|
} catch { }
|
|
}
|
|
});
|
|
}
|
|
},
|
|
|
|
init() {
|
|
z2ui5.onBeforeRoundtrip.push(this.setBackend.bind(this));
|
|
},
|
|
|
|
renderer(oRm, oControl) {
|
|
if (!oControl.getProperty("setUpdate")) return;
|
|
|
|
oControl.setProperty("setUpdate", false);
|
|
const items = oControl.getProperty("items");
|
|
if (!items) return;
|
|
|
|
setTimeout(() => {
|
|
items.forEach(item => {
|
|
try {
|
|
z2ui5.oView.byId(item.N).scrollTo(item.V);
|
|
} catch {
|
|
try {
|
|
const element = document.getElementById(`${z2ui5.oView.byId(item.ID).getId()}-inner`);
|
|
if (element) element.scrollTop = item.V;
|
|
} catch {
|
|
setTimeout(() => {
|
|
z2ui5.oView.byId(item.N).scrollTo(item.V);
|
|
}, 1);
|
|
}
|
|
}
|
|
});
|
|
}, 100);
|
|
}
|
|
});
|
|
});
|
|
|
|
sap.ui.define("z2ui5/Info", ["sap/ui/core/Control", "sap/ui/VersionInfo", "sap/ui/Device"], (Control) => {
|
|
"use strict";
|
|
|
|
return Control.extend("z2ui5.Info", {
|
|
metadata: {
|
|
properties: {
|
|
ui5_version: {
|
|
type: "string"
|
|
},
|
|
device_phone: {
|
|
type: "string"
|
|
},
|
|
device_desktop: {
|
|
type: "string"
|
|
},
|
|
device_tablet: {
|
|
type: "string"
|
|
},
|
|
device_combi: {
|
|
type: "string"
|
|
},
|
|
device_height: {
|
|
type: "string"
|
|
},
|
|
device_width: {
|
|
type: "string"
|
|
},
|
|
ui5_theme: {
|
|
type: "string"
|
|
},
|
|
device_os: {
|
|
type: "string"
|
|
},
|
|
device_systemtype: {
|
|
type: "string"
|
|
},
|
|
device_browser: {
|
|
type: "string"
|
|
},
|
|
},
|
|
events: {
|
|
"finished": {
|
|
allowPreventDefault: true,
|
|
parameters: {},
|
|
}
|
|
}
|
|
},
|
|
|
|
init() { },
|
|
|
|
onAfterRendering() {
|
|
},
|
|
|
|
async renderer(_, oControl) {
|
|
|
|
let oDevice = z2ui5.oView.getModel("device").oData;
|
|
oControl.setProperty("ui5_version", z2ui5.oConfig.UI5VersionInfo.version);
|
|
oControl.setProperty("device_phone", oDevice.system.phone);
|
|
oControl.setProperty("device_desktop", oDevice.system.desktop);
|
|
oControl.setProperty("device_tablet", oDevice.system.tablet);
|
|
oControl.setProperty("device_combi", oDevice.system.combi);
|
|
oControl.setProperty("device_height", oDevice.resize.height);
|
|
oControl.setProperty("device_width", oDevice.resize.width);
|
|
oControl.setProperty("device_os", oDevice.os.name);
|
|
oControl.setProperty("device_browser", oDevice.browser.name);
|
|
oControl.fireFinished();
|
|
|
|
}
|
|
});
|
|
}
|
|
);
|
|
|
|
sap.ui.define("z2ui5/Geolocation", ["sap/ui/core/Control"], (Control) => {
|
|
"use strict";
|
|
|
|
return Control.extend("z2ui5.Geolocation", {
|
|
metadata: {
|
|
properties: {
|
|
longitude: {
|
|
type: "string",
|
|
defaultValue: ""
|
|
},
|
|
latitude: {
|
|
type: "string",
|
|
defaultValue: ""
|
|
},
|
|
altitude: {
|
|
type: "string",
|
|
defaultValue: ""
|
|
},
|
|
accuracy: {
|
|
type: "string",
|
|
defaultValue: ""
|
|
},
|
|
altitudeAccuracy: {
|
|
type: "string",
|
|
defaultValue: ""
|
|
},
|
|
speed: {
|
|
type: "string",
|
|
defaultValue: false
|
|
},
|
|
heading: {
|
|
type: "string",
|
|
defaultValue: false
|
|
},
|
|
enableHighAccuracy: {
|
|
type: "boolean",
|
|
defaultValue: false
|
|
},
|
|
timeout: {
|
|
type: "string",
|
|
defaultValue: "5000"
|
|
}
|
|
},
|
|
events: {
|
|
"finished": {
|
|
allowPreventDefault: true,
|
|
parameters: {},
|
|
}
|
|
}
|
|
},
|
|
|
|
callbackPosition(position) {
|
|
|
|
this.setProperty("longitude", position.coords.longitude, true);
|
|
this.setProperty("latitude", position.coords.latitude, true);
|
|
this.setProperty("altitude", position.coords.altitude, true);
|
|
this.setProperty("accuracy", position.coords.accuracy, true);
|
|
this.setProperty("altitudeAccuracy", position.coords.altitudeAccuracy, true);
|
|
this.setProperty("speed", position.coords.speed, true);
|
|
this.setProperty("heading", position.coords.heading, true);
|
|
this.fireFinished();
|
|
|
|
},
|
|
|
|
async init() {
|
|
|
|
navigator.geolocation.getCurrentPosition(this.callbackPosition.bind(this));
|
|
|
|
},
|
|
|
|
exit() {
|
|
},
|
|
|
|
onAfterRendering() {
|
|
},
|
|
|
|
renderer() {
|
|
}
|
|
});
|
|
}
|
|
);
|
|
|
|
sap.ui.define("z2ui5/FileUploader", ["sap/ui/core/Control", "sap/m/Button", "sap/ui/unified/FileUploader", "sap/m/HBox"], function (Control, Button, FileUploader, HBox) {
|
|
"use strict";
|
|
|
|
return Control.extend("z2ui5.FileUploader", {
|
|
|
|
metadata: {
|
|
properties: {
|
|
value: {
|
|
type: "string",
|
|
defaultValue: ""
|
|
},
|
|
path: {
|
|
type: "string",
|
|
defaultValue: ""
|
|
},
|
|
tooltip: {
|
|
type: "string",
|
|
defaultValue: ""
|
|
},
|
|
fileType: {
|
|
type: "string",
|
|
defaultValue: ""
|
|
},
|
|
placeholder: {
|
|
type: "string",
|
|
defaultValue: ""
|
|
},
|
|
buttonText: {
|
|
type: "string",
|
|
defaultValue: ""
|
|
},
|
|
style: {
|
|
type: "string",
|
|
defaultValue: ""
|
|
},
|
|
uploadButtonText: {
|
|
type: "string",
|
|
defaultValue: "Upload"
|
|
},
|
|
enabled: {
|
|
type: "boolean",
|
|
defaultValue: true
|
|
},
|
|
icon: {
|
|
type: "string",
|
|
defaultValue: "sap-icon://browse-folder"
|
|
},
|
|
iconOnly: {
|
|
type: "boolean",
|
|
defaultValue: false
|
|
},
|
|
buttonOnly: {
|
|
type: "boolean",
|
|
defaultValue: false
|
|
},
|
|
multiple: {
|
|
type: "boolean",
|
|
defaultValue: false
|
|
},
|
|
visible: {
|
|
type: "boolean",
|
|
defaultValue: true
|
|
},
|
|
checkDirectUpload: {
|
|
type: "boolean",
|
|
defaultValue: false
|
|
}
|
|
},
|
|
|
|
aggregations: {},
|
|
events: {
|
|
"upload": {
|
|
allowPreventDefault: true,
|
|
parameters: {}
|
|
}
|
|
},
|
|
renderer: null
|
|
},
|
|
|
|
renderer: function (oRm, oControl) {
|
|
|
|
if (!oControl.getProperty("checkDirectUpload")) {
|
|
oControl.oUploadButton = new Button({
|
|
text: oControl.getProperty("uploadButtonText"),
|
|
enabled: oControl.getProperty("path") !== "",
|
|
press: function (oEvent) {
|
|
|
|
this.setProperty("path", this.oFileUploader.getProperty("value"));
|
|
|
|
var file = z2ui5.oUpload.oFileUpload.files[0];
|
|
var reader = new FileReader();
|
|
|
|
reader.onload = function (evt) {
|
|
var vContent = evt.currentTarget.result;
|
|
this.setProperty("value", vContent);
|
|
this.fireUpload();
|
|
//this.getView().byId('picture' ).getDomRef().src = vContent;
|
|
}
|
|
.bind(this)
|
|
|
|
reader.readAsDataURL(file);
|
|
}
|
|
.bind(oControl)
|
|
});
|
|
}
|
|
|
|
oControl.oFileUploader = new FileUploader({
|
|
icon: oControl.getProperty("icon"),
|
|
iconOnly: oControl.getProperty("iconOnly"),
|
|
buttonOnly: oControl.getProperty("buttonOnly"),
|
|
buttonText: oControl.getProperty("buttonText"),
|
|
style: oControl.getProperty("style"),
|
|
fileType: oControl.getProperty("fileType"),
|
|
visible: oControl.getProperty("visible"),
|
|
uploadOnChange: oControl.getProperty("checkDirectUpload"),
|
|
enabled: oControl.getProperty("enabled"),
|
|
value: oControl.getProperty("path"),
|
|
placeholder: oControl.getProperty("placeholder"),
|
|
change: function (oEvent) {
|
|
if (oControl.getProperty("checkDirectUpload")) {
|
|
return;
|
|
}
|
|
|
|
var value = oEvent.getSource().getProperty("value");
|
|
this.setProperty("path", value);
|
|
if (value) {
|
|
this.oUploadButton.setEnabled();
|
|
} else {
|
|
this.oUploadButton.setEnabled(false);
|
|
}
|
|
this.oUploadButton.rerender();
|
|
z2ui5.oUpload = oEvent.oSource;
|
|
}
|
|
.bind(oControl),
|
|
uploadComplete: function (oEvent) {
|
|
if (!oControl.getProperty("checkDirectUpload")) {
|
|
return;
|
|
}
|
|
|
|
var value = oEvent.getSource().getProperty("value");
|
|
this.setProperty("path", value);
|
|
|
|
var file = oEvent.oSource.oFileUpload.files[0];
|
|
var reader = new FileReader();
|
|
|
|
reader.onload = function (evt) {
|
|
var vContent = evt.currentTarget.result;
|
|
this.setProperty("value", vContent);
|
|
this.fireUpload();
|
|
}
|
|
.bind(this)
|
|
|
|
reader.readAsDataURL(file);
|
|
}
|
|
.bind(oControl)
|
|
});
|
|
|
|
var hbox = new HBox();
|
|
hbox.addItem(oControl.oFileUploader);
|
|
hbox.addItem(oControl.oUploadButton);
|
|
oRm.renderControl(hbox);
|
|
}
|
|
});
|
|
});
|
|
|
|
sap.ui.define("z2ui5/MultiInputExt", ["sap/ui/core/Control", "sap/m/Token", "sap/ui/core/Core", "sap/ui/core/Element"], (Control, Token, Core, Element) => {
|
|
"use strict";
|
|
|
|
return Control.extend("z2ui5.MultiInputExt", {
|
|
metadata: {
|
|
properties: {
|
|
MultiInputId: {
|
|
type: "String"
|
|
},
|
|
MultiInputName: {
|
|
type: "String"
|
|
},
|
|
addedTokens: {
|
|
type: "Array"
|
|
},
|
|
checkInit: {
|
|
type: "Boolean",
|
|
defaultValue: false
|
|
},
|
|
removedTokens: {
|
|
type: "Array"
|
|
}
|
|
},
|
|
events: {
|
|
"change": {
|
|
allowPreventDefault: true,
|
|
parameters: {}
|
|
}
|
|
},
|
|
},
|
|
|
|
init() {
|
|
z2ui5.onAfterRendering.push(this.setControl.bind(this));
|
|
},
|
|
|
|
onTokenUpdate(oEvent) {
|
|
this.setProperty("addedTokens", []);
|
|
this.setProperty("removedTokens", []);
|
|
|
|
if (oEvent.mParameters.type == "removed") {
|
|
let removedTokens = [];
|
|
oEvent.mParameters.removedTokens.forEach((item) => {
|
|
removedTokens.push({
|
|
KEY: item.getKey(),
|
|
TEXT: item.getText()
|
|
});
|
|
}
|
|
);
|
|
this.setProperty("removedTokens", removedTokens);
|
|
} else {
|
|
let addedTokens = [];
|
|
oEvent.mParameters.addedTokens.forEach((item) => {
|
|
addedTokens.push({
|
|
KEY: item.getKey(),
|
|
TEXT: item.getText()
|
|
});
|
|
}
|
|
);
|
|
this.setProperty("addedTokens", addedTokens);
|
|
}
|
|
this.fireChange();
|
|
},
|
|
renderer(oRm, oControl) {
|
|
z2ui5.onAfterRendering.push(this.setControl.bind(oControl));
|
|
},
|
|
setControl() {
|
|
let table = z2ui5.oView.byId(this.getProperty("MultiInputId"));
|
|
if (!table) {
|
|
try {
|
|
// table = Core.byId(Element.getElementsByName(this.getProperty("MultiInputName"))[0].id.replace('-inner', ''));
|
|
} catch (e) {
|
|
return;
|
|
}
|
|
}
|
|
if (!table) {
|
|
return;
|
|
}
|
|
if (this.getProperty("checkInit") == true) {
|
|
return;
|
|
}
|
|
this.setProperty("checkInit", true);
|
|
table.attachTokenUpdate(this.onTokenUpdate.bind(this));
|
|
var fnValidator = function (args) {
|
|
var text = args.text;
|
|
return new Token({
|
|
key: text,
|
|
text: text
|
|
});
|
|
};
|
|
table.addValidator(fnValidator);
|
|
},
|
|
renderer(oRM, oControl) { }
|
|
});
|
|
}
|
|
);
|
|
|
|
sap.ui.define("z2ui5/SmartMultiInputExt", ["sap/ui/core/Control", "sap/m/Token", "sap/ui/core/Core", "sap/ui/core/Element"], (Control) => {
|
|
"use strict";
|
|
|
|
return Control.extend("z2ui5.SmartMultiInputExt", {
|
|
metadata: {
|
|
properties: {
|
|
multiInputId: {
|
|
type: "String"
|
|
},
|
|
addedTokens: {
|
|
type: "Array"
|
|
},
|
|
removedTokens: {
|
|
type: "Array"
|
|
},
|
|
rangeData: {
|
|
type: "Array",
|
|
defaultValue: []
|
|
},
|
|
checkInit: {
|
|
type: "Boolean",
|
|
defaultValue: false
|
|
}
|
|
},
|
|
events: {
|
|
"change": {
|
|
allowPreventDefault: true,
|
|
parameters: {}
|
|
}
|
|
},
|
|
},
|
|
|
|
init() {
|
|
z2ui5.onAfterRendering.push(this.setControl.bind(this));
|
|
},
|
|
|
|
onTokenUpdate(oEvent) {
|
|
this.setProperty("addedTokens", []);
|
|
this.setProperty("removedTokens", []);
|
|
|
|
if (oEvent.mParameters.type == "removed") {
|
|
let removedTokens = [];
|
|
oEvent.mParameters.removedTokens.forEach((item) => {
|
|
removedTokens.push({
|
|
KEY: item.getKey(),
|
|
TEXT: item.getText()
|
|
});
|
|
}
|
|
);
|
|
this.setProperty("removedTokens", removedTokens);
|
|
} else {
|
|
let addedTokens = [];
|
|
oEvent.mParameters.addedTokens.forEach((item) => {
|
|
addedTokens.push({
|
|
KEY: item.getKey(),
|
|
TEXT: item.getText()
|
|
});
|
|
}
|
|
);
|
|
this.setProperty("addedTokens", addedTokens);
|
|
}
|
|
const aTokens = oEvent.getSource().getTokens();
|
|
this.setProperty("rangeData", oEvent.getSource().getRangeData().map((oRangeData, iIndex) => {
|
|
const oToken = aTokens[iIndex];
|
|
oRangeData.tokenText = oToken.getText();
|
|
oRangeData.tokenLongKey = oToken.data("longKey");
|
|
return oRangeData;
|
|
}));
|
|
this.fireChange();
|
|
},
|
|
setRangeData(aRangeData) {
|
|
this.setProperty("rangeData", aRangeData);
|
|
this.inputInitialized().then((input) => {
|
|
input.setRangeData(aRangeData.map((oRangeData) => {
|
|
const oRangeDataNew = {};
|
|
Object.entries(oRangeData).forEach((aEntry) => {
|
|
const sKeyNameNew = aEntry[0].toLowerCase();
|
|
oRangeDataNew[(sKeyNameNew === "keyfield" ? "keyField" : sKeyNameNew)] = aEntry[1];
|
|
});
|
|
return oRangeDataNew;
|
|
}));
|
|
//we need to set token text explicitly, as setRangeData does no recalculation
|
|
input.getTokens().forEach((token, index) => {
|
|
const oRangeData = aRangeData[index];
|
|
token.data("longKey", oRangeData.TOKENLONGKEY);
|
|
token.data("range", null);
|
|
const sTokenText = oRangeData.TOKENTEXT;
|
|
if (sTokenText) {
|
|
token.setText(sTokenText);
|
|
}
|
|
});
|
|
});
|
|
},
|
|
renderer(oRm, oControl) { },
|
|
setControl() {
|
|
const input = z2ui5.oView.byId(this.getProperty("multiInputId"));
|
|
if (!input) {
|
|
return;
|
|
}
|
|
if (this.getProperty("checkInit") == true) {
|
|
return;
|
|
}
|
|
this.setProperty("checkInit", true);
|
|
input.attachTokenUpdate(this.onTokenUpdate.bind(this));
|
|
input.attachInnerControlsCreated(this.onInnerControlsCreated.bind(this));
|
|
},
|
|
inputInitialized(input) {
|
|
return new Promise((resolve, reject) => {
|
|
if (this._bInnerControlsCreated) {
|
|
resolve(input); //resolve immediately
|
|
} else {
|
|
this._oPendingInnerControlsCreated = resolve; //resolve later
|
|
}
|
|
});
|
|
},
|
|
_oPendingInnerControlsCreated: null,
|
|
_bInnerControlsCreated: false,
|
|
onInnerControlsCreated(oEvent) {
|
|
const input = oEvent.getSource();
|
|
if (this._oPendingInnerControlsCreated) {
|
|
this._oPendingInnerControlsCreated(input);
|
|
}
|
|
this._oPendingInnerControlsCreated = null;
|
|
this._bInnerControlsCreated = true;
|
|
}
|
|
});
|
|
}
|
|
);
|
|
|
|
sap.ui.define("z2ui5/CameraPicture", [
|
|
"sap/ui/core/Control",
|
|
"sap/m/Dialog",
|
|
"sap/m/Button"
|
|
], function (Control, Dialog, Button) {
|
|
"use strict";
|
|
return Control.extend("z2ui5.CameraPicture", {
|
|
metadata: {
|
|
properties: {
|
|
id: { type: "string" },
|
|
value: { type: "string" },
|
|
press: { type: "string" },
|
|
autoplay: { type: "boolean", defaultValue: true }
|
|
},
|
|
events: {
|
|
"OnPhoto": {
|
|
allowPreventDefault: true,
|
|
parameters: {
|
|
"photo": {
|
|
type: "string"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
capture: function (oEvent) {
|
|
|
|
var video = document.querySelector("#zvideo");
|
|
var canvas = document.getElementById('zcanvas');
|
|
var resultb64 = "";
|
|
canvas.width = 200;
|
|
canvas.height = 200;
|
|
canvas.getContext('2d').drawImage(video, 0, 0, 200, 200);
|
|
resultb64 = canvas.toDataURL();
|
|
this.setProperty("value", resultb64);
|
|
this.fireOnPhoto({
|
|
"photo": resultb64
|
|
});
|
|
},
|
|
|
|
onPicture: function (oEvent) {
|
|
|
|
if (!this._oScanDialog) {
|
|
this._oScanDialog = new Dialog({
|
|
title: "Device Photo Function",
|
|
contentWidth: "640px",
|
|
contentHeight: "480px",
|
|
horizontalScrolling: false,
|
|
verticalScrolling: false,
|
|
stretch: true,
|
|
content: [
|
|
new sap.ui.core.HTML({
|
|
id: this.getId() + 'PictureContainer',
|
|
content: '<video width="600px" height="400px" autoplay="true" id="zvideo">'
|
|
}),
|
|
new Button({
|
|
text: "Capture",
|
|
press: function (oEvent) {
|
|
this.capture();
|
|
this._oScanDialog.close();
|
|
}.bind(this)
|
|
}),
|
|
new sap.ui.core.HTML({
|
|
content: '<canvas hidden id="zcanvas" style="overflow:auto"></canvas>'
|
|
}),
|
|
],
|
|
endButton: new Button({
|
|
text: "Cancel",
|
|
press: function (oEvent) {
|
|
this._oScanDialog.close();
|
|
}.bind(this)
|
|
}),
|
|
});
|
|
}
|
|
|
|
this._oScanDialog.open();
|
|
|
|
setTimeout(function () {
|
|
var video = document.querySelector('#zvideo');
|
|
if (navigator.mediaDevices.getUserMedia) {
|
|
navigator.mediaDevices.getUserMedia({ video: { facingMode: { exact: "environment" } } })
|
|
.then(function (stream) {
|
|
video.srcObject = stream;
|
|
})
|
|
.catch(function (error) {
|
|
console.log("Something went wrong!");
|
|
});
|
|
}
|
|
}.bind(this), 300);
|
|
|
|
},
|
|
|
|
renderer: function (oRM, oControl) {
|
|
|
|
var oButton = new Button({
|
|
icon: "sap-icon://camera",
|
|
text: "Camera",
|
|
press: oControl.onPicture.bind(oControl),
|
|
});
|
|
oRM.renderControl(oButton);
|
|
|
|
},
|
|
});
|
|
});
|
|
|
|
sap.ui.define("z2ui5/UITableExt", ["sap/ui/core/Control"], (Control) => {
|
|
"use strict";
|
|
|
|
return Control.extend("z2ui5.UITableExt", {
|
|
metadata: {
|
|
properties: {
|
|
tableId: {
|
|
type: "String"
|
|
}
|
|
}
|
|
},
|
|
|
|
init() {
|
|
z2ui5.onBeforeRoundtrip.push(this.readFilter.bind(this));
|
|
z2ui5.onAfterRoundtrip.push(this.setFilter.bind(this));
|
|
},
|
|
|
|
readFilter() {
|
|
try {
|
|
let id = this.getProperty("tableId");
|
|
let oTable = z2ui5.oView.byId(id);
|
|
this.aFilters = oTable.getBinding().aFilters;
|
|
} catch (e) { }
|
|
;
|
|
},
|
|
|
|
setFilter() {
|
|
try {
|
|
setTimeout((aFilters) => {
|
|
let id = this.getProperty("tableId");
|
|
let oTable = z2ui5.oView.byId(id);
|
|
oTable.getBinding().filter(aFilters);
|
|
}
|
|
, 100, this.aFilters);
|
|
} catch (e) { }
|
|
;
|
|
},
|
|
|
|
renderer(oRM, oControl) { }
|
|
});
|
|
}
|
|
);
|
|
|
|
sap.ui.define("z2ui5/Util", [], () => {
|
|
"use strict";
|
|
return {
|
|
DateCreateObject: (s) => new Date(s),
|
|
// 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)),
|
|
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)),
|
|
};
|
|
}
|
|
);
|
|
sap.ui.require(["z2ui5/Util"], (Util) => {
|
|
z2ui5.Util = Util;
|
|
}
|
|
);
|
|
|
|
sap.ui.define("z2ui5/Favicon", ["sap/ui/core/Control"], (Control) => {
|
|
"use strict";
|
|
return Control.extend("z2ui5.Favicon", {
|
|
metadata: {
|
|
properties: {
|
|
favicon: {
|
|
type: "string"
|
|
},
|
|
}
|
|
},
|
|
setFavicon(val) {
|
|
this.setProperty("favicon", val);
|
|
let headTitle = document.querySelector('head');
|
|
let setFavicon = document.createElement('link');
|
|
setFavicon.setAttribute('rel', 'shortcut icon');
|
|
setFavicon.setAttribute('href', val);
|
|
headTitle.appendChild(setFavicon);
|
|
},
|
|
renderer(oRm, oControl) { }
|
|
});
|
|
}
|
|
);
|
|
|
|
sap.ui.define("z2ui5/Dirty", ["sap/ui/core/Control", "sap/ushell/Container"], (Control, Container) => {
|
|
"use strict";
|
|
return Control.extend("z2ui5.Dirty", {
|
|
metadata: {
|
|
properties: {
|
|
isDirty: {
|
|
type: "string"
|
|
},
|
|
}
|
|
},
|
|
setIsDirty(val) {
|
|
if (Container) {
|
|
Container.setDirtyFlag(val);
|
|
} else {
|
|
window.onbeforeunload = function (e) {
|
|
if (val) {
|
|
e.preventDefault();
|
|
}
|
|
}
|
|
}
|
|
},
|
|
renderer(oRm, oControl) { }
|
|
});
|
|
}
|
|
);
|