forked from MapComplete/MapComplete
Workaround for upstream issue: always use 'opening_hours' as using ome keys crashes the OH-parser
This commit is contained in:
parent
23ae9d39c8
commit
1db54f3c8e
1 changed files with 12 additions and 6 deletions
|
@ -27,13 +27,19 @@ export default class OpeningHoursVisualization extends Toggle {
|
||||||
const tagsDirect = tags.data;
|
const tagsDirect = tags.data;
|
||||||
const ohTable = new VariableUiElement(tags
|
const ohTable = new VariableUiElement(tags
|
||||||
.map(tags => {
|
.map(tags => {
|
||||||
const value : string = tags[key];
|
const value: string = tags[key];
|
||||||
if(value.startsWith(prefix) && value.endsWith(postfix)){
|
if (value === undefined) {
|
||||||
return value.substring(prefix.length, value.length - postfix.length)
|
return undefined
|
||||||
|
}
|
||||||
|
if (value.startsWith(prefix) && value.endsWith(postfix)) {
|
||||||
|
return value.substring(prefix.length, value.length - postfix.length).trim()
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}) // This mapping will absorb all other changes to tags in order to prevent regeneration
|
}) // This mapping will absorb all other changes to tags in order to prevent regeneration
|
||||||
.map(ohtext => {
|
.map(ohtext => {
|
||||||
|
if (ohtext === undefined) {
|
||||||
|
return new FixedUiElement("No opening hours defined with key " + key).SetClass("alert")
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
// noinspection JSPotentiallyInvalidConstructorUsage
|
// noinspection JSPotentiallyInvalidConstructorUsage
|
||||||
const oh = new opening_hours(ohtext, {
|
const oh = new opening_hours(ohtext, {
|
||||||
|
@ -41,12 +47,12 @@ export default class OpeningHoursVisualization extends Toggle {
|
||||||
lon: tagsDirect._lon,
|
lon: tagsDirect._lon,
|
||||||
address: {
|
address: {
|
||||||
country_code: tagsDirect._country
|
country_code: tagsDirect._country
|
||||||
}
|
},
|
||||||
}, {tag_key: key});
|
}, {tag_key: "opening_hours"});
|
||||||
|
|
||||||
return OpeningHoursVisualization.CreateFullVisualisation(oh)
|
return OpeningHoursVisualization.CreateFullVisualisation(oh)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.warn(e, e.stack);
|
||||||
return new Combine([Translations.t.general.opening_hours.error_loading,
|
return new Combine([Translations.t.general.opening_hours.error_loading,
|
||||||
new Toggle(
|
new Toggle(
|
||||||
new FixedUiElement(e).SetClass("subtle"),
|
new FixedUiElement(e).SetClass("subtle"),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue