forked from MapComplete/MapComplete
Fix: fix validation of question input; remove some obsolete logging; stabilize output of generate:translations wrt newlines
This commit is contained in:
parent
755f905c36
commit
1f39ba9ab5
26 changed files with 7328 additions and 71 deletions
|
@ -177,6 +177,7 @@ export default class MoveWizard extends Toggle {
|
|||
|
||||
state.featureProperties.getStore(id).ping()
|
||||
currentStep.setData("moved")
|
||||
state.mapProperties.location.setData(loc)
|
||||
})
|
||||
const zoomInFurhter = t.zoomInFurther.SetClass("alert block m-6")
|
||||
return new Combine([
|
||||
|
|
|
@ -10,6 +10,8 @@ import Lazy from "../Base/Lazy"
|
|||
import { OsmServiceState } from "../../Logic/Osm/OsmConnection"
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This element is getting stripped and is not used anymore
|
||||
* Generates all the questions, one by one
|
||||
*/
|
||||
export default class QuestionBox extends VariableUiElement {
|
||||
|
|
|
@ -19,17 +19,20 @@
|
|||
|
||||
let dispatch = createEventDispatcher<{ "selected" }>();
|
||||
onDestroy(value.addCallbackD(() => {dispatch("selected")}))
|
||||
function getCountry() {
|
||||
return tags.data["_country"]
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="inline-flex flex-col">
|
||||
|
||||
{#if config.freeform.inline}
|
||||
<Inline key={config.freeform.key} {tags} template={config.render}>
|
||||
<ValidatedInput {feedback} on:selected={() => dispatch("selected")}
|
||||
<ValidatedInput {feedback} {getCountry} on:selected={() => dispatch("selected")}
|
||||
type={config.freeform.type} {value}></ValidatedInput>
|
||||
</Inline>
|
||||
{:else}
|
||||
<ValidatedInput {feedback} on:selected={() => dispatch("selected")}
|
||||
<ValidatedInput {feedback} {getCountry} on:selected={() => dispatch("selected")}
|
||||
type={config.freeform.type} {value}></ValidatedInput>
|
||||
|
||||
{/if}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
import { ExclamationIcon } from "@rgossiaux/svelte-heroicons/solid";
|
||||
import SpecialTranslation from "./SpecialTranslation.svelte";
|
||||
import TagHint from "../TagHint.svelte";
|
||||
import Validators from "../../InputElement/Validators";
|
||||
|
||||
export let config: TagRenderingConfig;
|
||||
export let tags: UIEventSource<Record<string, string>>;
|
||||
|
@ -34,9 +35,12 @@
|
|||
let selectedMapping: number = undefined;
|
||||
let checkedMappings: boolean[];
|
||||
$: {
|
||||
// We received a new config -> reinit
|
||||
console.log("Initing checkedMappings for", config)
|
||||
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*/];
|
||||
}
|
||||
freeformInput.setData(undefined)
|
||||
}
|
||||
let selectedTags: TagsFilter = undefined;
|
||||
|
||||
|
@ -54,9 +58,10 @@
|
|||
$: {
|
||||
mappings = config.mappings?.filter(m => !mappingIsHidden(m));
|
||||
try {
|
||||
selectedTags = config?.constructChangeSpecification($freeformInput, selectedMapping, checkedMappings);
|
||||
let freeformInputValue = $freeformInput
|
||||
selectedTags = config?.constructChangeSpecification(freeformInputValue, selectedMapping, checkedMappings, tags.data);
|
||||
} catch (e) {
|
||||
console.debug("Could not calculate changeSpecification:", e);
|
||||
console.error("Could not calculate changeSpecification:", e);
|
||||
selectedTags = undefined;
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +104,7 @@
|
|||
}
|
||||
);
|
||||
freeformInput.setData(undefined);
|
||||
selectedMapping = 0;
|
||||
selectedMapping = undefined;
|
||||
selectedTags = undefined;
|
||||
|
||||
change.CreateChangeDescriptions().then(changes =>
|
||||
|
@ -139,14 +144,14 @@
|
|||
{#each config.mappings as mapping, i (mapping.then)}
|
||||
<!-- Even though we have a list of 'mappings' already, we still iterate over the list as to keep the original indices-->
|
||||
{#if !mappingIsHidden(mapping) }
|
||||
<label>
|
||||
<label class="flex">
|
||||
<input type="radio" bind:group={selectedMapping} name={"mappings-radio-"+config.id} value={i}>
|
||||
<TagRenderingMapping {mapping} {tags} {state} {selectedElement} {layer}></TagRenderingMapping>
|
||||
</label>
|
||||
{/if}
|
||||
{/each}
|
||||
{#if config.freeform?.key}
|
||||
<label>
|
||||
<label class="flex">
|
||||
<input type="radio" bind:group={selectedMapping} name={"mappings-radio-"+config.id}
|
||||
value={config.mappings.length}>
|
||||
<FreeformInput {config} {tags} feature={selectedElement} value={freeformInput}
|
||||
|
@ -159,13 +164,14 @@
|
|||
<div class="flex flex-col">
|
||||
{#each config.mappings as mapping, i (mapping.then)}
|
||||
{#if !mappingIsHidden(mapping)}
|
||||
<label>
|
||||
<label class="flex">
|
||||
<input type="checkbox" name={"mappings-checkbox-"+config.id+"-"+i} bind:checked={checkedMappings[i]}>
|
||||
<TagRenderingMapping {mapping} {tags} {state} {selectedElement}></TagRenderingMapping>
|
||||
</label>{/if}
|
||||
</label>
|
||||
{/if}
|
||||
{/each}
|
||||
{#if config.freeform?.key}
|
||||
<label>
|
||||
<label class="flex">
|
||||
<input type="checkbox" name={"mappings-checkbox-"+config.id+"-"+config.mappings.length}
|
||||
bind:checked={checkedMappings[config.mappings.length]}>
|
||||
<FreeformInput {config} {tags} feature={selectedElement} value={freeformInput}
|
||||
|
@ -184,7 +190,7 @@
|
|||
<Tr t={Translations.t.general.save}></Tr>
|
||||
</button>
|
||||
{:else }
|
||||
<div class="w-6 h-6">
|
||||
<div class="inline-flex w-6 h-6">
|
||||
<!-- Invalid value; show an inactive button or something like that-->
|
||||
<ExclamationIcon/>
|
||||
</div>
|
||||
|
|
|
@ -29,6 +29,7 @@ import { SearchablePillsSelector } from "../Input/SearchableMappingsSelector"
|
|||
import { OsmTags } from "../../Models/OsmFeature"
|
||||
|
||||
/**
|
||||
* @deprecated: getting stripped and getting ported
|
||||
* Shows the question element.
|
||||
* Note that the value _migh_ already be known, e.g. when selected or when changing the value
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue