Refactoring: fix delete indication, fix splitroad, fix addition of multiple new points snapped onto the same way (all will properly attach now)

This commit is contained in:
Pieter Vander Vennet 2023-04-20 17:42:07 +02:00
parent 1f9aacfb29
commit 4172af6a72
118 changed files with 1422 additions and 1357 deletions

View file

@ -88,16 +88,18 @@
changeType: "create",
snapOnto: snapToWay
});
await state.changes.applyAction(newElementAction);
await state.changes.applyAction(newElementAction)
state.newFeatures.features.ping()
// The 'changes' should have created a new point, which added this into the 'featureProperties'
const newId = newElementAction.newElementId;
console.log("Applied pending changes, fetching store for", newId)
const tagsStore = state.featureProperties.getStore(newId);
{
// Set some metainfo
const properties = tagsStore.data;
if (snapTo) {
// metatags (starting with underscore) are not uploaded, so we can safely mark this
delete properties["_referencing_ways"]
properties["_referencing_ways"] = `["${snapTo}"]`;
}
properties["_backend"] = state.osmConnection.Backend()

View file

@ -1,15 +1,9 @@
import { Store, UIEventSource } from "../../Logic/UIEventSource"
import QuestionBox from "./QuestionBox"
import { UIEventSource } from "../../Logic/UIEventSource"
import Combine from "../Base/Combine"
import TagRenderingAnswer from "./TagRenderingAnswer"
import ScrollableFullScreen from "../Base/ScrollableFullScreen"
import Constants from "../../Models/Constants"
import SharedTagRenderings from "../../Customizations/SharedTagRenderings"
import BaseUIElement from "../BaseUIElement"
import { VariableUiElement } from "../Base/VariableUIElement"
import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
import Toggle from "../Input/Toggle"
import Lazy from "../Base/Lazy"
import FeaturePipelineState from "../../Logic/State/FeaturePipelineState"
import Svg from "../../Svg"
import Translations from "../i18n/Translations"
@ -31,7 +25,7 @@ export default class FeatureInfoBox extends ScrollableFullScreen {
)
super(
() => undefined,
() => FeatureInfoBox.GenerateContent(tags, layerConfig, state, showAllQuestions),
() => FeatureInfoBox.GenerateContent(tags, layerConfig),
options?.hashToShow ?? tags.data.id ?? "item",
options?.isShown,
options
@ -42,60 +36,14 @@ export default class FeatureInfoBox extends ScrollableFullScreen {
}
}
public static GenerateContent(
tags: UIEventSource<any>,
layerConfig: LayerConfig
): BaseUIElement {
public static GenerateContent(tags: UIEventSource<any>): BaseUIElement {
return new Toggle(
new Combine([
Svg.delete_icon_svg().SetClass("w-8 h-8"),
Translations.t.delete.isDeleted,
]).SetClass("flex justify-center font-bold items-center"),
FeatureInfoBox.GenerateMainContent(tags, layerConfig),
new Combine([]).SetClass("block"),
tags.map((t) => t["_deleted"] == "yes")
)
}
private static GenerateMainContent(
tags: UIEventSource<any>,
layerConfig: LayerConfig
): BaseUIElement {
const t = Translations.t.general
const withQuestion = layerConfig.tagRenderings.filter(
(tr) => tr.question !== undefined
).length
const allRenderings: BaseUIElement[] = [
new VariableUiElement(
tags
.map((data) => data["_newly_created"])
.map((isCreated) => {
if (isCreated === undefined) {
return undefined
}
const createdDate = new Date(isCreated)
const secondsSinceCreation = (Date.now() - createdDate.getTime()) / 1000
if (secondsSinceCreation >= 60 * 5) {
return undefined
}
const els = []
const thanks = new Combine([
Svg.party_svg().SetClass(
"w-12 h-12 shrink-0 p-1 m-1 bg-white rounded-full block"
),
t.newlyCreated,
]).SetClass("flex w-full thanks content-center")
els.push(thanks)
if (withQuestion > 0) {
els.push(t.feelFreeToSkip)
}
return new Combine(els).SetClass("pb-4 mb-4 border-b block border-black")
})
),
]
return new Combine(allRenderings).SetClass("block")
}
}

View file

@ -65,7 +65,6 @@ export default class SplitRoadWizard extends Combine {
leafletMap.setData(mapComponent.SetClass("w-full h-80"))
)
}
initMap()
// Toggle between splitmap
const splitButton = new SubtleButton(
@ -94,7 +93,6 @@ export default class SplitRoadWizard extends Combine {
await state.changes?.applyAction(splitAction)
// We throw away the old map and splitpoints, and create a new map from scratch
splitPoints.setData([])
initMap()
// Close the popup. The contributor has to select a segment again to make sure they continue editing the correct segment; see #1219
state.selectedElement?.setData(undefined)
@ -134,6 +132,11 @@ export default class SplitRoadWizard extends Combine {
),
new Toggle(mapView, splitToggle, splitClicked),
])
splitClicked.addCallback((view) => {
if (view) {
initMap()
}
})
this.dialogIsOpened = splitClicked
const self = this
splitButton.onClick(() => {

View file

@ -45,7 +45,6 @@
let questionsToAsk = tags.map(tags => {
const baseQuestions = (layer.tagRenderings ?? [])?.filter(tr => allowed(tr.labels) && tr.question !== undefined);
console.log("Determining questions for", baseQuestions)
const questionsToAsk: TagRenderingConfig[] = [];
for (const baseQuestion of baseQuestions) {
if (skippedQuestions.data.has(baseQuestion.id) > 0) {

View file

@ -23,10 +23,12 @@
export let layer: LayerConfig;
let trs: { then: Translation; icon?: string; iconClass?: string }[];
$: trs = Utils.NoNull(config?.GetRenderValues(_tags));
let classes = ""
$:classes = config?.classes?.join(" ") ?? "";
</script>
{#if config !== undefined && (config?.condition === undefined || config.condition.matchesProperties(_tags))}
<div class="flex flex-col w-full">
<div class={"flex flex-col w-full "+classes}>
{#if trs.length === 1}
<TagRenderingMapping mapping={trs[0]} {tags} {state} {selectedElement} {layer}></TagRenderingMapping>
{/if}