mirror of
https://github.com/umap-project/umap.git
synced 2025-04-28 19:42:36 +02:00
wip: uncreated map should always appear as dirty
This commit is contained in:
parent
d0fb85d552
commit
a2e864ad73
3 changed files with 5 additions and 2 deletions
|
@ -73,7 +73,7 @@ export class SyncEngine {
|
||||||
this.websocketConnected = false
|
this.websocketConnected = false
|
||||||
this.closeRequested = false
|
this.closeRequested = false
|
||||||
this.peerId = Utils.generateId()
|
this.peerId = Utils.generateId()
|
||||||
this._undoManager = new UndoManager(this.updaters, this)
|
this._undoManager = new UndoManager(umap, this.updaters, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
get isOpen() {
|
get isOpen() {
|
||||||
|
|
|
@ -2,7 +2,8 @@ import * as Utils from '../utils.js'
|
||||||
import { DataLayerUpdater, FeatureUpdater, MapUpdater } from './updaters.js'
|
import { DataLayerUpdater, FeatureUpdater, MapUpdater } from './updaters.js'
|
||||||
|
|
||||||
export class UndoManager {
|
export class UndoManager {
|
||||||
constructor(updaters, syncEngine) {
|
constructor(umap, updaters, syncEngine) {
|
||||||
|
this._umap = umap
|
||||||
this._syncEngine = syncEngine
|
this._syncEngine = syncEngine
|
||||||
this.updaters = updaters
|
this.updaters = updaters
|
||||||
this._undoStack = []
|
this._undoStack = []
|
||||||
|
@ -25,6 +26,7 @@ export class UndoManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
isDirty() {
|
isDirty() {
|
||||||
|
if (!this._umap.id) return true
|
||||||
for (const stage of this._undoStack) {
|
for (const stage of this._undoStack) {
|
||||||
if (stage.operation.dirty) return true
|
if (stage.operation.dirty) return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,6 +162,7 @@ export class TopBar extends WithTemplate {
|
||||||
this.elements.view.disabled = this._umap.sync._undoManager.isDirty()
|
this.elements.view.disabled = this._umap.sync._undoManager.isDirty()
|
||||||
this.elements.saveLabel.hidden = this._umap.permissions.isDraft()
|
this.elements.saveLabel.hidden = this._umap.permissions.isDraft()
|
||||||
this.elements.saveDraftLabel.hidden = !this._umap.permissions.isDraft()
|
this.elements.saveDraftLabel.hidden = !this._umap.permissions.isDraft()
|
||||||
|
this._umap.sync._undoManager.toggleState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue