forked from MapComplete/MapComplete
More work on refactoring the changes handling
This commit is contained in:
parent
42391b4ff1
commit
b55f9a25c6
19 changed files with 181 additions and 105 deletions
|
@ -21,6 +21,7 @@ import {InputElement} from "../Input/InputElement";
|
|||
import Loc from "../../Models/Loc";
|
||||
import AvailableBaseLayers from "../../Logic/Actors/AvailableBaseLayers";
|
||||
import CreateNewNodeAction from "../../Logic/Osm/Actions/CreateNewNodeAction";
|
||||
import Hash from "../../Logic/Web/Hash";
|
||||
|
||||
/*
|
||||
* The SimpleAddUI is a single panel, which can have multiple states:
|
||||
|
@ -71,10 +72,11 @@ export default class SimpleAddUI extends Toggle {
|
|||
}
|
||||
return SimpleAddUI.CreateConfirmButton(preset,
|
||||
(tags, location) => {
|
||||
let changes =
|
||||
State.state.changes.applyAction(new CreateNewNodeAction(tags, location.lat, location.lon))
|
||||
State.state.selectedElement.setData(changes.newFeatures[0]);
|
||||
const newElementAction = new CreateNewNodeAction(tags, location.lat, location.lon)
|
||||
State.state.changes.applyAction(newElementAction)
|
||||
selectedPreset.setData(undefined)
|
||||
isShown.setData(false)
|
||||
Hash.hash.setData(newElementAction.newElementId)
|
||||
}, () => {
|
||||
selectedPreset.setData(undefined)
|
||||
})
|
||||
|
@ -119,16 +121,16 @@ export default class SimpleAddUI extends Toggle {
|
|||
lon: location.data.lon,
|
||||
zoom: 19
|
||||
});
|
||||
|
||||
|
||||
let backgroundLayer = undefined;
|
||||
if(preset.preciseInput.preferredBackground){
|
||||
backgroundLayer= AvailableBaseLayers.SelectBestLayerAccordingTo(locationSrc, new UIEventSource<string | string[]>(preset.preciseInput.preferredBackground))
|
||||
if (preset.preciseInput.preferredBackground) {
|
||||
backgroundLayer = AvailableBaseLayers.SelectBestLayerAccordingTo(locationSrc, new UIEventSource<string | string[]>(preset.preciseInput.preferredBackground))
|
||||
}
|
||||
|
||||
|
||||
preciseInput = new LocationInput({
|
||||
mapBackground: backgroundLayer,
|
||||
centerLocation:locationSrc
|
||||
|
||||
centerLocation: locationSrc
|
||||
|
||||
})
|
||||
preciseInput.SetClass("h-32 rounded-xl overflow-hidden border border-gray").SetStyle("height: 12rem;")
|
||||
}
|
||||
|
@ -143,7 +145,7 @@ export default class SimpleAddUI extends Toggle {
|
|||
.onClick(() => {
|
||||
confirm(preset.tags, (preciseInput?.GetValue() ?? location).data);
|
||||
});
|
||||
|
||||
|
||||
if (preciseInput !== undefined) {
|
||||
confirmButton = new Combine([preciseInput, confirmButton])
|
||||
}
|
||||
|
@ -239,7 +241,7 @@ export default class SimpleAddUI extends Toggle {
|
|||
for (const preset of presets) {
|
||||
|
||||
const tags = TagUtils.KVtoProperties(preset.tags ?? []);
|
||||
let icon:() => BaseUIElement = () => layer.layerDef.GenerateLeafletStyle(new UIEventSource<any>(tags), false).icon.html
|
||||
let icon: () => BaseUIElement = () => layer.layerDef.GenerateLeafletStyle(new UIEventSource<any>(tags), false).icon.html
|
||||
.SetClass("w-12 h-12 block relative");
|
||||
const presetInfo: PresetInfo = {
|
||||
tags: preset.tags,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue