Open popup of newly added element immediatly, fix #132

This commit is contained in:
Pieter Vander Vennet 2020-10-01 00:03:12 +02:00
parent e16a210ee1
commit a75471df77
2 changed files with 15 additions and 5 deletions

View file

@ -1,6 +1,7 @@
import {Img} from "../../UI/Img";
import {RegexTag, Tag} from "../../Logic/Tags";
import {TagRenderingOptions} from "../TagRenderingOptions";
import {FixedUiElement} from "../../UI/Base/FixedUiElement";
export class OsmLink extends TagRenderingOptions {
@ -18,7 +19,7 @@ export class OsmLink extends TagRenderingOptions {
placeholder: "",
},
mappings: [
{k: new RegexTag("id", /node\/-.+/), txt: "<span class='alert'>Uploading</span>"}
{k: new RegexTag("id", /node\/-.+/), txt: ""}
]
}

View file

@ -165,12 +165,11 @@ export class FilteredLayer {
public AddNewElement(element) {
this._newElements.push(element);
console.log("Element added");
this.RenderLayer({features:this._dataFromOverpass}); // Update the layer
this.RenderLayer({features: this._dataFromOverpass}, element); // Update the layer
}
private RenderLayer(data) {
private RenderLayer(data, openPopupOf = undefined) {
let self = this;
if (this._geolayer !== undefined && this._geolayer !== null) {
@ -219,6 +218,7 @@ export class FilteredLayer {
// The points get a special treatment in order to render them properly
// Note that some features might get a point representation as well
const runWhenAdded: (() => void)[] = []
this._geolayer = L.geoJSON(data, {
style: function (feature) {
@ -252,7 +252,7 @@ export class FilteredLayer {
const popup = L.popup({}, marker);
let uiElement: UIElement;
let content = undefined;
marker.bindPopup(popup)
let p = marker.bindPopup(popup)
.on("popupopen", () => {
if (content === undefined) {
uiElement = self._showOnPopup(eventSource, feature);
@ -263,6 +263,12 @@ export class FilteredLayer {
uiElement.Update();
});
if (feature === openPopupOf) {
runWhenAdded.push(() => {
p.openPopup();
})
}
return marker;
},
@ -321,6 +327,9 @@ export class FilteredLayer {
if (this.combinedIsDisplayed.data) {
this._geolayer.addTo(State.state.bm.map);
for (const f of runWhenAdded) {
f();
}
}
}