mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 22:25:24 +00:00
Changed implementation and parameter of __barcodeChooseBackward to accept a format-like string; renamed retroCompatibility to backward
This commit is contained in:
18
index.js
18
index.js
@@ -400,7 +400,7 @@ class Pass {
|
|||||||
return Object.assign({
|
return Object.assign({
|
||||||
length: 4,
|
length: 4,
|
||||||
autocomplete: () => {},
|
autocomplete: () => {},
|
||||||
retroCompatibility: this.__barcodeChooseBackward.bind(this)
|
backward: this.__barcodeChooseBackward.bind(this)
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -465,21 +465,19 @@ class Pass {
|
|||||||
* property "barcode".
|
* property "barcode".
|
||||||
*
|
*
|
||||||
* @method __barcodeChooseRetroCompatibility
|
* @method __barcodeChooseRetroCompatibility
|
||||||
* @params {Number} index - the position in this.props
|
* @params {String} format - the format, or part of it, to be used
|
||||||
* @return {this}
|
* @return {this}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
__barcodeChooseBackward(index) {
|
__barcodeChooseBackward(format) {
|
||||||
if (typeof index !== "number") {
|
if (typeof format !== "string") {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index > this.props["barcodes"].length) {
|
let index = this.props["barcodes"].findIndex(b => b.format.toLowerCase().includes(format.toLowerCase()));
|
||||||
// resetting from left
|
|
||||||
index = index - this.props["barcodes"].length - 1;
|
if (index === -1) {
|
||||||
} else if (index < 0) {
|
return this;
|
||||||
// resetting from rigth
|
|
||||||
index = Math.abs(this.props["barcodes"].length - Math.abs(index));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.props["barcode"] = this.props["barcodes"][index];
|
this.props["barcode"] = this.props["barcodes"][index];
|
||||||
|
|||||||
Reference in New Issue
Block a user