Fix: fill in freeform value if already set

This commit is contained in:
Pieter Vander Vennet 2023-05-05 11:00:31 +02:00
parent f7eaec2243
commit e0527e9647
2 changed files with 7 additions and 13 deletions

View file

@ -19,7 +19,7 @@
$: { $: {
// The type changed -> reset some values // The type changed -> reset some values
validator = Validators.get(type) validator = Validators.get(type)
_value.setData("") _value.setData(value.data ?? "")
feedback = feedback?.setData(validator?.getFeedback(_value.data, getCountry)); feedback = feedback?.setData(validator?.getFeedback(_value.data, getCountry));
} }

View file

@ -27,13 +27,7 @@
export let layer: LayerConfig; export let layer: LayerConfig;
// Will be bound if a freeform is available // Will be bound if a freeform is available
let freeformInput = new UIEventSource<string>(undefined); let freeformInput = new UIEventSource<string>(tags?.[config.freeform?.key]);
onDestroy(tags.addCallbackAndRunD(tags => {
// initialize with the previous value
if (config.freeform?.key) {
freeformInput.setData(tags[config.freeform.key]);
}
}));
let selectedMapping: number = undefined; let selectedMapping: number = undefined;
let checkedMappings: boolean[]; let checkedMappings: boolean[];
$: { $: {
@ -44,20 +38,20 @@
return m.hideInAnswer.matchesProperties(tags.data) return m.hideInAnswer.matchesProperties(tags.data)
}) })
// We received a new config -> reinit // We received a new config -> reinit
console.log("Initing checkedMappings for", config)
if (config.mappings?.length > 0 && (checkedMappings === undefined || checkedMappings?.length < config.mappings.length)) { if (config.mappings?.length > 0 && (checkedMappings === undefined || checkedMappings?.length < config.mappings.length)) {
checkedMappings = [...config.mappings.map(_ => false), false /*One element extra in case a freeform value is added*/]; checkedMappings = [...config.mappings.map(_ => false), false /*One element extra in case a freeform value is added*/];
} }
if (config.freeform?.key) {
freeformInput.setData(tags.data[config.freeform.key]);
}else{
freeformInput.setData(undefined) freeformInput.setData(undefined)
} }
}
let selectedTags: TagsFilter = undefined; let selectedTags: TagsFilter = undefined;
let mappings: Mapping[] = config?.mappings; let mappings: Mapping[] = config?.mappings;
let searchTerm: Store<string> = new UIEventSource("") let searchTerm: Store<string> = new UIEventSource("")
$:{
console.log("Seachterm:", $searchTerm)
}
$: { $: {
try { try {