Left pad card number for code
This commit is contained in:
parent
abc474c993
commit
6ce8f04f42
@ -1,5 +1,5 @@
|
|||||||
// TODO: should be defined in strange eons somewhere
|
// TODO: should be defined in strange eons somewhere
|
||||||
const pack_code = "420";
|
const pack_code = "42";
|
||||||
|
|
||||||
function renameSlot(slot) {
|
function renameSlot(slot) {
|
||||||
if (slot.startsWith('1 ')) {
|
if (slot.startsWith('1 ')) {
|
||||||
@ -76,6 +76,10 @@ function int_or_null(inp) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function leftPad(str, len, fill) {
|
||||||
|
return fill.repeat(Math.max(len - str.length, 0)) + str;
|
||||||
|
}
|
||||||
|
|
||||||
function build_card(component) {
|
function build_card(component) {
|
||||||
function substitute_tags(str) {
|
function substitute_tags(str) {
|
||||||
str = str.replace("<fullname>", String(component.getName()));
|
str = str.replace("<fullname>", String(component.getName()));
|
||||||
@ -86,7 +90,7 @@ function build_card(component) {
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
var code = pack_code + component.settings.get('CollectionNumber');
|
var code = pack_code + leftPad(String(component.settings.get('CollectionNumber')), 3, '0');
|
||||||
|
|
||||||
var card_data = {
|
var card_data = {
|
||||||
code: String(code),
|
code: String(code),
|
||||||
|
Loading…
Reference in New Issue
Block a user