@sapui5/sap.ndc 1.93.3 → 1.96.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/sap/ndc/.library +3 -4
- package/src/sap/ndc/BarcodeScanner.js +65 -46
- package/src/sap/ndc/BarcodeScannerButtonRenderer.js +4 -1
- package/src/sap/ndc/library.js +1 -1
- package/src/sap/ndc/thirdparty/ZXing-dbg.js +5 -0
- package/src/sap/ndc/thirdparty/ZXing.js +1 -1
- package/ui5.yaml +0 -3
package/package.json
CHANGED
package/src/sap/ndc/.library
CHANGED
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
<name>sap.ndc</name>
|
|
5
5
|
<vendor>SAP SE</vendor>
|
|
6
6
|
<copyright>SAPUI5
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<version>1.93.3</version>
|
|
7
|
+
* (c) Copyright 2009-2021 SAP SE. All rights reserved.</copyright>
|
|
8
|
+
<version>1.96.2</version>
|
|
10
9
|
|
|
11
10
|
<documentation>SAPUI5 library with controls with native device capabilities.</documentation>
|
|
12
11
|
|
|
@@ -30,7 +29,7 @@
|
|
|
30
29
|
<jscoverage xmlns="http://www.sap.com/ui5/buildext/jscoverage">
|
|
31
30
|
<exclude name="sap.ndc.thirdparty."/>
|
|
32
31
|
</jscoverage>
|
|
33
|
-
|
|
32
|
+
|
|
34
33
|
<!-- Thirdparty references -->
|
|
35
34
|
<thirdparty xmlns="http://www.sap.com/ui5/buildext/thirdparty" >
|
|
36
35
|
<lib name="@zxing/library" displayName="ZXing" version="0.18.3" homepage="https://zxing-js.github.io/library/">
|
|
@@ -39,13 +39,11 @@ sap.ui.define([
|
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* @class
|
|
42
|
-
* TODO: description
|
|
43
42
|
*
|
|
44
|
-
*
|
|
45
|
-
* statement must be explicitly executed before the class can be used. Example: *
|
|
43
|
+
* Here is an example of how to trigger the scan function of BarcodeScanner:
|
|
46
44
|
* <pre>
|
|
47
|
-
* sap.ui.
|
|
48
|
-
*
|
|
45
|
+
* sap.ui.require(["sap/ndc/BarcodeScanner"], function(BarcodeScanner) {
|
|
46
|
+
* BarcodeScanner.scan(
|
|
49
47
|
* function (oResult) { / * process scan result * / },
|
|
50
48
|
* function (oError) { / * handle scan error * / },
|
|
51
49
|
* function (oResult) { / * handle input dialog change * / }
|
|
@@ -123,19 +121,26 @@ sap.ui.define([
|
|
|
123
121
|
}
|
|
124
122
|
|
|
125
123
|
function getZXingAPI() {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
124
|
+
sap.ui.require([
|
|
125
|
+
"sap/ndc/thirdparty/ZXing"
|
|
126
|
+
], function (ZXing) {
|
|
127
|
+
oZXing = ZXing;
|
|
128
|
+
if (oZXing) {
|
|
129
|
+
oZXingScannerAPI = new oZXing.BrowserMultiFormatReader();
|
|
130
|
+
if (oZXingScannerAPI) {
|
|
131
|
+
Log.debug("ZXing BrowserMultiFormatReader API is available!");
|
|
132
|
+
} else {
|
|
133
|
+
oStatusModel.setProperty("/available", false);
|
|
134
|
+
Log.error("BarcodeScanner: ZXing BrowserMultiFormatReader API is not available");
|
|
135
|
+
}
|
|
131
136
|
} else {
|
|
132
137
|
oStatusModel.setProperty("/available", false);
|
|
133
|
-
Log.error("BarcodeScanner:
|
|
138
|
+
Log.error("BarcodeScanner: Scanner API is not available");
|
|
134
139
|
}
|
|
135
|
-
}
|
|
140
|
+
}, function (oError) {
|
|
136
141
|
oStatusModel.setProperty("/available", false);
|
|
137
|
-
Log.error("BarcodeScanner:
|
|
138
|
-
}
|
|
142
|
+
Log.error("BarcodeScanner: ZXing is not available");
|
|
143
|
+
});
|
|
139
144
|
}
|
|
140
145
|
|
|
141
146
|
|
|
@@ -221,16 +226,19 @@ sap.ui.define([
|
|
|
221
226
|
oScanDialog.removeStyleClass('sapUiNoContentPadding');
|
|
222
227
|
|
|
223
228
|
oScanDialog.setTitle(oDialogTitle);
|
|
229
|
+
|
|
230
|
+
var oMSGLabel = new Label(oScanDialog.getId() + '-txt_barcode', {
|
|
231
|
+
text: "{i18n>BARCODE_DIALOG_MSG}",
|
|
232
|
+
visible: "{/isNoScanner}"
|
|
233
|
+
});
|
|
224
234
|
oScanDialog.addContent(
|
|
225
|
-
|
|
226
|
-
text: "{i18n>BARCODE_DIALOG_MSG}",
|
|
227
|
-
visible: "{/isNoScanner}"
|
|
228
|
-
})
|
|
235
|
+
oMSGLabel
|
|
229
236
|
);
|
|
230
237
|
|
|
231
238
|
var oFallbackInput = new Input(oScanDialog.getId() + '-inp_barcode', {
|
|
232
239
|
value: "{/barcode}",
|
|
233
240
|
valueLiveUpdate: true,
|
|
241
|
+
ariaLabelledBy: oMSGLabel.getId(),
|
|
234
242
|
liveChange: function(oEvent) {
|
|
235
243
|
if (typeof oScanDialogController.onLiveUpdate === "function") {
|
|
236
244
|
oScanDialogController.onLiveUpdate({
|
|
@@ -280,7 +288,12 @@ sap.ui.define([
|
|
|
280
288
|
.getUserMedia(defaultConstraints)
|
|
281
289
|
.then(
|
|
282
290
|
function(stream) {
|
|
283
|
-
|
|
291
|
+
if (oZXingScannerAPI) {
|
|
292
|
+
openBarcodeScannerDialogContains();
|
|
293
|
+
} else {
|
|
294
|
+
oScanDialog.getModel().setProperty("/isNoScanner", true);
|
|
295
|
+
openBarcodeInputDialog();
|
|
296
|
+
}
|
|
284
297
|
}
|
|
285
298
|
)
|
|
286
299
|
.catch(
|
|
@@ -319,6 +332,7 @@ sap.ui.define([
|
|
|
319
332
|
}
|
|
320
333
|
}),
|
|
321
334
|
afterClose: function() {
|
|
335
|
+
closeZXingScanContain();
|
|
322
336
|
oScanDialog.destroyContent();
|
|
323
337
|
oScanDialog.destroy();
|
|
324
338
|
oScanDialog = null;
|
|
@@ -342,15 +356,15 @@ sap.ui.define([
|
|
|
342
356
|
oDialogTitle = sTitle;
|
|
343
357
|
}
|
|
344
358
|
|
|
345
|
-
|
|
346
|
-
if (oCordovaScannerAPI || !oStatusModel.getProperty("/available")) {
|
|
347
|
-
oScanDialog.getModel().setProperty("/isNoScanner", false);
|
|
348
|
-
openBarcodeInputDialog();
|
|
349
|
-
} else if (isUserMediaAccessSupported() && oZXingScannerAPI) {
|
|
359
|
+
if (!oCordovaScannerAPI && isUserMediaAccessSupported()) {
|
|
350
360
|
openBarcodeScannerDialog();
|
|
351
361
|
} else {
|
|
352
|
-
|
|
353
|
-
|
|
362
|
+
if (oStatusModel.getProperty("/available")) {
|
|
363
|
+
oScanDialog.getModel().setProperty("/isNoScanner", false);
|
|
364
|
+
} else {
|
|
365
|
+
oScanDialog.getModel().setProperty("/isNoScanner", true);
|
|
366
|
+
}
|
|
367
|
+
openBarcodeInputDialog();
|
|
354
368
|
}
|
|
355
369
|
|
|
356
370
|
return oScanDialog;
|
|
@@ -443,6 +457,7 @@ sap.ui.define([
|
|
|
443
457
|
Log.warning("Started continous decode failed.");
|
|
444
458
|
if (typeof oScanDialogController.onFail === "function") {
|
|
445
459
|
oScanDialogController.onFail(err);
|
|
460
|
+
oScanDialog.getModel().setProperty("/isNoScanner", true);
|
|
446
461
|
openBarcodeInputDialog();
|
|
447
462
|
}
|
|
448
463
|
}
|
|
@@ -498,6 +513,7 @@ sap.ui.define([
|
|
|
498
513
|
if (oZXingScannerAPI) {
|
|
499
514
|
oZXingScannerAPI.reset();
|
|
500
515
|
oZXingScannerAPI.stopContinuousDecode();
|
|
516
|
+
oZXingScannerAPI.reader.reset();
|
|
501
517
|
}
|
|
502
518
|
}
|
|
503
519
|
|
|
@@ -509,10 +525,6 @@ sap.ui.define([
|
|
|
509
525
|
* Starts the bar code scanning process either showing the live input from the camera or displaying a dialog
|
|
510
526
|
* to enter the value directly if the bar code scanning feature is not available.
|
|
511
527
|
*
|
|
512
|
-
* <pre>
|
|
513
|
-
* sap.ndc.BarcodeScanner.scan(fnSuccess, fnFail, fnLiveUpdate, dialogTitle)
|
|
514
|
-
* </pre>
|
|
515
|
-
*
|
|
516
528
|
* The bar code scanning is done asynchronously. When it is triggered, this function returns without waiting for
|
|
517
529
|
* the scanning process to finish. The applications have to provide callback functions to react to the events of
|
|
518
530
|
* a successful scanning, an error during scanning, and the live input on the dialog.
|
|
@@ -523,21 +535,23 @@ sap.ui.define([
|
|
|
523
535
|
* dialog's input field. An example:
|
|
524
536
|
*
|
|
525
537
|
* <pre>
|
|
526
|
-
* sap.ndc
|
|
527
|
-
*
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
*
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
*
|
|
536
|
-
*
|
|
537
|
-
*
|
|
538
|
-
*
|
|
539
|
-
*
|
|
540
|
-
*
|
|
538
|
+
* sap.ui.require(["sap/ndc/BarcodeScanner"], function(BarcodeScanner) {
|
|
539
|
+
* BarcodeScanner.scan(
|
|
540
|
+
* function (mResult) {
|
|
541
|
+
* alert("We got a bar code\n" +
|
|
542
|
+
* "Result: " + mResult.text + "\n" +
|
|
543
|
+
* "Format: " + mResult.format + "\n" +
|
|
544
|
+
* "Cancelled: " + mResult.cancelled);
|
|
545
|
+
* },
|
|
546
|
+
* function (Error) {
|
|
547
|
+
* alert("Scanning failed: " + Error);
|
|
548
|
+
* },
|
|
549
|
+
* function (mParams) {
|
|
550
|
+
* alert("Value entered: " + mParams.newValue);
|
|
551
|
+
* },
|
|
552
|
+
* "Enter Product Bar Code"
|
|
553
|
+
* );
|
|
554
|
+
* });
|
|
541
555
|
* </pre>
|
|
542
556
|
*
|
|
543
557
|
* @param {function} [fnSuccess] Function to be called when the scanning is done or cancelled
|
|
@@ -577,10 +591,15 @@ sap.ui.define([
|
|
|
577
591
|
},
|
|
578
592
|
function (oEvent) {
|
|
579
593
|
Log.error("Barcode scanning failed.");
|
|
594
|
+
bReady = true;
|
|
580
595
|
if (typeof fnFail === "function") {
|
|
596
|
+
if (typeof oEvent === "string") {
|
|
597
|
+
var str = oEvent;
|
|
598
|
+
oEvent = {"text": str};
|
|
599
|
+
Log.debug("Change the type of oEvent from string to object");
|
|
600
|
+
}
|
|
581
601
|
fnFail(oEvent);
|
|
582
602
|
}
|
|
583
|
-
bReady = true;
|
|
584
603
|
}
|
|
585
604
|
);
|
|
586
605
|
} else {
|
|
@@ -30,7 +30,10 @@ sap.ui.define([],
|
|
|
30
30
|
oRm.write("<span");
|
|
31
31
|
oRm.writeControlData(oControl);
|
|
32
32
|
// we need to change the containing span tag's width instead of the button
|
|
33
|
-
oRm.
|
|
33
|
+
oRm.addStyle("display", "inline-block");
|
|
34
|
+
oRm.addStyle("width", oControl.getWidth());
|
|
35
|
+
oRm.writeStyles();
|
|
36
|
+
oRm.write(">");
|
|
34
37
|
oRm.renderControl(oControl.getAggregation("_btn"));
|
|
35
38
|
oRm.write("</span>");
|
|
36
39
|
};
|
package/src/sap/ndc/library.js
CHANGED
|
@@ -8839,6 +8839,11 @@
|
|
|
8839
8839
|
if (readers.length === 0) {
|
|
8840
8840
|
readers.push(new EAN13Reader());
|
|
8841
8841
|
// UPC-A is covered by EAN-13
|
|
8842
|
+
// ##### BEGIN: MODIFIED BY SAP
|
|
8843
|
+
// Add UPCAReader() into readers array
|
|
8844
|
+
// see https://github.com/zxing-js/library/pull/304
|
|
8845
|
+
readers.push(new UPCAReader());
|
|
8846
|
+
// ##### END: MODIFIED BY SAP
|
|
8842
8847
|
readers.push(new EAN8Reader());
|
|
8843
8848
|
readers.push(new UPCEReader());
|
|
8844
8849
|
}
|