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 {
const leftRightSensitive = state.layoutToUse.layers.some(layer => layer.lineRendering.some(lr => lr.leftRightSensitive))
const leftRightSensitive = state.layoutToUse.isLeftRightSensitive()
if (leftRightSensitive) {
SimpleMetaTagger.removeBothTagging(latestTags)

View file

@ -6,6 +6,7 @@ import OsmChangeAction from "./Actions/OsmChangeAction";
import {ChangeDescription} from "./Actions/ChangeDescription";
import {Utils} from "../../Utils";
import {LocalStorageSource} from "../Web/LocalStorageSource";
import SimpleMetaTagger from "../SimpleMetaTagger";
/**
* Handles all changes made to OSM.
@ -26,8 +27,10 @@ export class Changes {
private readonly isUploading = new UIEventSource(false);
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
this.allChanges.setData([...this.pendingChanges.data])
// If a pending change contains a negative ID, we save that
@ -121,6 +124,11 @@ export class Changes {
const self = this;
const neededIds = Changes.GetNeededIds(pending)
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)
const changes: {
newObjects: OsmObject[],

View file

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

View file

@ -297,4 +297,8 @@ export default class LayerConfig extends WithContextLoader{
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")
}
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 {SaveButton} from "./SaveButton";
import State from "../../State";
import {Changes} from "../../Logic/Osm/Changes";
import {VariableUiElement} from "../Base/VariableUIElement";
import Translations from "../i18n/Translations";
import {FixedUiElement} from "../Base/FixedUiElement";
@ -84,7 +83,7 @@ export default class TagRenderingQuestion extends Combine {
const save = () => {
const selection = inputElement.GetValue().data;
if (selection) {
(State.state?.changes ?? new Changes())
(State.state?.changes)
.applyAction(new ChangeTagAction(
tags.data.id, selection, tags.data, {
theme: State.state?.layoutToUse?.id ?? "unkown",