From 5b5bceda3af980afdb1c564705d2769adce23aad Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Tue, 26 Aug 2014 13:08:56 -0700 Subject: [PATCH] Components tab now incorporates components inherited from thang types. --- .../editor/level/components/ComponentsTabView.coffee | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/views/editor/level/components/ComponentsTabView.coffee b/app/views/editor/level/components/ComponentsTabView.coffee index 10cd608aa..d3cd60125 100644 --- a/app/views/editor/level/components/ComponentsTabView.coffee +++ b/app/views/editor/level/components/ComponentsTabView.coffee @@ -1,5 +1,6 @@ CocoView = require 'views/kinds/CocoView' template = require 'templates/editor/level/components_tab' +ThangType = require 'models/ThangType' LevelComponent = require 'models/LevelComponent' LevelComponentEditView = require './LevelComponentEditView' LevelComponentNewView = require './NewLevelComponentModal' @@ -27,7 +28,15 @@ module.exports = class ComponentsTabView extends CocoView refreshLevelThangsTreema: (thangsData) -> presentComponents = {} for thang in thangsData + componentMap = {} + thangType = @supermodel.getModelByOriginal ThangType, thang.thangType + for component in thangType.get('components') ? [] + componentMap[component.original] = component + for component in thang.components + componentMap[component.original] = component + + for component in _.values(componentMap) haveThisComponent = (presentComponents[component.original + '.' + (component.majorVersion ? 0)] ?= []) haveThisComponent.push thang.id if haveThisComponent.length < 100 # for performance when adding many Thangs return if _.isEqual presentComponents, @presentComponents