Changes do apply left-right splitting before uploading too
This commit is contained in:
parent
40c4ae769d
commit
0dc7187bab
6 changed files with 27 additions and 9 deletions
|
@ -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)
|
||||||
|
|
|
@ -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[],
|
||||||
|
|
|
@ -15,7 +15,7 @@ import TitleHandler from "../Actors/TitleHandler";
|
||||||
/**
|
/**
|
||||||
* The part of the state keeping track of where the elements, loading them, configuring the feature pipeline etc
|
* The part of the state keeping track of where the elements, loading them, configuring the feature pipeline etc
|
||||||
*/
|
*/
|
||||||
export default class ElementsState extends FeatureSwitchState{
|
export default class ElementsState extends FeatureSwitchState {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The mapping from id -> UIEventSource<properties>
|
The mapping from id -> UIEventSource<properties>
|
||||||
|
@ -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
|
||||||
|
@ -34,7 +34,7 @@ export default class ElementsState extends FeatureSwitchState{
|
||||||
"Selected element"
|
"Selected element"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The map location: currently centered lat, lon and zoom
|
* The map location: currently centered lat, lon and zoom
|
||||||
*/
|
*/
|
||||||
|
@ -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(
|
||||||
|
@ -84,10 +87,10 @@ export default class ElementsState extends FeatureSwitchState{
|
||||||
lon.setData(latlonz.lon);
|
lon.setData(latlonz.lon);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
new ChangeToElementsActor(this.changes, this.allElements)
|
new ChangeToElementsActor(this.changes, this.allElements)
|
||||||
new PendingChangesUploader(this.changes, this.selectedElement);
|
new PendingChangesUploader(this.changes, this.selectedElement);
|
||||||
new TitleHandler(this);
|
new TitleHandler(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -297,4 +297,8 @@ export default class LayerConfig extends WithContextLoader{
|
||||||
|
|
||||||
return allIcons;
|
return allIcons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public isLeftRightSensitive() : boolean{
|
||||||
|
return this.lineRendering.some(lr => lr.leftRightSensitive)
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -279,5 +279,9 @@ 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())
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -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",
|
||||||
|
|
Loading…
Add table
Reference in a new issue