forked from MapComplete/MapComplete
Close popup after splitting; scroll popup into view
This commit is contained in:
parent
057c3fde4f
commit
a7da5d65cf
4 changed files with 17 additions and 17 deletions
|
@ -45,20 +45,6 @@ export default class SelectedFeatureHandler {
|
|||
|
||||
const self = this
|
||||
hash.addCallback(() => self.setSelectedElementFromHash())
|
||||
|
||||
state.featurePipeline?.newDataLoadedSignal?.addCallbackAndRunD((_) => {
|
||||
// New data was loaded. In initial startup, the hash might be set (via the URL) but might not be selected yet
|
||||
if (hash.data === undefined || SelectedFeatureHandler._no_trigger_on.has(hash.data)) {
|
||||
// This is an invalid hash anyway
|
||||
return
|
||||
}
|
||||
if (state.selectedElement.data !== undefined) {
|
||||
// We already have something selected
|
||||
return
|
||||
}
|
||||
self.setSelectedElementFromHash()
|
||||
})
|
||||
|
||||
this.initialLoad()
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,9 @@ export default class ElementsState extends FeatureSwitchState {
|
|||
constructor(layoutToUse: LayoutConfig) {
|
||||
super(layoutToUse)
|
||||
|
||||
this.selectedElement.addCallbackAndRun((e) => {
|
||||
console.trace("Selected element is now", e)
|
||||
})
|
||||
function localStorageSynced(
|
||||
key: string,
|
||||
deflt: number,
|
||||
|
|
|
@ -24,6 +24,7 @@ import BaseLayer from "../../Models/BaseLayer"
|
|||
import FilteredLayer from "../../Models/FilteredLayer"
|
||||
import BaseUIElement from "../BaseUIElement"
|
||||
import { VariableUiElement } from "../Base/VariableUIElement"
|
||||
import ScrollableFullScreen from "../Base/ScrollableFullScreen"
|
||||
|
||||
export default class SplitRoadWizard extends Combine {
|
||||
// @ts-ignore
|
||||
|
@ -54,6 +55,7 @@ export default class SplitRoadWizard extends Combine {
|
|||
changes: Changes
|
||||
layoutToUse: LayoutConfig
|
||||
allElements: ElementStorage
|
||||
selectedElement: UIEventSource<any>
|
||||
}
|
||||
) {
|
||||
const t = Translations.t.split
|
||||
|
@ -79,9 +81,6 @@ export default class SplitRoadWizard extends Combine {
|
|||
hasBeenSplit
|
||||
)
|
||||
)
|
||||
splitButton.onClick(() => {
|
||||
splitClicked.setData(true)
|
||||
})
|
||||
|
||||
// Only show the splitButton if logged in, else show login prompt
|
||||
const loginBtn = t.loginToSplit
|
||||
|
@ -110,6 +109,9 @@ export default class SplitRoadWizard extends Combine {
|
|||
// We throw away the old map and splitpoints, and create a new map from scratch
|
||||
splitPoints.setData([])
|
||||
leafletMap.setData(SplitRoadWizard.setupMapComponent(id, splitPoints, state))
|
||||
|
||||
// Close the popup. The contributor has to select a segment again to make sure they continue editing the correct segment; see #1219
|
||||
ScrollableFullScreen.collapse()
|
||||
})
|
||||
|
||||
saveButton.SetClass("btn btn-primary mr-3")
|
||||
|
@ -147,6 +149,11 @@ export default class SplitRoadWizard extends Combine {
|
|||
new Toggle(mapView, splitToggle, splitClicked),
|
||||
])
|
||||
this.dialogIsOpened = splitClicked
|
||||
const self = this
|
||||
splitButton.onClick(() => {
|
||||
splitClicked.setData(true)
|
||||
self.ScrollIntoView()
|
||||
})
|
||||
}
|
||||
|
||||
private static setupMapComponent(
|
||||
|
|
|
@ -115,6 +115,10 @@ export default class ShowDataLayerImplementation {
|
|||
})
|
||||
|
||||
this._selectedElement?.addCallbackAndRunD((selected) => {
|
||||
if (selected === undefined) {
|
||||
ScrollableFullScreen.collapse()
|
||||
return
|
||||
}
|
||||
self.openPopupOfSelectedElement(selected)
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue