Add paper formats to copy shops

This commit is contained in:
pietervdvn 2022-07-08 15:37:31 +02:00
parent 4246221e8e
commit bb23bc0761
3 changed files with 461 additions and 913 deletions

File diff suppressed because it is too large Load diff

View file

@ -113,6 +113,57 @@
"email",
"phone",
"payment-options",
{
"id": "copyshop-print-sizes",
"condition": {
"or": [
"shop~.*copyshop.*",
"shop~.*stationary.*",
"service:print=yes"
]
},
"question": {
"en": "What paper formats does this shop offer?"
},
"multiAnswer": true,
"mappings": [
{
"if": "service:print:A4=yes",
"then": {
"en": "This shop can print on papers of size A4"
},
"ifnot": "service:print:A4=no"
},
{
"if": "service:print:A3=yes",
"then": {
"en": "This shop can print on papers of size A3"
},
"ifnot": "service:print:A3=no"
},
{
"if": "service:print:A2=yes",
"then": {
"en": "This shop can print on papers of size A2"
},
"ifnot": "service:print:A2=no"
},
{
"if": "service:print:A1=yes",
"then": {
"en": "This shop can print on papers of size A1"
},
"ifnot": "service:print:A1=no"
},
{
"if": "service:print:A0=yes",
"then": {
"en": "This shop can print on papers of size A0"
},
"ifnot": "service:print:A0=no"
}
]
},
"questions",
"reviews"
],

View file

@ -196,7 +196,7 @@ class LayerOverviewUtils {
}
main(args: string[]) {
const forceReload = args.some(a => a == "--force")
const licensePaths = new Set<string>()
@ -205,7 +205,7 @@ class LayerOverviewUtils {
}
const doesImageExist = new DoesImageExist(licensePaths, existsSync)
const sharedLayers = this.buildLayerIndex(doesImageExist, forceReload);
const recompiledThemes : string[] = []
const recompiledThemes: string[] = []
const sharedThemes = this.buildThemeIndex(doesImageExist, sharedLayers, recompiledThemes, forceReload)
writeFileSync("./assets/generated/known_layers_and_themes.json", JSON.stringify({
@ -216,7 +216,7 @@ class LayerOverviewUtils {
writeFileSync("./assets/generated/known_layers.json", JSON.stringify({layers: Array.from(sharedLayers.values())}))
if(recompiledThemes.length > 0) {
if (recompiledThemes.length > 0) {
// mapcomplete-changes shows an icon for each corresponding mapcomplete-theme
const iconsPerTheme =
Array.from(sharedThemes.values()).map(th => ({
@ -260,10 +260,14 @@ class LayerOverviewUtils {
skippedLayers.push(sharedLayer.id)
continue;
}
}
const parsed = JSON.parse(readFileSync(sharedLayerPath, "utf8"))
}
let parsed;
try {
parsed = JSON.parse(readFileSync(sharedLayerPath, "utf8"))
} catch (e) {
throw ("Could not parse or read file " + sharedLayerPath)
}
const context = "While building builtin layer " + sharedLayerPath
const fixed = prepLayer.convertStrict(parsed, context)
@ -283,6 +287,7 @@ class LayerOverviewUtils {
this.writeLayer(fixed)
}
console.log("Recompiled layers " + recompiledLayers.join(", ") + " and skipped " + skippedLayers.length + " layers")
@ -313,7 +318,7 @@ class LayerOverviewUtils {
const usedLayers = Array.from(LayerOverviewUtils.extractLayerIdsFrom(themeFile, false))
.map(id => LayerOverviewUtils.layerPath + id + ".json")
if (!forceReload && !this.shouldBeUpdated([themePath, ...usedLayers], targetPath)) {
fixed.set(themeFile.id, JSON.parse(readFileSync(LayerOverviewUtils.themePath+themeFile.id+".json", 'utf8')))
fixed.set(themeFile.id, JSON.parse(readFileSync(LayerOverviewUtils.themePath + themeFile.id + ".json", 'utf8')))
skippedThemes.push(themeFile.id)
continue;
}