codecombat/app/views/modal/RevertModal.coffee

27 lines
658 B
CoffeeScript
Raw Normal View History

ModalView = require 'views/core/ModalView'
template = require 'templates/modal/revert'
CocoModel = require 'models/CocoModel'
module.exports = class RevertModal extends ModalView
id: 'revert-modal'
template: template
2014-04-11 20:36:15 -04:00
events:
'click #changed-models button': 'onRevertModel'
2014-04-11 20:36:15 -04:00
onRevertModel: (e) ->
id = $(e.target).val()
CocoModel.backedUp[id].revert()
$(e.target).closest('tr').remove()
@reloadOnClose = true
2014-04-11 20:36:15 -04:00
getRenderData: ->
c = super()
models = _.values CocoModel.backedUp
models = (m for m in models when m.hasLocalChanges())
c.models = models
c
onHidden: ->
location.reload() if @reloadOnClose