History

Show guide/tutorial types at the top of the list

Thibaut committed 11 years ago

Commit bff40331 parent 14464292 files · +17 −1Browse files

Unified · Split

2 files
  1. assets/javascripts/collections/types.coffee +14 −0
  2. assets/javascripts/views/sidebar/type_list.coffee +3 −1
assets/javascripts/collections/types.coffee+14−0
@@ -1,2 +1,16 @@
11 class app.collections.Types extends app.Collection
22 @model: 'Type'
3+
4+ groups: ->
5+ result = []
6+ for type in @models
7+ (result[@_groupFor(type)] ||= []).push(type)
8+ result.filter (e) -> e.length > 0
9+
10+ GUIDES_RGX = /guide|tutorial/i
11+
12+ _groupFor: (type) ->
13+ if GUIDES_RGX.test(type.name)
14+ 0
15+ else
16+ 1
assets/javascripts/views/sidebar/type_list.coffee+3−1
@@ -25,7 +25,9 @@ class app.views.TypeList extends app.View · 24 unmodified lines
2525 return
2626
2727 render: ->
28− @html @tmpl('sidebarType', @doc.types.all())
28+ html = ''
29+ html += @tmpl('sidebarType', group) for group in @doc.types.groups()
30+ @html(html)
2931
3032 onOpen: (event) =>
3133 $.stopEvent(event)