codecombat/app/views/modal/versions_modal.coffee

44 lines
1.1 KiB
CoffeeScript
Raw Normal View History

ModalView = require 'views/kinds/ModalView'
template = require 'templates/modal/versions'
tableTemplate = require 'templates/kinds/table'
class VersionsViewCollection extends Backbone.Collection
url: ""
model: null
initialize: (@url, @levelID, @model) ->
@url = url + levelID + '/versions'
@model = model
module.exports = class VersionsModalView extends ModalView
template: template
startsLoading: true
2014-04-17 14:22:33 -04:00
plain: true
modalWidthPercent: 80
# needs to be overwritten by child
id: ""
url: ""
page: ""
constructor: (options, @ID, @model) ->
super options
@view = new model(_id: @ID)
@view.fetch()
2014-03-24 02:53:41 -04:00
@listenToOnce(@view, 'sync', @onViewSync)
2014-03-24 02:53:41 -04:00
onViewSync: ->
@collection = new VersionsViewCollection(@url, @view.attributes.original, @model)
@collection.fetch()
2014-03-24 02:53:41 -04:00
@listenTo(@collection, 'sync', @onVersionFetched)
2014-03-24 02:53:41 -04:00
onVersionFetched: ->
@startsLoading = false
@render()
2014-02-11 17:58:45 -05:00
getRenderData: (context={}) ->
context = super(context)
context.page = @page
context.dataList = (m.attributes for m in @collection.models) if @collection
context