mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 22:25:24 +00:00
Added some comments, fixed barcode problem when not valid, refactored a condition
This commit is contained in:
13
index.js
13
index.js
@@ -298,17 +298,13 @@ class Pass {
|
|||||||
data = [data];
|
data = [data];
|
||||||
}
|
}
|
||||||
|
|
||||||
let valid = data.filter(b => {
|
let valid = data.filter(b => b instanceof Object && schema.isValid(b, "barcode"));
|
||||||
if (!(b instanceof Object)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return schema.isValid(b, "barcode");
|
this.props["barcode"] = valid[0] || undefined;
|
||||||
});
|
|
||||||
|
|
||||||
this.props["barcode"] = valid[0] || {};
|
|
||||||
this.props["barcodes"] = valid || [];
|
this.props["barcodes"] = valid || [];
|
||||||
|
|
||||||
|
// I bind "this" to get a clean this when returning from the methods
|
||||||
|
|
||||||
return Object.assign({
|
return Object.assign({
|
||||||
length: valid.length,
|
length: valid.length,
|
||||||
autocomplete: this.__barcodeAutocomplete.bind(this),
|
autocomplete: this.__barcodeAutocomplete.bind(this),
|
||||||
@@ -390,6 +386,7 @@ class Pass {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Checking which object among barcodes has the same format of the specified one.
|
||||||
let index = this.props["barcodes"].findIndex(b => b.format.toLowerCase().includes(format.toLowerCase()));
|
let index = this.props["barcodes"].findIndex(b => b.format.toLowerCase().includes(format.toLowerCase()));
|
||||||
|
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user