Fix loading of tag renderings

This commit is contained in:
Pieter Vander Vennet 2020-10-17 03:36:20 +02:00
parent e0694fee9d
commit 5b25953127
2 changed files with 14 additions and 6 deletions

View file

@ -20,6 +20,8 @@ import {UserDetails} from "../../Logic/Osm/OsmConnection";
import State from "../../State";
import {FixedUiElement} from "../Base/FixedUiElement";
import ValidatedTextField from "../Input/ValidatedTextField";
import {TagRendering} from "../Popup/TagRendering";
import {Utils} from "../../Utils";
/**
* Shows the configuration for a single layer
@ -118,13 +120,22 @@ export default class LayerPanel extends UIElement {
this.titleRendering = popupTitleRendering;
this.registerTagRendering(popupTitleRendering);
const renderings = config.map(config => {
const layer = config.layers[index] as LayerConfigJson;
// @ts-ignore
const renderings : TagRenderingConfigJson[] = layer.tagRenderings ;
return renderings;
});
const tagRenderings = new MultiInput<TagRenderingConfigJson>("Add a tag rendering/question",
() => ({}),
() => {
const tagPanel = new TagRenderingPanel(languages, currentlySelected, userDetails)
self.registerTagRendering(tagPanel);
return tagPanel;
}, undefined, {allowMovement:true});
}, renderings,
{allowMovement: true});
tagRenderings.GetValue().addCallback(
tagRenderings => {
(config.data.layers[index] as LayerConfigJson).tagRenderings = tagRenderings;

View file

@ -29,7 +29,6 @@ export default class OpeningHoursInput extends InputElement<string> {
const leftoverRules = value.map<string[]>(str => {
console.log("Leftovers?",str)
if (str === undefined) {
return []
}
@ -50,7 +49,6 @@ export default class OpeningHoursInput extends InputElement<string> {
const rulesFromOhPicker = value.map(OH.Parse);
const ph = value.map<string>(str => {
console.log("PH RULE?", ph)
if (str === undefined) {
return ""
}
@ -65,7 +63,6 @@ export default class OpeningHoursInput extends InputElement<string> {
this._phSelector = new PublicHolidayInput(ph);
function update() {
console.log("UPdating")
let rules = OH.ToString(rulesFromOhPicker.data);
if (leftoverRules.data.length != 0) {
rules += ";" + leftoverRules.data.join(";")