mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-01 15:50:11 -04:00
Clearing backups of old models when saving new versions of versioned models.
This commit is contained in:
parent
573b566580
commit
3862bd2376
4 changed files with 11 additions and 6 deletions
app
|
@ -1,7 +1,7 @@
|
|||
ul#primary-goals-list
|
||||
div.goals-status
|
||||
strong(data-i18n="play_level.goals") Goals
|
||||
span.spl.spr :
|
||||
span.spr :
|
||||
span(data-i18n="play_level.success").secret.goal-status.success Success!
|
||||
span(data-i18n="play_level.incomplete").secret.goal-status.incomplete Incomplete
|
||||
span(data-i18n="play_level.timed_out").secret.goal-status.timed-out Ran out of time
|
||||
|
|
|
@ -81,7 +81,7 @@ module.exports = class ArticleEditView extends View
|
|||
@preview.focus() if window.focus
|
||||
@preview.onload = => @pushChangesToPreview()
|
||||
return false
|
||||
|
||||
|
||||
openSaveModal: ->
|
||||
@openModalView(new SaveVersionModal({model: @article}))
|
||||
|
||||
|
@ -101,6 +101,7 @@ module.exports = class ArticleEditView extends View
|
|||
@disableModalInProgress(modal)
|
||||
|
||||
res.success =>
|
||||
@article.clearBackup()
|
||||
modal.modal('hide')
|
||||
url = "/editor/article/#{newArticle.get('slug') or newArticle.id}"
|
||||
document.location.href = url
|
||||
|
|
|
@ -76,7 +76,7 @@ module.exports = class LevelSaveView extends SaveVersionModal
|
|||
else if @level.isPublished() and not newModel.isPublished()
|
||||
newModel.publish() # Publish any LevelComponents that weren't published yet
|
||||
formsToSave.push form
|
||||
|
||||
|
||||
for model in modelsToSave
|
||||
if errors = model.getValidationErrors()
|
||||
messages = ("\t #{error.dataPath}: #{error.message}" for error in errors)
|
||||
|
@ -96,6 +96,8 @@ module.exports = class LevelSaveView extends SaveVersionModal
|
|||
forms.applyErrorsToForm($(form), JSON.parse(res.responseText))
|
||||
res.success =>
|
||||
modelsToSave = _.without modelsToSave, newModel
|
||||
oldModel = _.find @supermodel.models, (m) -> m.get('original') is newModel.get('original')
|
||||
oldModel.clearBackup() # Otherwise looking at old versions is confusing.
|
||||
unless modelsToSave.length
|
||||
url = "/editor/level/#{@level.get('slug') or @level.id}"
|
||||
document.location.href = url
|
||||
|
|
|
@ -66,7 +66,7 @@ module.exports = class ThangTypeEditView extends View
|
|||
raw = ("raw:#{name}" for name in raw)
|
||||
main = _.keys(@thangType.get('actions') or {})
|
||||
main.concat(raw)
|
||||
|
||||
|
||||
afterRender: ->
|
||||
super()
|
||||
return unless @supermodel.finished()
|
||||
|
@ -326,7 +326,9 @@ module.exports = class ThangTypeEditView extends View
|
|||
image = @currentSprite.imageObject.image
|
||||
portraitSource = imageToPortrait image
|
||||
# bit of a hacky way to get that portrait
|
||||
success = -> document.location.href = url
|
||||
success = =>
|
||||
@thangType.clearBackup()
|
||||
document.location.href = url
|
||||
newThangType.uploadGenericPortrait success, portraitSource
|
||||
|
||||
clearRawData: ->
|
||||
|
@ -419,4 +421,4 @@ imageToPortrait = (img) ->
|
|||
scaleY = 100 / img.height
|
||||
ctx.scale scaleX, scaleY
|
||||
ctx.drawImage img, 0, 0
|
||||
canvas.toDataURL("image/png")
|
||||
canvas.toDataURL("image/png")
|
||||
|
|
Loading…
Add table
Reference in a new issue