forked from MapComplete/MapComplete
Rewrite left-right tags when updating them on click
This commit is contained in:
parent
45e8ee310b
commit
40c4ae769d
2 changed files with 95 additions and 73 deletions
|
@ -6,6 +6,8 @@ import {ElementStorage} from "../ElementStorage";
|
|||
import {Changes} from "../Osm/Changes";
|
||||
import {OsmObject} from "../Osm/OsmObject";
|
||||
import {OsmConnection} from "../Osm/OsmConnection";
|
||||
import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig";
|
||||
import SimpleMetaTagger from "../SimpleMetaTagger";
|
||||
|
||||
export default class SelectedElementTagsUpdater {
|
||||
|
||||
|
@ -14,13 +16,14 @@ export default class SelectedElementTagsUpdater {
|
|||
"changeset",
|
||||
"user",
|
||||
"uid",
|
||||
"id"] )
|
||||
"id"])
|
||||
|
||||
constructor(state: {
|
||||
selectedElement: UIEventSource<any>,
|
||||
allElements: ElementStorage,
|
||||
changes: Changes,
|
||||
osmConnection: OsmConnection
|
||||
osmConnection: OsmConnection,
|
||||
layoutToUse: LayoutConfig
|
||||
}) {
|
||||
|
||||
|
||||
|
@ -37,7 +40,8 @@ export default class SelectedElementTagsUpdater {
|
|||
selectedElement: UIEventSource<any>,
|
||||
allElements: ElementStorage,
|
||||
changes: Changes,
|
||||
osmConnection: OsmConnection
|
||||
osmConnection: OsmConnection,
|
||||
layoutToUse: LayoutConfig
|
||||
}) {
|
||||
|
||||
|
||||
|
@ -70,11 +74,18 @@ export default class SelectedElementTagsUpdater {
|
|||
selectedElement: UIEventSource<any>,
|
||||
allElements: ElementStorage,
|
||||
changes: Changes,
|
||||
osmConnection: OsmConnection
|
||||
osmConnection: OsmConnection,
|
||||
layoutToUse: LayoutConfig
|
||||
}, latestTags: any, id: string
|
||||
) {
|
||||
try {
|
||||
|
||||
const leftRightSensitive = state.layoutToUse.layers.some(layer => layer.lineRendering.some(lr => lr.leftRightSensitive))
|
||||
|
||||
if (leftRightSensitive) {
|
||||
SimpleMetaTagger.removeBothTagging(latestTags)
|
||||
}
|
||||
|
||||
const pendingChanges = state.changes.pendingChanges.data
|
||||
.filter(change => change.type + "/" + change.id === id)
|
||||
.filter(change => change.tags !== undefined);
|
||||
|
@ -92,6 +103,7 @@ export default class SelectedElementTagsUpdater {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// With the changes applied, we merge them onto the upstream object
|
||||
let somethingChanged = false;
|
||||
const currentTagsSource = state.allElements.getEventSourceById(id);
|
||||
|
@ -115,7 +127,7 @@ export default class SelectedElementTagsUpdater {
|
|||
if (currentKey.startsWith("_")) {
|
||||
continue
|
||||
}
|
||||
if(this.metatags.has(currentKey)){
|
||||
if (this.metatags.has(currentKey)) {
|
||||
continue
|
||||
}
|
||||
if (currentKey in latestTags) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue