diff --git a/app/styles/editor/level/thangs_tab.sass b/app/styles/editor/level/thangs_tab.sass index 9b8b7bf1f..2caa3552e 100644 --- a/app/styles/editor/level/thangs_tab.sass +++ b/app/styles/editor/level/thangs_tab.sass @@ -58,6 +58,17 @@ h3 margin: 0 -20px 0 0 width: 100% + + h4 + margin: 0 0 10px + clear: both + padding: 5px + background: rgba(150, 150, 150, 0.5) + width: $addPaletteWidth - 20px + box-sizing: border-box + + .clearfix + margin-bottom: 20px .add-thang-palette-icon position: relative diff --git a/app/templates/editor/level/thangs_tab.jade b/app/templates/editor/level/thangs_tab.jade index 86ad57f9c..e3d74429e 100644 --- a/app/templates/editor/level/thangs_tab.jade +++ b/app/templates/editor/level/thangs_tab.jade @@ -12,9 +12,11 @@ .add-thangs-palette.thangs-column h3(data-i18n="editor.level_tab_thangs_add") Add Thangs #thangs-list - for thangType in thangTypes - div.add-thang-palette-icon(data-thang-type=thangType.name) - - path = '/file/db/thang.type/'+thangType.original+'/portrait.png' - img(title="Add " + thangType.name, src=path, alt="") - + for group in groups + h4= group.name + for thangType in group.thangs + div.add-thang-palette-icon(data-thang-type=thangType.name) + - path = '/file/db/thang.type/'+thangType.original+'/portrait.png' + img(title="Add " + thangType.name, src=path, alt="") + div.clearfix #editor-level-thang-edit.hide \ No newline at end of file diff --git a/app/views/editor/level/thangs_tab_view.coffee b/app/views/editor/level/thangs_tab_view.coffee index 454b4d4f0..c03b81724 100644 --- a/app/views/editor/level/thangs_tab_view.coffee +++ b/app/views/editor/level/thangs_tab_view.coffee @@ -63,7 +63,24 @@ module.exports = class ThangsTabView extends View getRenderData: (context={}) => context = super(context) - context.thangTypes = (thangType.attributes for thangType in @supermodel.getModels(ThangType)) + thangTypes = (thangType.attributes for thangType in @supermodel.getModels(ThangType)) + thangTypes = _.uniq thangTypes, false, 'original' + groupMap = {} + for thangType in thangTypes + groupMap[thangType.kind] ?= [] + groupMap[thangType.kind].push thangType + + groups = [] + for groupName in Object.keys(groupMap).sort() + someThangTypes = groupMap[groupName] + someThangTypes = _.sortBy someThangTypes, 'name' + group = + name: groupName + thangs: someThangTypes + groups.push group + + context.thangTypes = thangTypes + context.groups = groups context afterRender: -> diff --git a/server/handlers/Handler.coffee b/server/handlers/Handler.coffee index c193ab050..7a02b6280 100644 --- a/server/handlers/Handler.coffee +++ b/server/handlers/Handler.coffee @@ -92,7 +92,7 @@ module.exports = class Handler unless @modelClass.schema.uses_coco_search return @sendNotFoundError(res) - project = {original:1, name:1, version:1, description: 1, slug:1} + project = {original:1, name:1, version:1, description: 1, slug:1, kind: 1} term = req.query.term matchedObjects = [] filters = [{filter: {index: true}}]