diff --git a/assets/layers/questions/license_info.json b/assets/layers/questions/license_info.json
index 8985470b30..aa446c69d2 100644
--- a/assets/layers/questions/license_info.json
+++ b/assets/layers/questions/license_info.json
@@ -100,6 +100,14 @@
"https://www.onlinewebfonts.com/icon/464507"
]
},
+ {
+ "path": "open24_7.svg",
+ "license": "CC0-1.0",
+ "authors": [
+ "Pieter Vander Vennet"
+ ],
+ "sources": []
+ },
{
"path": "payment_card.svg",
"license": "CC0-1.0",
diff --git a/assets/layers/questions/open24_7.svg b/assets/layers/questions/open24_7.svg
new file mode 100644
index 0000000000..174aa82354
--- /dev/null
+++ b/assets/layers/questions/open24_7.svg
@@ -0,0 +1,106 @@
+
+
+
+
diff --git a/assets/layers/questions/open24_7.svg.license b/assets/layers/questions/open24_7.svg.license
new file mode 100644
index 0000000000..2452bee1e8
--- /dev/null
+++ b/assets/layers/questions/open24_7.svg.license
@@ -0,0 +1,2 @@
+SPDX-FileCopyrightText: Pieter Vander Vennet
+SPDX-License-Identifier: CC0
\ No newline at end of file
diff --git a/assets/layers/questions/questions.json b/assets/layers/questions/questions.json
index d9b364b52a..6c61a8e2fd 100644
--- a/assets/layers/questions/questions.json
+++ b/assets/layers/questions/questions.json
@@ -753,6 +753,7 @@
"+mappings": [
{
"if": "opening_hours=24/7",
+ "icon": "./assets/layers/questions/open24_7.svg",
"then": {
"en": "24/7 opened (including holidays)",
"de": "durchgehend geƶffnet (auch an Feiertagen)",
@@ -771,6 +772,18 @@
]
}
},
+ {
+ "id": "opening_hours_24_7_default",
+ "builtin": "opening_hours_24_7",
+ "override": {
+ "mappings": [
+ {
+ "#": "The first mapping is 'opening_hours=24/7', we amend this to also show if no info is known",
+ "alsoShowIf": "opening_hours="
+ }
+ ]
+ }
+ },
{
"id": "opening_hours_by_appointment",
"builtin": "opening_hours",
diff --git a/scripts/generateLayerOverview.ts b/scripts/generateLayerOverview.ts
index 6d3f719a51..154bbf2fcb 100644
--- a/scripts/generateLayerOverview.ts
+++ b/scripts/generateLayerOverview.ts
@@ -44,6 +44,7 @@ class ParseLayer extends Conversion<
> {
private readonly _prepareLayer: PrepareLayer
private readonly _doesImageExist: DoesImageExist
+ private readonly _options: { readonly addExpandedTagRenderingsToContext?: boolean }
constructor(prepareLayer: PrepareLayer, doesImageExist: DoesImageExist) {
super("Parsed a layer from file, validates it", [], "ParseLayer")
@@ -287,9 +288,11 @@ class LayerOverviewUtils extends Script {
tagRenderings: bootstrapTagRenderings,
sharedLayers: null,
publicLayers: null,
+ }, {
+ addTagRenderingsToContext: true
})
- let path = "assets/layers/questions/questions.json"
+ const path = "assets/layers/questions/questions.json"
const sharedQuestions = this.parseLayer(doesImageExist, prepareLayer, path).raw
const dict = new Map()
diff --git a/src/Models/ThemeConfig/Conversion/ExpandRewrite.ts b/src/Models/ThemeConfig/Conversion/ExpandRewrite.ts
index 7b3f11c17e..4cc6c0f25d 100644
--- a/src/Models/ThemeConfig/Conversion/ExpandRewrite.ts
+++ b/src/Models/ThemeConfig/Conversion/ExpandRewrite.ts
@@ -258,11 +258,11 @@ export class ExpandRewrite extends Conversion, T[
}
}
- let renderings = Array.isArray(rewrite.renderings)
+ const renderings = Array.isArray(rewrite.renderings)
? rewrite.renderings
: [rewrite.renderings]
for (let i = 0; i < keysToRewrite.into.length; i++) {
- let ts: T[] = Utils.Clone(renderings)
+ const ts: T[] = Utils.Clone(renderings)
for (const tx of ts) {
let t = tx
const sourceKeysToIgnore: string[] = []
diff --git a/src/Models/ThemeConfig/Conversion/PrepareLayer.ts b/src/Models/ThemeConfig/Conversion/PrepareLayer.ts
index 767d9d4129..1db4fde751 100644
--- a/src/Models/ThemeConfig/Conversion/PrepareLayer.ts
+++ b/src/Models/ThemeConfig/Conversion/PrepareLayer.ts
@@ -161,7 +161,9 @@ class ExpandTagRendering extends Conversion<
private readonly _options: {
/* If true, will copy the 'osmSource'-tags into the condition */
applyCondition?: true | boolean
- noHardcodedStrings?: false | boolean
+ noHardcodedStrings?: false | boolean,
+ addToContext?: false | boolean
+
}
constructor(
@@ -169,11 +171,13 @@ class ExpandTagRendering extends Conversion<
self: LayerConfigJson,
options?: {
applyCondition?: true | boolean
- noHardcodedStrings?: false | boolean
+ noHardcodedStrings?: false | boolean,
+ // If set, a question will be added to the 'sharedTagRenderings'. Should only be used for 'questions.json'
+ addToContext?: false | boolean
}
) {
super(
- "Converts a tagRenderingSpec into the full tagRendering, e.g. by substituting the tagRendering by the shared-question",
+ "Converts a tagRenderingSpec into the full tagRendering, e.g. by substituting the tagRendering by the shared-question and reusing the builtins",
[],
"ExpandTagRendering"
)
@@ -204,8 +208,17 @@ class ExpandTagRendering extends Conversion<
if (typeof tr === "string" || tr["builtin"] !== undefined) {
const stable = this.convert(tr, ctx.inOperation("recursive_resolve"))
result.push(...stable)
+ if(this._options?.addToContext){
+ for (const tr of stable) {
+ this._state.tagRenderings?.set(tr.id, tr)
+ }
+ }
} else {
result.push(tr)
+ if(this._options?.addToContext){
+ this._state.tagRenderings?.set(tr["id"], tr)
+ }
+
}
}
@@ -220,7 +233,7 @@ class ExpandTagRendering extends Conversion<
}
const result: TagRenderingConfigJson[] = []
for (const tagRenderingConfigJson of direct) {
- let nm: string | string[] | undefined = tagRenderingConfigJson["builtin"]
+ const nm: string | string[] | undefined = tagRenderingConfigJson["builtin"]
if (nm !== undefined) {
let indirect: TagRenderingConfigJson[]
if (typeof nm === "string") {
@@ -1261,12 +1274,14 @@ export class AutoTitleIcon extends DesugaringStep {
}
export class PrepareLayer extends Fuse {
- constructor(state: DesugaringContext) {
+ constructor(state: DesugaringContext, options?: {addTagRenderingsToContext?: false | boolean}) {
super(
"Fully prepares and expands a layer for the LayerConfig.",
new On("tagRenderings", new Each(new RewriteSpecial())),
new On("tagRenderings", new Concat(new ExpandRewrite()).andThenF(Utils.Flatten)),
- new On("tagRenderings", (layer) => new Concat(new ExpandTagRendering(state, layer))),
+ new On("tagRenderings", (layer) => new Concat(new ExpandTagRendering(state, layer, {
+ addToContext: options?.addTagRenderingsToContext ?? false
+ }))),
new On("tagRenderings", new Each(new DetectInline())),
new AddQuestionBox(),
new AddEditingElements(state),