Chore: housekeeping

This commit is contained in:
Pieter Vander Vennet 2025-06-19 21:55:28 +02:00
parent 4c001d718e
commit 6f7d94890a
29 changed files with 430 additions and 308 deletions

View file

@ -67,86 +67,86 @@
})
</script>
<MenuDrawerIndex {state} {onlyLink} >
<MenuDrawerIndex {state} {onlyLink}>
<!-- Theme related: documentation links, download, ... -->
<svelte:fragment slot="theme-tools">
{#if state.theme}
<SidebarUnit>
<h3>
<Tr t={t.aboutCurrentThemeTitle} />
</h3>
<SidebarUnit>
<h3>
<Tr t={t.aboutCurrentThemeTitle} />
</h3>
<Page {onlyLink} shown={pg.about_theme}>
<svelte:fragment slot="link">
<Marker size="h-7 w-7" icons={theme.icon} />
<Tr t={t.showIntroduction} />
</svelte:fragment>
<svelte:fragment slot="header">
<Marker size="h-8 w-8 mr-3" icons={theme.icon} />
<Tr t={theme.title} />
</svelte:fragment>
<ThemeIntroPanel {state} />
</Page>
<FilterPage {onlyLink} {state} />
<RasterLayerOverview {onlyLink} {state} />
<Page {onlyLink} shown={pg.share}>
<svelte:fragment slot="header">
<Share />
<Tr t={Translations.t.general.sharescreen.title} />
</svelte:fragment>
<ShareScreen {state} />
</Page>
{#if state.featureSwitches?.featureSwitchEnableExport}
<Page {onlyLink} shown={pg.download}>
<svelte:fragment slot="header">
<ArrowDownTray />
<Tr t={Translations.t.general.download.title} />
<Page {onlyLink} shown={pg.about_theme}>
<svelte:fragment slot="link">
<Marker size="h-7 w-7" icons={theme.icon} />
<Tr t={t.showIntroduction} />
</svelte:fragment>
<DownloadPanel {state} />
<svelte:fragment slot="header">
<Marker size="h-8 w-8 mr-3" icons={theme.icon} />
<Tr t={theme.title} />
</svelte:fragment>
<ThemeIntroPanel {state} />
</Page>
{/if}
{#if theme.official}
<a
class="flex"
href={"https://source.mapcomplete.org/MapComplete/MapComplete/src/branch/develop/Docs/Themes/" +
theme.id +
".md"}
target="_blank"
>
<DocumentMagnifyingGlass class="h-6 w-6" />
<Tr
t={Translations.t.general.attribution.openThemeDocumentation.Subs({
name: theme.title,
})}
/>
</a>
<FilterPage {onlyLink} {state} />
<a class="flex" href={Utils.OsmChaLinkFor(31, theme.id)} target="_blank">
<QueueList class="h-6 w-6" />
<Tr t={Translations.t.general.attribution.openOsmcha.Subs({ theme: theme.title })} />
</a>
<a
class="flex"
href={`./statistics.html?filter-mapcomplete-changes-theme-search={"search"%3A"${theme.id}"}`}
target="_blank"
>
<ChartBar class="h-6 w-6" />
<Tr t={Translations.t.general.attribution.openStatistics.Subs({ theme: theme.title })} />
</a>
{/if}
</SidebarUnit>
{/if}
<RasterLayerOverview {onlyLink} {state} />
<Page {onlyLink} shown={pg.share}>
<svelte:fragment slot="header">
<Share />
<Tr t={Translations.t.general.sharescreen.title} />
</svelte:fragment>
<ShareScreen {state} />
</Page>
{#if state.featureSwitches?.featureSwitchEnableExport}
<Page {onlyLink} shown={pg.download}>
<svelte:fragment slot="header">
<ArrowDownTray />
<Tr t={Translations.t.general.download.title} />
</svelte:fragment>
<DownloadPanel {state} />
</Page>
{/if}
{#if theme.official}
<a
class="flex"
href={"https://source.mapcomplete.org/MapComplete/MapComplete/src/branch/develop/Docs/Themes/" +
theme.id +
".md"}
target="_blank"
>
<DocumentMagnifyingGlass class="h-6 w-6" />
<Tr
t={Translations.t.general.attribution.openThemeDocumentation.Subs({
name: theme.title,
})}
/>
</a>
<a class="flex" href={Utils.OsmChaLinkFor(31, theme.id)} target="_blank">
<QueueList class="h-6 w-6" />
<Tr t={Translations.t.general.attribution.openOsmcha.Subs({ theme: theme.title })} />
</a>
<a
class="flex"
href={`./statistics.html?filter-mapcomplete-changes-theme-search={"search"%3A"${theme.id}"}`}
target="_blank"
>
<ChartBar class="h-6 w-6" />
<Tr
t={Translations.t.general.attribution.openStatistics.Subs({ theme: theme.title })}
/>
</a>
{/if}
</SidebarUnit>
{/if}
</svelte:fragment>
<!-- Other links and tools for the given location: open iD/JOSM; community index, ... -->
<svelte:fragment slot="location-tools">
<svelte:fragment slot="location-tools">
{#if state.mapProperties?.location}
<SidebarUnit>
<h3>
@ -175,6 +175,4 @@
</SidebarUnit>
{/if}
</svelte:fragment>
</MenuDrawerIndex>

View file

@ -205,9 +205,8 @@
<LanguagePicker />
</SidebarUnit>
<slot name="theme-tools"/>
<slot name="location-tools"/>
<slot name="theme-tools" />
<slot name="location-tools" />
<!-- About MC: various outward links, legal info, ... -->
<SidebarUnit>

View file

@ -163,7 +163,11 @@
<UserCircleIcon class={clss} {color} />
{:else if icon === "wifi"}
<WifiIcon class={"m-0 " + clss} {color} />
{:else if Utils.isEmoji(icon)}<span style={`font-size: ${emojiHeight}; line-height: ${emojiHeight}`}> {icon}</span>
{:else if Utils.isEmoji(icon)}<span
style={`font-size: ${emojiHeight}; line-height: ${emojiHeight}`}
>
{icon}
</span>
{:else}<img class={clss ?? "h-full w-full"} src={icon} aria-hidden="true" alt="" />
{/if}
{/if}

View file

@ -97,4 +97,3 @@ export class MultiApplyExecutor {
}
}
}

View file

@ -20,17 +20,20 @@
</script>
<LoginToggle {state} ignoreLoading>
{#if $featuresToApplyOn.length > 0}
{#if p.autoapply}
<div class="border-interactive p-2 low-interaction">
<div class="border-interactive low-interaction p-2">
<div class="flex items-center gap-x-2">
<ExclamationTriangle class="w-16" />
<div>{p.text}</div>
</div>
<div class="subtle text-sm">
<Tr t={t.autoApply.Subs({attr_names: keysToApply.join(", ") ,count: "" + $featuresToApplyOn.length})} />
<Tr
t={t.autoApply.Subs({
attr_names: keysToApply.join(", "),
count: "" + $featuresToApplyOn.length,
})}
/>
</div>
</div>
{:else}
@ -38,6 +41,3 @@
{/if}
{/if}
</LoginToggle>

View file

@ -63,7 +63,7 @@ export class MultiApplyViz implements SpecialVisualization {
return []
}
})
const params : MultiApplyParams= {
const params: MultiApplyParams = {
featureIds,
keysToApply,
text,

View file

@ -66,7 +66,7 @@
reader.readAsText(files[0], "UTF-8")
// here we tell the reader what to do when it's done reading...
const content = await new Promise<string>(resolve => {
const content = await new Promise<string>((resolve) => {
reader.onload = (readerEvent) => {
resolve(<string>readerEvent.target.result)
}

View file

@ -24,12 +24,12 @@
const t = Translations.t.general.apply_button
// THis button might be shown on MapRoulette-items, which might already have been applied
// This will default to 'false' for non-maproulette challenges
let isMaprouletteAndApplied = tags?.data?.["mr_taskStatus"] !== undefined &&
tags?.data?.["mr_taskStatus"] !== "Created"
let isMaprouletteAndApplied =
tags?.data?.["mr_taskStatus"] !== undefined && tags?.data?.["mr_taskStatus"] !== "Created"
let currentState: UIEventSource<"init" | "applying" | "applied"> = new UIEventSource(
isMaprouletteAndApplied ? "applied" : "init")
isMaprouletteAndApplied ? "applied" : "init"
)
async function apply() {
currentState.set("applying")
@ -38,17 +38,20 @@
}
</script>
<LoginToggle {state} ignoreLoading>
{#if $currentState === "init"}
<button on:click={() => apply()}>
<Icon icon={image} />
<div class="flex flex-col">
<div>{msg}</div>
{#if targetIdKey}
<Tr cls="subtle break-all"
t={t.appliedOnAnotherObject.Subs({ id: $tags[targetIdKey], tags: new And($tagsToApply).asHumanString(false, false, {}) })} />
<Tr
cls="subtle break-all"
t={t.appliedOnAnotherObject.Subs({
id: $tags[targetIdKey],
tags: new And($tagsToApply).asHumanString(false, false, {}),
})}
/>
{:else}
<TagExplanation tagsFilter={new And($tagsToApply)} />
{/if}
@ -58,7 +61,6 @@
<Loading>
<Tr t={t.applying} />
</Loading>
{:else if $currentState === "applied"}
<Tr t={t.isApplied} cls="thanks" />
{/if}

View file

@ -48,7 +48,7 @@ export default class TagApplyViz implements AutoAction, SpecialVisualization {
public static generateTagsToApply(
spec: string,
tagSource: Store<Record<string, string>>,
tagSource: Store<Record<string, string>>
): Store<Tag[]> {
// Check whether we need to look up a single value
@ -128,7 +128,7 @@ export default class TagApplyViz implements AutoAction, SpecialVisualization {
_: Feature,
state: SpecialVisualizationState,
tags: UIEventSource<any>,
args: string[],
args: string[]
): Promise<void> {
const tagsToApply = TagApplyViz.generateTagsToApply(args[0], tags)
const targetIdKey = args[3]
@ -141,7 +141,7 @@ export default class TagApplyViz implements AutoAction, SpecialVisualization {
{
theme: state.theme.id,
changeType: "answer",
},
}
)
await state.changes.applyAction(changeAction)
try {
@ -152,7 +152,12 @@ export default class TagApplyViz implements AutoAction, SpecialVisualization {
const maproulette_id_key = args[4]
if (maproulette_id_key) {
const maproulette_id = tags.data[maproulette_id_key]
console.log("Looking for maproulette feature with id", maproulette_id,"based on key", maproulette_id_key)
console.log(
"Looking for maproulette feature with id",
maproulette_id,
"based on key",
maproulette_id_key
)
const maproulette_feature = state.indexedFeatures.featuresById.data.get(maproulette_id)
const maproulette_task_id = Number(maproulette_feature.properties.mr_taskId)
await Maproulette.singleton.closeTask(
@ -161,7 +166,7 @@ export default class TagApplyViz implements AutoAction, SpecialVisualization {
state,
{
comment: "Tags are copied onto " + targetId + " with MapComplete",
},
}
)
maproulette_feature.properties["mr_taskStatus"] = "Fixed"
state.featureProperties.getStore(maproulette_id).ping()
@ -171,9 +176,9 @@ export default class TagApplyViz implements AutoAction, SpecialVisualization {
public constr(
state: SpecialVisualizationState,
tags: UIEventSource<Record<string, string>>,
args: string[], feature: Feature,
args: string[],
feature: Feature
): SvelteUIElement {
const tagsToApply: Store<Tag[]> = TagApplyViz.generateTagsToApply(args[0], tags)
const msg = args[1]
let image = args[2]?.trim()
@ -186,9 +191,14 @@ export default class TagApplyViz implements AutoAction, SpecialVisualization {
await this.applyActionOn(feature, state, tags, args)
}
return new SvelteUIElement(TagApplyButton, {
state, tags, tagsToApply, msg, image, targetIdKey, onApply
state,
tags,
tagsToApply,
msg,
image,
targetIdKey,
onApply,
})
}
}