From 79615574680d021c8cad28549cd799650a92749c Mon Sep 17 00:00:00 2001 From: Thibaut Courouble Date: Sun, 30 Apr 2017 18:24:19 -0400 Subject: [PATCH] Show doc version in sidebar when multiple versions of the same doc are enabled --- assets/javascripts/collections/collection.coffee | 5 +++++ assets/javascripts/templates/sidebar_tmpl.coffee | 2 +- assets/javascripts/views/sidebar/doc_list.coffee | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/assets/javascripts/collections/collection.coffee b/assets/javascripts/collections/collection.coffee index a5628d8a..b902a498 100644 --- a/assets/javascripts/collections/collection.coffee +++ b/assets/javascripts/collections/collection.coffee @@ -48,3 +48,8 @@ class app.Collection findAllBy: (attr, value) -> model for model in @models when model[attr] is value + + countAllBy: (attr, value) -> + i = 0 + i += 1 for model in @models when model[attr] is value + i diff --git a/assets/javascripts/templates/sidebar_tmpl.coffee b/assets/javascripts/templates/sidebar_tmpl.coffee index bb5dc623..a1a4c3ca 100644 --- a/assets/javascripts/templates/sidebar_tmpl.coffee +++ b/assets/javascripts/templates/sidebar_tmpl.coffee @@ -10,7 +10,7 @@ templates.sidebarDoc = (doc, options = {}) -> link += """""" link += """#{doc.release}""" if doc.release link += """#{doc.name}""" - link += " #{doc.version}" if options.disabled and doc.version + link += " #{doc.version}" if options.fullName or options.disabled and doc.version link + "" templates.sidebarType = (type) -> diff --git a/assets/javascripts/views/sidebar/doc_list.coffee b/assets/javascripts/views/sidebar/doc_list.coffee index c59be416..d9823a10 100644 --- a/assets/javascripts/views/sidebar/doc_list.coffee +++ b/assets/javascripts/views/sidebar/doc_list.coffee @@ -37,7 +37,10 @@ class app.views.DocList extends app.View return render: => - @html @tmpl('sidebarDoc', app.docs.all()) + html = '' + for doc in app.docs.all() + html += @tmpl('sidebarDoc', doc, fullName: app.docs.countAllBy('name', doc.name) > 1) + @html html @renderDisabled() unless app.isSingleDoc() or app.disabledDocs.size() is 0 return