Fixed the level editor save view knowing if the level has changes to save.

This commit is contained in:
Scott Erickson 2014-02-06 10:30:49 -08:00
parent f3d1a43bbf
commit 332ea0df2c
2 changed files with 3 additions and 6 deletions
app/views/editor/level

View file

@ -52,7 +52,6 @@ module.exports = class EditorLevelView extends View
@files.fetch()
onAllLoaded: =>
@originalLevelAttributes = _.cloneDeep @level.attributes
@level.unset('nextLevel') if _.isString(@level.get('nextLevel'))
@initWorld()
@startsLoading = false
@ -93,7 +92,7 @@ module.exports = class EditorLevelView extends View
@childWindow.focus()
startCommittingLevel: (e) ->
levelSaveView = new LevelSaveView level: @level, supermodel: @supermodel, originalLevelAttributes: @originalLevelAttributes
levelSaveView = new LevelSaveView level: @level, supermodel: @supermodel
@openModalView levelSaveView
Backbone.Mediator.publish 'level:view-switched', e

View file

@ -16,13 +16,11 @@ module.exports = class LevelSaveView extends SaveVersionModal
constructor: (options) ->
super options
@level = options.level
@originalLevelAttributes = options.originalLevelAttributes
@levelNeedsSave = not _.isEqual @level.attributes, @originalLevelAttributes
getRenderData: (context={}) =>
context = super(context)
context.level = @level
context.levelNeedsSave = @levelNeedsSave
context.levelNeedsSave = @level.hasLocalChanges()
context.modifiedComponents = _.filter @supermodel.getModels(LevelComponent), @shouldSaveEntity
context.modifiedSystems = _.filter @supermodel.getModels(LevelSystem), @shouldSaveEntity
context