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