Unified · Split
| @@ -1,2 +1,16 @@ | ||
| 1 | 1 | class app.collections.Types extends app.Collection |
| 2 | 2 | @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 | |
| @@ -25,7 +25,9 @@ class app.views.TypeList extends app.View · 24 unmodified lines | ||
| 25 | 25 | return |
| 26 | 26 | |
| 27 | 27 | render: -> |
| 28 | − @html @tmpl('sidebarType', @doc.types.all()) | |
| 28 | + html = '' | |
| 29 | + html += @tmpl('sidebarType', group) for group in @doc.types.groups() | |
| 30 | + @html(html) | |
| 29 | 31 | |
| 30 | 32 | onOpen: (event) => |
| 31 | 33 | $.stopEvent(event) |