Fixed with a sledgehammer--just loading all Components before loading level editor.

This commit is contained in:
Nick Winter 2014-03-15 12:31:39 -07:00
parent e97bff6a3c
commit ca75cc4a1a
2 changed files with 17 additions and 4 deletions

View file

@ -2,6 +2,5 @@ LevelComponent = require 'models/LevelComponent'
CocoCollection = require 'models/CocoCollection'
module.exports = class ComponentsCollection extends CocoCollection
url: '/db/level_component/search'
url: '/db/level.component/search'
model: LevelComponent

View file

@ -8,6 +8,7 @@ CocoCollection = require 'models/CocoCollection'
Surface = require 'lib/surface/Surface'
Thang = require 'lib/world/thang'
LevelThangEditView = require './thang/edit'
ComponentsCollection = require 'collections/ComponentsCollection'
# Moving the screen while dragging thangs constants
MOVE_MARGIN = 0.15
@ -60,12 +61,25 @@ module.exports = class ThangsTabView extends View
@thangTypes.once 'sync', @onThangTypesLoaded
@thangTypes.fetch()
# just loading all Components for now: https://github.com/codecombat/codecombat/issues/405
@componentCollection = @supermodel.getCollection new ComponentsCollection()
@componentCollection.once 'sync', @onComponentsLoaded
@componentCollection.fetch()
onThangTypesLoaded: =>
return if @destroyed
@supermodel.addCollection @thangTypes
@supermodel.populateModel model for model in @thangTypes.models
@startsLoading = false
@startsLoading = not @componentCollection.loaded
@render() # do it again but without the loading screen
@onLevelLoaded level: @level if @level
@onLevelLoaded level: @level if @level and not @startsLoading
onComponentsLoaded: =>
return if @destroyed
@supermodel.addCollection @componentCollection
@startsLoading = not @thangTypes.loaded
@render() # do it again but without the loading screen
@onLevelLoaded level: @level if @level and not @startsLoading
getRenderData: (context={}) ->
context = super(context)