Fixed name ordering in the thang components editor.

This commit is contained in:
Scott Erickson 2014-08-26 13:27:17 -07:00
parent 5b5bceda3a
commit 39d0df5153
2 changed files with 10 additions and 5 deletions

View file

@ -78,6 +78,8 @@ module.exports = class ThangComponentsEditView extends CocoView
},
data: $.extend true, {}, components
callbacks: {select: @onSelectComponent, change: @onComponentsTreemaChanged}
nodeClasses:
'object': ThangComponentsObjectNode
@componentsTreema = @$el.find('#thang-components-column .treema').treema treemaOptions
@componentsTreema.build()
@ -345,11 +347,14 @@ module.exports = class ThangComponentsEditView extends CocoView
@onComponentsChanged()
class ThangComponentsArrayNode extends TreemaArrayNode
valueClass: 'treema-thang-components-array'
sort: true
class ThangComponentsObjectNode extends TreemaObjectNode
getChildren: ->
children = super(arguments...)
children.sort(@sortFunction)
sortFunction: (a, b) =>
a = a.value ? a.defaultData
b = b.value ? b.defaultData
a = @settings.supermodel.getModelByOriginalAndMajorVersion(LevelComponent, a.original, a.majorVersion)
b = @settings.supermodel.getModelByOriginalAndMajorVersion(LevelComponent, b.original, b.majorVersion)
return 0 if not (a or b)

View file

@ -44,9 +44,9 @@ responses =
module.exports = ->
view = new ThangComponentEditView({
components: [
{ original: 'A', majorVersion: 0, config: {propA: 1, propB: 'string'} }
{ original: 'B', majorVersion: 0 }
{ original: 'C', majorVersion: 0 }
{ original: 'A', majorVersion: 0, config: {propA: 1, propB: 'string'} }
]
thangType: new ThangType({
components: [