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

View file

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