Merge develop

This commit is contained in:
Pieter Vander Vennet 2023-04-07 04:36:41 +02:00
commit bef05481bd
239 changed files with 11612 additions and 1347 deletions

View file

@ -6,44 +6,45 @@
import Translations from "../i18n/Translations";
import { ImmutableStore } from "../../Logic/UIEventSource.js";
export let imageUrl: string | BaseUIElement = undefined;
export let message: string | BaseUIElement = undefined;
export let imageUrl: string | BaseUIElement = undefined
export let message: string | BaseUIElement = undefined
export let options: {
url?: string | Store<string>
newTab?: boolean
imgSize?: string
extraClasses?: string
} = {};
} = {}
// Website to open when clicked
let href : Store<string> = undefined
if(options?.url){
href = typeof options?.url == "string" ? new ImmutableStore(options.url) : options.url;
let href: Store<string> = undefined
if (options?.url) {
href = typeof options?.url == "string" ? new ImmutableStore(options.url) : options.url
}
let imgElem: HTMLElement;
let msgElem: HTMLElement;
let imgClasses = "block justify-center shrink-0 mr-4 " + (options?.imgSize ?? "h-11 w-11");
const dispatch = createEventDispatcher<{click}>()
onMount(() => {
// Image
if (imgElem && imageUrl) {
let img: BaseUIElement;
let img: BaseUIElement
if ((imageUrl ?? "") === "") {
img = undefined;
img = undefined
} else if (typeof imageUrl !== "string") {
img = imageUrl?.SetClass(imgClasses);
img = imageUrl?.SetClass(imgClasses)
}
if (img) imgElem.replaceWith(img.ConstructElement());
if (img) imgElem.replaceWith(img.ConstructElement())
}
// Message
if (msgElem && message) {
let msg = Translations.W(message)?.SetClass("block text-ellipsis no-images flex-shrink");
msgElem.replaceWith(msg.ConstructElement());
let msg = Translations.W(message)?.SetClass("block text-ellipsis no-images flex-shrink")
msgElem.replaceWith(msg.ConstructElement())
}
});
})
</script>
<svelte:element
@ -69,7 +70,6 @@
</svelte:element>
<style lang="scss">
span,
a {
@apply flex p-3 my-2 py-4 rounded-lg shrink-0;

View file

@ -13,7 +13,7 @@ export class SubtleButton extends UIElement {
private readonly options: {
url?: string | Store<string>
newTab?: boolean
imgSize?: string,
imgSize?: string
extraClasses?: string
}
@ -23,7 +23,7 @@ export class SubtleButton extends UIElement {
options: {
url?: string | Store<string>
newTab?: boolean
imgSize?: "h-11 w-11" | string,
imgSize?: "h-11 w-11" | string
extraClasses?: string
} = {}
) {

View file

@ -29,8 +29,8 @@
url: "https://pietervdvn.github.io/mc/legacy/070/customGenerator.html",
}}
>
<span slot="image" class="h-11 w-11 mx-4 bg-red" >
<ToSvelte construct={Svg.pencil_ui()}/>
<span slot="image" class="h-11 w-11 mx-4 bg-red">
<ToSvelte construct={Svg.pencil_ui()} />
</span>
<span slot="message">{t.createYourOwnTheme.toString()}</span>
</SubtleButton>

View file

@ -27,7 +27,14 @@
$: knownThemes = hiddenThemes.filter((theme) => knownThemesId.includes(theme.id))
</script>
<ThemesList {search} {state} {onMainScreen} themes={knownThemes} isCustom={true} hideThemes={false}>
<ThemesList
{search}
{state}
{onMainScreen}
themes={knownThemes}
isCustom={false}
hideThemes={false}
>
<svelte:fragment slot="title">
<h3>{t.previouslyHiddenTitle.toString()}</h3>
<p>

View file

@ -1,23 +1,9 @@
/**
* Asks to add a feature at the last clicked location, at least if zoom is sufficient
*/
import { UIEventSource } from "../../Logic/UIEventSource"
import Translations from "../i18n/Translations"
import BaseUIElement from "../BaseUIElement"
import { VariableUiElement } from "../Base/VariableUIElement"
import Toggle from "../Input/Toggle"
import CreateNewNodeAction from "../../Logic/Osm/Actions/CreateNewNodeAction"
import { OsmObject, OsmWay } from "../../Logic/Osm/OsmObject"
import PresetConfig from "../../Models/ThemeConfig/PresetConfig"
import FilteredLayer from "../../Models/FilteredLayer"
import Loading from "../Base/Loading"
import Hash from "../../Logic/Web/Hash"
import { WayId } from "../../Models/OsmFeature"
import { Tag } from "../../Logic/Tags/Tag"
import { SpecialVisualizationState } from "../SpecialVisualization"
import { Feature } from "geojson"
import { FixedUiElement } from "../Base/FixedUiElement"
import Combine from "../Base/Combine"
/*
* The SimpleAddUI is a single panel, which can have multiple states:

View file

@ -6,8 +6,8 @@
import UserDetails, { OsmConnection } from "../../Logic/Osm/OsmConnection"
import Constants from "../../Models/Constants"
import type Loc from "../../Models/Loc"
import type { LayoutInformation } from "../../Models/ThemeConfig/LayoutConfig";
import Tr from "../Base/Tr.svelte";
import type { LayoutInformation } from "../../Models/ThemeConfig/LayoutConfig"
import Tr from "../Base/Tr.svelte"
export let theme: LayoutInformation
export let isCustom: boolean = false

View file

@ -8,7 +8,7 @@
import CustomGeneratorButton from "./CustomGeneratorButton.svelte"
import ProfessionalServicesButton from "./ProfessionalServicesButton.svelte"
import ThemeButton from "./ThemeButton.svelte"
import { LayoutInformation } from "../../Models/ThemeConfig/LayoutConfig";
import { LayoutInformation } from "../../Models/ThemeConfig/LayoutConfig"
export let search: UIEventSource<string>
export let themes: LayoutInformation[]
@ -44,32 +44,31 @@
<slot name="title" />
{#if onMainScreen}
<div class="md:grid md:grid-flow-row md:grid-cols-2 lg:grid-cols-3 gap-4">
{#if ($search === undefined || $search === "") && !isCustom}
{#if ($search === undefined || $search === "") && !isCustom && hideThemes}
<CustomGeneratorButton userDetails={state.osmConnection.userDetails} />
<ProfessionalServicesButton />
{/if}
{#each filteredThemes as theme}
{#each filteredThemes as theme (theme.id)}
{#if theme !== undefined && !(hideThemes && theme?.hideFromOverview)}
<ThemeButton {theme} {isCustom} userDetails={state.osmConnection.userDetails} {state} />
{/if}
{/each}
</div>
{:else }
{:else}
<div>
{#if ($search === undefined || $search === "") && !isCustom}
{#if ($search === undefined || $search === "") && !isCustom && hideThemes}
<CustomGeneratorButton userDetails={state.osmConnection.userDetails} />
<ProfessionalServicesButton />
{/if}
{#each filteredThemes as theme}
{#each filteredThemes as theme (theme.id)}
{#if theme !== undefined && !(hideThemes && theme?.hideFromOverview)}
<ThemeButton {theme} {isCustom} userDetails={state.osmConnection.userDetails} {state} />
{/if}
{/each}
</div>
{/if}
{/if}
{#if filteredThemes.length == 0}
<NoThemeResultButton {search} />

View file

@ -169,13 +169,13 @@ export default class LocationInput
loc.lat,
])
if (min === undefined) {
min = nearestPointOnLine
min = { ...nearestPointOnLine }
matchedWay = feature
continue
}
if (min.properties.dist > nearestPointOnLine.properties.dist) {
min = nearestPointOnLine
min = { ...nearestPointOnLine }
matchedWay = feature
}
} catch (e) {
@ -201,6 +201,10 @@ export default class LocationInput
}
}
min.properties = options?.snappedPointTags ?? min.properties
min.properties = {
...min.properties,
_referencing_ways: JSON.stringify([matchedWay.properties.id]),
}
self.snappedOnto.setData(<any>matchedWay)
return min
},

View file

@ -9,7 +9,7 @@ export class Translation extends BaseUIElement {
public readonly translations: Record<string, string>
public readonly context?: string
constructor(translations: Record<string, string>, context?: string) {
constructor(translations: string | Record<string, string>, context?: string) {
super()
if (translations === undefined) {
console.error("Translation without content at " + context)