forked from MapComplete/MapComplete
Improve 'relocate'-dialog
This commit is contained in:
parent
530d746bb7
commit
c1223b6244
1 changed files with 48 additions and 11 deletions
|
@ -19,6 +19,10 @@ import MoveConfig from "../../Models/ThemeConfig/MoveConfig"
|
||||||
import {ElementStorage} from "../../Logic/ElementStorage"
|
import {ElementStorage} from "../../Logic/ElementStorage"
|
||||||
import AvailableBaseLayers from "../../Logic/Actors/AvailableBaseLayers"
|
import AvailableBaseLayers from "../../Logic/Actors/AvailableBaseLayers"
|
||||||
import BaseLayer from "../../Models/BaseLayer"
|
import BaseLayer from "../../Models/BaseLayer"
|
||||||
|
import SearchAndGo from "../BigComponents/SearchAndGo";
|
||||||
|
import ChangeTagAction from "../../Logic/Osm/Actions/ChangeTagAction";
|
||||||
|
import {And} from "../../Logic/Tags/And";
|
||||||
|
import {Tag} from "../../Logic/Tags/Tag";
|
||||||
|
|
||||||
interface MoveReason {
|
interface MoveReason {
|
||||||
text: Translation | string
|
text: Translation | string
|
||||||
|
@ -26,9 +30,11 @@ interface MoveReason {
|
||||||
icon: BaseUIElement
|
icon: BaseUIElement
|
||||||
changesetCommentValue: string
|
changesetCommentValue: string
|
||||||
lockBounds: true | boolean
|
lockBounds: true | boolean
|
||||||
|
includeSearch: false | boolean
|
||||||
background: undefined | "map" | "photo" | string | string[]
|
background: undefined | "map" | "photo" | string | string[]
|
||||||
startZoom: number
|
startZoom: number
|
||||||
minZoom: number
|
minZoom: number
|
||||||
|
eraseAddressFields: false | boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class MoveWizard extends Toggle {
|
export default class MoveWizard extends Toggle {
|
||||||
|
@ -62,8 +68,10 @@ export default class MoveWizard extends Toggle {
|
||||||
changesetCommentValue: "relocated",
|
changesetCommentValue: "relocated",
|
||||||
lockBounds: false,
|
lockBounds: false,
|
||||||
background: undefined,
|
background: undefined,
|
||||||
|
includeSearch: true,
|
||||||
startZoom: 12,
|
startZoom: 12,
|
||||||
minZoom: 6,
|
minZoom: 6,
|
||||||
|
eraseAddressFields: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (options.enableImproveAccuracy) {
|
if (options.enableImproveAccuracy) {
|
||||||
|
@ -73,9 +81,11 @@ export default class MoveWizard extends Toggle {
|
||||||
icon: Svg.crosshair_svg(),
|
icon: Svg.crosshair_svg(),
|
||||||
changesetCommentValue: "improve_accuracy",
|
changesetCommentValue: "improve_accuracy",
|
||||||
lockBounds: true,
|
lockBounds: true,
|
||||||
|
includeSearch: false,
|
||||||
background: "photo",
|
background: "photo",
|
||||||
startZoom: 17,
|
startZoom: 17,
|
||||||
minZoom: 16,
|
minZoom: 16,
|
||||||
|
eraseAddressFields: false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,6 +151,7 @@ export default class MoveWizard extends Toggle {
|
||||||
loc,
|
loc,
|
||||||
new UIEventSource(background)
|
new UIEventSource(background)
|
||||||
).data
|
).data
|
||||||
|
|
||||||
const locationInput = new LocationInput({
|
const locationInput = new LocationInput({
|
||||||
minZoom: reason.minZoom,
|
minZoom: reason.minZoom,
|
||||||
centerLocation: loc,
|
centerLocation: loc,
|
||||||
|
@ -152,12 +163,19 @@ export default class MoveWizard extends Toggle {
|
||||||
locationInput.installBounds(0.05, true)
|
locationInput.installBounds(0.05, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let searchPanel: BaseUIElement = undefined
|
||||||
|
if (reason.includeSearch) {
|
||||||
|
searchPanel = new SearchAndGo({
|
||||||
|
leafletMap: locationInput.leafletMap
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
locationInput.SetStyle("height: 17.5rem")
|
locationInput.SetStyle("height: 17.5rem")
|
||||||
|
|
||||||
const confirmMove = new SubtleButton(Svg.move_confirm_svg(), t.confirmMove)
|
const confirmMove = new SubtleButton(Svg.move_confirm_svg(), t.confirmMove)
|
||||||
confirmMove.onClick(() => {
|
confirmMove.onClick(async () => {
|
||||||
const loc = locationInput.GetValue().data
|
const loc = locationInput.GetValue().data
|
||||||
state.changes.applyAction(
|
await state.changes.applyAction(
|
||||||
new ChangeLocationAction(featureToMove.properties.id, [loc.lon, loc.lat], {
|
new ChangeLocationAction(featureToMove.properties.id, [loc.lon, loc.lat], {
|
||||||
reason: reason.changesetCommentValue,
|
reason: reason.changesetCommentValue,
|
||||||
theme: state.layoutToUse.id,
|
theme: state.layoutToUse.id,
|
||||||
|
@ -165,11 +183,30 @@ export default class MoveWizard extends Toggle {
|
||||||
)
|
)
|
||||||
featureToMove.properties._lat = loc.lat
|
featureToMove.properties._lat = loc.lat
|
||||||
featureToMove.properties._lon = loc.lon
|
featureToMove.properties._lon = loc.lon
|
||||||
|
|
||||||
|
if (reason.eraseAddressFields) {
|
||||||
|
await state.changes.applyAction(
|
||||||
|
new ChangeTagAction(featureToMove.properties.id,
|
||||||
|
new And([new Tag("addr:housenumber", ""),
|
||||||
|
new Tag("addr:street", ""),
|
||||||
|
new Tag("addr:city", ""),
|
||||||
|
new Tag("addr:postcode","")]
|
||||||
|
),
|
||||||
|
featureToMove.properties,
|
||||||
|
{
|
||||||
|
changeType: "relocated",
|
||||||
|
theme: state.layoutToUse.id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
state.allElements.getEventSourceById(id).ping()
|
state.allElements.getEventSourceById(id).ping()
|
||||||
currentStep.setData("moved")
|
currentStep.setData("moved")
|
||||||
})
|
})
|
||||||
const zoomInFurhter = t.zoomInFurther.SetClass("alert block m-6")
|
const zoomInFurhter = t.zoomInFurther.SetClass("alert block m-6")
|
||||||
return new Combine([
|
return new Combine([
|
||||||
|
searchPanel,
|
||||||
locationInput,
|
locationInput,
|
||||||
new Toggle(
|
new Toggle(
|
||||||
confirmMove,
|
confirmMove,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue