diff --git a/app/views/editor/component/ThangComponentsEditView.coffee b/app/views/editor/component/ThangComponentsEditView.coffee index f12a0b331..f2ce6b905 100644 --- a/app/views/editor/component/ThangComponentsEditView.coffee +++ b/app/views/editor/component/ThangComponentsEditView.coffee @@ -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) diff --git a/test/demo/views/editor/component/ThangComponentsEditView.demo.coffee b/test/demo/views/editor/component/ThangComponentsEditView.demo.coffee index 8bab8d90f..079fc50ef 100644 --- a/test/demo/views/editor/component/ThangComponentsEditView.demo.coffee +++ b/test/demo/views/editor/component/ThangComponentsEditView.demo.coffee @@ -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: [