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 State from "../../State";
import {FixedUiElement} from "../Base/FixedUiElement"; import {FixedUiElement} from "../Base/FixedUiElement";
import ValidatedTextField from "../Input/ValidatedTextField"; import ValidatedTextField from "../Input/ValidatedTextField";
import {TagRendering} from "../Popup/TagRendering";
import {Utils} from "../../Utils";
/** /**
* Shows the configuration for a single layer * Shows the configuration for a single layer
@ -113,18 +115,27 @@ export default class LayerPanel extends UIElement {
description: "This is the rendering shown as title in the popup for this element", description: "This is the rendering shown as title in the popup for this element",
disableQuestions: true disableQuestions: true
}); });
new SingleSetting(config, popupTitleRendering, ["layers", index, "title"], "Popup title", "This is the rendering shown as title in the popup"); new SingleSetting(config, popupTitleRendering, ["layers", index, "title"], "Popup title", "This is the rendering shown as title in the popup");
this.titleRendering = popupTitleRendering; this.titleRendering = popupTitleRendering;
this.registerTagRendering(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 tagRenderings = new MultiInput<TagRenderingConfigJson>("Add a tag rendering/question",
() => ({}), () => ({}),
() => { () => {
const tagPanel = new TagRenderingPanel(languages, currentlySelected, userDetails) const tagPanel = new TagRenderingPanel(languages, currentlySelected, userDetails)
self.registerTagRendering(tagPanel); self.registerTagRendering(tagPanel);
return tagPanel; return tagPanel;
}, undefined, {allowMovement:true}); }, renderings,
{allowMovement: true});
tagRenderings.GetValue().addCallback( tagRenderings.GetValue().addCallback(
tagRenderings => { tagRenderings => {
(config.data.layers[index] as LayerConfigJson).tagRenderings = 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 => { const leftoverRules = value.map<string[]>(str => {
console.log("Leftovers?",str)
if (str === undefined) { if (str === undefined) {
return [] return []
} }
@ -50,7 +49,6 @@ export default class OpeningHoursInput extends InputElement<string> {
const rulesFromOhPicker = value.map(OH.Parse); const rulesFromOhPicker = value.map(OH.Parse);
const ph = value.map<string>(str => { const ph = value.map<string>(str => {
console.log("PH RULE?", ph)
if (str === undefined) { if (str === undefined) {
return "" return ""
} }
@ -65,7 +63,6 @@ export default class OpeningHoursInput extends InputElement<string> {
this._phSelector = new PublicHolidayInput(ph); this._phSelector = new PublicHolidayInput(ph);
function update() { function update() {
console.log("UPdating")
let rules = OH.ToString(rulesFromOhPicker.data); let rules = OH.ToString(rulesFromOhPicker.data);
if (leftoverRules.data.length != 0) { if (leftoverRules.data.length != 0) {
rules += ";" + leftoverRules.data.join(";") rules += ";" + leftoverRules.data.join(";")