From a49023a991c62595fc5c449729be4cc313ff66a7 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 3 Nov 2014 16:59:45 -0500 Subject: fix undo scenery create/destroy --- public/assets/javascripts/ui/editor/MediaEditor.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'public/assets/javascripts/ui') diff --git a/public/assets/javascripts/ui/editor/MediaEditor.js b/public/assets/javascripts/ui/editor/MediaEditor.js index 9b81db1..9a3c355 100644 --- a/public/assets/javascripts/ui/editor/MediaEditor.js +++ b/public/assets/javascripts/ui/editor/MediaEditor.js @@ -161,7 +161,7 @@ var MediaEditor = FormView.extend({ unbind: function(){ if (this.scenery) { - if (this.tainted) { + if (this.tainted && this.scenery.media) { this.scenery.media.title = this.$name.val() this.scenery.media.description = this.$description.val() Minotaur.watch( app.router.editorView.settings ) @@ -178,8 +178,20 @@ var MediaEditor = FormView.extend({ destroy: function(){ var scenery = this.scenery this.hide() + + UndoStack.push({ + type: 'destroy-scenery', + undo: scenery.serialize(), + redo: { id: scenery.id }, + }) + + // TODO: watch individual scenery object here + Minotaur.watch( app.router.editorView.settings ) + Scenery.remove(scenery.id) Scenery.resize.hide() + this.tainted = false + this.scenery = null }, }) -- cgit v1.2.3-70-g09d2