support for flags in eventLineup edit

This commit is contained in:
2024-03-05 09:15:18 -06:00
parent 2f2f33ce74
commit 35d6eba599
5 changed files with 49 additions and 16 deletions

View File

@@ -150,7 +150,19 @@ exports.parsePositionLabel = (label) => {
positionFlags: null
}
}
const positionLabelWithoutFlags= label.replace(/(.*?)\s\[(.*?)\]/, "$1")
const positionFlags = label.replace(/(.*?)\s\[(.*?)\]/, "$2")
const pattern = /(?<pos>[A-Z0-9]+)(?:\s\[(?<flags>.[A-z,]+)\])?/g
const {pos, flags} = pattern.exec(label)?.groups || {}
const positionLabelWithoutFlags= pos
const positionFlags = flags?.split(',').map(f=>f.trim()) || []
return {positionLabelWithoutFlags, positionFlags}
}
}
exports.compilePositionLabel = (label, flags) => {
if (flags == null || flags == '' || flags.lengh == 0) {
return label
}
else {
const flags_set = new Set(flags.split(',').map(s=>s.trim()))
return `${label} [${Array.from(flags_set).sort().join(',')}]`
}
}