diff --git a/assets/javascripts/collections/types.coffee b/assets/javascripts/collections/types.coffee index 455a7ed7..7750542d 100644 --- a/assets/javascripts/collections/types.coffee +++ b/assets/javascripts/collections/types.coffee @@ -1,2 +1,16 @@ class app.collections.Types extends app.Collection @model: 'Type' + + groups: -> + result = [] + for type in @models + (result[@_groupFor(type)] ||= []).push(type) + result.filter (e) -> e.length > 0 + + GUIDES_RGX = /guide|tutorial/i + + _groupFor: (type) -> + if GUIDES_RGX.test(type.name) + 0 + else + 1 diff --git a/assets/javascripts/views/sidebar/type_list.coffee b/assets/javascripts/views/sidebar/type_list.coffee index a57ad41f..eb089618 100644 --- a/assets/javascripts/views/sidebar/type_list.coffee +++ b/assets/javascripts/views/sidebar/type_list.coffee @@ -25,7 +25,9 @@ class app.views.TypeList extends app.View return render: -> - @html @tmpl('sidebarType', @doc.types.all()) + html = '' + html += @tmpl('sidebarType', group) for group in @doc.types.groups() + @html(html) onOpen: (event) => $.stopEvent(event)