Changes do apply left-right splitting before uploading too

This commit is contained in:
Pieter Vander Vennet 2021-10-22 14:01:40 +02:00
parent 40c4ae769d
commit 0dc7187bab
6 changed files with 27 additions and 9 deletions

View file

@ -80,7 +80,7 @@ export default class SelectedElementTagsUpdater {
) { ) {
try { try {
const leftRightSensitive = state.layoutToUse.layers.some(layer => layer.lineRendering.some(lr => lr.leftRightSensitive)) const leftRightSensitive = state.layoutToUse.isLeftRightSensitive()
if (leftRightSensitive) { if (leftRightSensitive) {
SimpleMetaTagger.removeBothTagging(latestTags) SimpleMetaTagger.removeBothTagging(latestTags)

View file

@ -6,6 +6,7 @@ import OsmChangeAction from "./Actions/OsmChangeAction";
import {ChangeDescription} from "./Actions/ChangeDescription"; import {ChangeDescription} from "./Actions/ChangeDescription";
import {Utils} from "../../Utils"; import {Utils} from "../../Utils";
import {LocalStorageSource} from "../Web/LocalStorageSource"; import {LocalStorageSource} from "../Web/LocalStorageSource";
import SimpleMetaTagger from "../SimpleMetaTagger";
/** /**
* Handles all changes made to OSM. * Handles all changes made to OSM.
@ -26,8 +27,10 @@ export class Changes {
private readonly isUploading = new UIEventSource(false); private readonly isUploading = new UIEventSource(false);
private readonly previouslyCreated: OsmObject[] = [] private readonly previouslyCreated: OsmObject[] = []
private readonly _leftRightSensitive: boolean;
constructor() { constructor(leftRightSensitive : boolean = false) {
this._leftRightSensitive = leftRightSensitive;
// We keep track of all changes just as well // We keep track of all changes just as well
this.allChanges.setData([...this.pendingChanges.data]) this.allChanges.setData([...this.pendingChanges.data])
// If a pending change contains a negative ID, we save that // If a pending change contains a negative ID, we save that
@ -121,6 +124,11 @@ export class Changes {
const self = this; const self = this;
const neededIds = Changes.GetNeededIds(pending) const neededIds = Changes.GetNeededIds(pending)
const osmObjects = await Promise.all(neededIds.map(id => OsmObject.DownloadObjectAsync(id))); const osmObjects = await Promise.all(neededIds.map(id => OsmObject.DownloadObjectAsync(id)));
if(this._leftRightSensitive){
osmObjects.forEach(obj => SimpleMetaTagger.removeBothTagging(obj.tags))
}
console.log("Got the fresh objects!", osmObjects, "pending: ", pending) console.log("Got the fresh objects!", osmObjects, "pending: ", pending)
const changes: { const changes: {
newObjects: OsmObject[], newObjects: OsmObject[],

View file

@ -24,7 +24,7 @@ export default class ElementsState extends FeatureSwitchState{
/** /**
THe change handler THe change handler
*/ */
public changes: Changes = new Changes(); public changes: Changes;
/** /**
The latest element that was selected The latest element that was selected
@ -48,6 +48,9 @@ export default class ElementsState extends FeatureSwitchState{
constructor(layoutToUse: LayoutConfig) { constructor(layoutToUse: LayoutConfig) {
super(layoutToUse); super(layoutToUse);
this.changes = new Changes(layoutToUse.isLeftRightSensitive())
{ {
// -- Location control initialization // -- Location control initialization
const zoom = UIEventSource.asFloat( const zoom = UIEventSource.asFloat(

View file

@ -297,4 +297,8 @@ export default class LayerConfig extends WithContextLoader{
return allIcons; return allIcons;
} }
public isLeftRightSensitive() : boolean{
return this.lineRendering.some(lr => lr.leftRightSensitive)
}
} }

View file

@ -280,4 +280,8 @@ export default class LayoutConfig {
return new LayoutConfig(JSON.parse(originalJson), false, "Layout rewriting") return new LayoutConfig(JSON.parse(originalJson), false, "Layout rewriting")
} }
public isLeftRightSensitive(){
return this.layers.some(l => l.isLeftRightSensitive())
}
} }

View file

@ -9,7 +9,6 @@ import CheckBoxes from "../Input/Checkboxes";
import InputElementMap from "../Input/InputElementMap"; import InputElementMap from "../Input/InputElementMap";
import {SaveButton} from "./SaveButton"; import {SaveButton} from "./SaveButton";
import State from "../../State"; import State from "../../State";
import {Changes} from "../../Logic/Osm/Changes";
import {VariableUiElement} from "../Base/VariableUIElement"; import {VariableUiElement} from "../Base/VariableUIElement";
import Translations from "../i18n/Translations"; import Translations from "../i18n/Translations";
import {FixedUiElement} from "../Base/FixedUiElement"; import {FixedUiElement} from "../Base/FixedUiElement";
@ -84,7 +83,7 @@ export default class TagRenderingQuestion extends Combine {
const save = () => { const save = () => {
const selection = inputElement.GetValue().data; const selection = inputElement.GetValue().data;
if (selection) { if (selection) {
(State.state?.changes ?? new Changes()) (State.state?.changes)
.applyAction(new ChangeTagAction( .applyAction(new ChangeTagAction(
tags.data.id, selection, tags.data, { tags.data.id, selection, tags.data, {
theme: State.state?.layoutToUse?.id ?? "unkown", theme: State.state?.layoutToUse?.id ?? "unkown",