mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 10:06:08 -05:00
42 lines
1.1 KiB
CoffeeScript
42 lines
1.1 KiB
CoffeeScript
|
View = require 'views/kinds/RootView'
|
||
|
template = require 'templates/kinds/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 SuperVersionsView extends View
|
||
|
template: template
|
||
|
startsLoading: true
|
||
|
|
||
|
# needs to be overwritten by child
|
||
|
id: ""
|
||
|
url = ""
|
||
|
page = ""
|
||
|
|
||
|
constructor: (options, @ID, @model) ->
|
||
|
super options
|
||
|
@view = new model(_id: @ID)
|
||
|
@view.fetch()
|
||
|
@view.once('sync', @onViewSync)
|
||
|
|
||
|
onViewSync: =>
|
||
|
@collection = new VersionsViewCollection(@url, @view.attributes.original, @model)
|
||
|
@collection.fetch()
|
||
|
@collection.on('sync', @onVersionFetched)
|
||
|
|
||
|
onVersionFetched: =>
|
||
|
@startsLoading = false
|
||
|
@render()
|
||
|
|
||
|
getRenderData: (context={}) =>
|
||
|
context = super(context)
|
||
|
context.page = @page
|
||
|
context.dataList = (m.attributes for m in @collection.models) if @collection
|
||
|
context
|