diff --git a/scripts/downloadNsiLogos.ts b/scripts/downloadNsiLogos.ts index 4abb89b415..040f9aebad 100644 --- a/scripts/downloadNsiLogos.ts +++ b/scripts/downloadNsiLogos.ts @@ -4,22 +4,12 @@ import * as nsiWD from "../node_modules/name-suggestion-index/dist/wikidata.min. import { existsSync, writeFileSync } from "fs" import ScriptUtils from "./ScriptUtils" import { Utils } from "../src/Utils" -import { WikimediaImageProvider } from "../src/Logic/ImageProviders/WikimediaImageProvider" -import { renameSync } from "node:fs" -export default class DownloadNsiLogos extends Script { +class DownloadNsiLogos extends Script { constructor() { super("Downloads all images of the NSI") } - private async getWikimediaUrl(startUrl: string) { - if (!startUrl) { - return startUrl - } - - - } - private async downloadLogo(nsiItem: NSIItem, type: string, basePath: string) { try { return await this.downloadLogoUnsafe(nsiItem, type, basePath) @@ -71,8 +61,8 @@ export default class DownloadNsiLogos extends Script { } if ((logos.wikidata).toLowerCase().endsWith(".svg")) { console.log("Written SVG", path) - if(!path.endsWith(".svg")){ - throw "Undetected svg path:"+logos.wikidata + if (!path.endsWith(".svg")) { + throw "Undetected svg path:" + logos.wikidata } writeFileSync(path, dloaded["content"], "utf8") return true @@ -90,8 +80,12 @@ export default class DownloadNsiLogos extends Script { } - async main(args: string[]): Promise { - const type = "brand" + async main(): Promise { + await this.downloadFor("operator") + await this.downloadFor("brand") + } + + async downloadFor(type: "brand" | "operator"): Promise { const items = NameSuggestionIndex.allPossible(type) const basePath = "./public/assets/data/nsi/logos/" let downloadCount = 0 diff --git a/src/Models/ThemeConfig/TagRenderingConfig.ts b/src/Models/ThemeConfig/TagRenderingConfig.ts index 613546a943..c5a1bca751 100644 --- a/src/Models/ThemeConfig/TagRenderingConfig.ts +++ b/src/Models/ThemeConfig/TagRenderingConfig.ts @@ -883,7 +883,8 @@ export class TagRenderingConfigUtils { return config } const clone: TagRenderingConfig = Object.create(config) - clone.mappings = [...clone.mappings ?? [], ...extraMappings] + const oldMappingsCloned = clone.mappings?.map(m => ({ ...m, priorityIf: m.priorityIf ?? TagUtils.Tag("id~*") })) ?? [] + clone.mappings = [...oldMappingsCloned, ...extraMappings] return clone }) } diff --git a/src/UI/BigComponents/SelectedElementView.svelte b/src/UI/BigComponents/SelectedElementView.svelte index 09ca04744d..17e24e44fe 100644 --- a/src/UI/BigComponents/SelectedElementView.svelte +++ b/src/UI/BigComponents/SelectedElementView.svelte @@ -11,6 +11,7 @@ import UserRelatedState from "../../Logic/State/UserRelatedState" import Delete_icon from "../../assets/svg/Delete_icon.svelte" import BackButton from "../Base/BackButton.svelte" + import TagRenderingEditableDynamic from "../Popup/TagRendering/TagRenderingEditableDynamic.svelte" export let state: SpecialVisualizationState export let selectedElement: Feature @@ -68,7 +69,7 @@ tabindex="-1" > {#each $knownTagRenderings as config (config.id)} - { - - map.resize() - map.fitBounds(bbox.toLngLat(), { - padding: { top: 10, bottom: 10, left: 10, right: 10 }, - animate: false - }) + map.resize() + map.fitBounds(bbox.toLngLat(), { + padding: { top: 10, bottom: 10, left: 10, right: 10 }, + animate: false + }) }) } diff --git a/src/UI/OpeningHours/OpeningHoursVisualization.ts b/src/UI/OpeningHours/OpeningHoursVisualization.ts index b705fed39c..e7078f7204 100644 --- a/src/UI/OpeningHours/OpeningHoursVisualization.ts +++ b/src/UI/OpeningHours/OpeningHoursVisualization.ts @@ -55,7 +55,7 @@ export default class OpeningHoursVisualization extends Toggle { applicableWeek.startingMonday ) Locale.language.mapD((lng) => { - console.log("Setting OH description to", lng, textual) + console.debug("Setting OH description to", lng, textual) vis.ConstructElement().ariaLabel = textual.textFor(lng) }) return vis diff --git a/src/UI/Popup/TagRendering/Questionbox.svelte b/src/UI/Popup/TagRendering/Questionbox.svelte index b20305d3e3..2265a106a0 100644 --- a/src/UI/Popup/TagRendering/Questionbox.svelte +++ b/src/UI/Popup/TagRendering/Questionbox.svelte @@ -3,16 +3,16 @@ * Shows all questions for which the answers are unknown. * The questions can either be shown all at once or one at a time (in which case they can be skipped) */ - import TagRenderingConfig, { TagRenderingConfigUtils } from "../../../Models/ThemeConfig/TagRenderingConfig" - import { Store, UIEventSource } from "../../../Logic/UIEventSource" + import TagRenderingConfig from "../../../Models/ThemeConfig/TagRenderingConfig" + import { UIEventSource } from "../../../Logic/UIEventSource" import type { Feature } from "geojson" import type { SpecialVisualizationState } from "../../SpecialVisualization" import LayerConfig from "../../../Models/ThemeConfig/LayerConfig" - import TagRenderingQuestion from "./TagRenderingQuestion.svelte" import Tr from "../../Base/Tr.svelte" import Translations from "../../i18n/Translations.js" import { Utils } from "../../../Utils" import { onDestroy } from "svelte" + import TagRenderingQuestion from "./TagRenderingQuestion.svelte" import TagRenderingQuestionDynamic from "./TagRenderingQuestionDynamic.svelte" export let layer: LayerConfig @@ -26,7 +26,8 @@ export let onlyForLabels: string[] | undefined = undefined const _onlyForLabels = new Set(onlyForLabels) /** - * If set, only questions _not_ having these labels will be shown + * If set, only questions _not_ having these labels will be shown. + * This is used for a partial questionbox */ export let notForLabels: string[] | undefined = undefined const _notForLabels = new Set(notForLabels) @@ -41,14 +42,15 @@ } return true } + const baseQuestions = (layer.tagRenderings ?? [])?.filter( + (tr) => allowed(tr.labels) && tr.question !== undefined + ) let skippedQuestions = new UIEventSource>(new Set()) let questionboxElem: HTMLDivElement let questionsToAsk = tags.map( (tags) => { - const baseQuestions = (layer.tagRenderings ?? [])?.filter( - (tr) => allowed(tr.labels) && tr.question !== undefined - ) + const questionsToAsk: TagRenderingConfig[] = [] for (const baseQuestion of baseQuestions) { if (skippedQuestions.data.has(baseQuestion.id)) { diff --git a/src/UI/Popup/TagRendering/TagRenderingEditable.svelte b/src/UI/Popup/TagRendering/TagRenderingEditable.svelte index 635d97698a..50b7725b8d 100644 --- a/src/UI/Popup/TagRendering/TagRenderingEditable.svelte +++ b/src/UI/Popup/TagRendering/TagRenderingEditable.svelte @@ -11,7 +11,7 @@ import { Utils } from "../../../Utils" import { twMerge } from "tailwind-merge" import EditButton from "./EditButton.svelte" - import TagRenderingAnswerDynamic from "./TagRenderingAnswerDynamic.svelte" + import TagRenderingAnswer from "./TagRenderingAnswer.svelte" export let config: TagRenderingConfig export let tags: UIEventSource> @@ -100,7 +100,7 @@ {:else}
- + - +
{/if} diff --git a/src/UI/Popup/TagRendering/TagRenderingEditableDynamic.svelte b/src/UI/Popup/TagRendering/TagRenderingEditableDynamic.svelte new file mode 100644 index 0000000000..585d76bf97 --- /dev/null +++ b/src/UI/Popup/TagRendering/TagRenderingEditableDynamic.svelte @@ -0,0 +1,26 @@ + + + diff --git a/src/UI/Popup/TagRendering/TagRenderingQuestion.svelte b/src/UI/Popup/TagRendering/TagRenderingQuestion.svelte index 7fed07be37..e5cf6b804e 100644 --- a/src/UI/Popup/TagRendering/TagRenderingQuestion.svelte +++ b/src/UI/Popup/TagRendering/TagRenderingQuestion.svelte @@ -3,7 +3,6 @@ import type { SpecialVisualizationState } from "../../SpecialVisualization" import Tr from "../../Base/Tr.svelte" import type { Feature } from "geojson" - import type { Mapping } from "../../../Models/ThemeConfig/TagRenderingConfig" import TagRenderingConfig from "../../../Models/ThemeConfig/TagRenderingConfig" import { TagsFilter } from "../../../Logic/Tags/TagsFilter" import FreeformInput from "./FreeformInput.svelte" @@ -59,7 +58,6 @@ */ let checkedMappings: boolean[] - let mappings: Mapping[] = config?.mappings ?? [] let searchTerm: UIEventSource = new UIEventSource("") let dispatch = createEventDispatcher<{ @@ -74,7 +72,7 @@ */ function initialize(tgs: Record, confg: TagRenderingConfig): void { - mappings = confg.mappings?.filter((m) => { + const mappings = confg.mappings?.filter((m) => { if (typeof m.hideInAnswer === "boolean") { return !m.hideInAnswer } @@ -169,7 +167,7 @@ onDestroy( freeformInput.subscribe((freeformValue) => { - if (!mappings || mappings?.length == 0 || config.freeform?.key === undefined) { + if (!config?.mappings || config?.mappings?.length == 0 || config.freeform?.key === undefined) { return } // If a freeform value is given, mark the 'mapping' as marked @@ -178,11 +176,11 @@ // Initialization didn't yet run return } - checkedMappings[mappings.length] = freeformValue?.length > 0 + checkedMappings[config?.mappings.length] = freeformValue?.length > 0 return } if (freeformValue?.length > 0) { - selectedMapping = mappings.length + selectedMapping = config.mappings.length } }) ) @@ -192,7 +190,7 @@ allowDeleteOfFreeform && $freeformInput === undefined && $freeformInputUnvalidated === "" && - (mappings?.length ?? 0) === 0 + (config?.mappings?.length ?? 0) === 0 ) { selectedTags = new Tag(config.freeform.key, "") } else { @@ -353,7 +351,7 @@ - {#if config.freeform?.key && !(mappings?.length > 0)} + {#if config.freeform?.key && !(config?.mappings?.length > 0)} onSave()} /> - {:else if mappings !== undefined && !config.multiAnswer} + {:else if config.mappings !== undefined && !config.multiAnswer}
{#each config.mappings as mapping, i (mapping.then)} @@ -416,7 +414,7 @@ {/if}
- {:else if mappings !== undefined && config.multiAnswer} + {:else if config.mappings !== undefined && config.multiAnswer}
{#each config.mappings as mapping, i (mapping.then)} @@ -480,7 +478,7 @@ - {#if allowDeleteOfFreeform && (mappings?.length ?? 0) === 0 && $freeformInput === undefined && $freeformInputUnvalidated === ""} + {#if allowDeleteOfFreeform && (config?.mappings?.length ?? 0) === 0 && $freeformInput === undefined && $freeformInputUnvalidated === ""}