ソースを参照

Improve 'Updates' notification

Thibaut Courouble 9 年 前
コミット
430524f097

+ 21 - 8
assets/javascripts/templates/notif_tmpl.coffee

@@ -26,14 +26,27 @@ app.templates.notifInvalidLocation = ->
 app.templates.notifNews = (news) ->
   notif 'Changelog', """<div class="_notif-content _notif-news">#{app.templates.newsList(news, years: false)}</div>"""
 
-app.templates.notifUpdates = (docs) ->
-  html = """<ul class="_notif-content _notif-list">"""
-  for doc in docs
-    html += "<li>#{doc.name}"
-    html += " (#{doc.release})" if doc.release
-    html += "</li>"
-  html += "</ul>"
-  notif 'Updates', html
+app.templates.notifUpdates = (docs, disabledDocs) ->
+  html = '<div class="_notif-content _notif-news">'
+
+  if docs.length > 0
+    html += '<div class="_news-row">'
+    html += '<ul class="_notif-list">'
+    for doc in docs
+      html += "<li>#{doc.name}"
+      html += " <code>&rarr;</code> #{doc.release}" if doc.release
+    html += '</ul></div>'
+
+  if disabledDocs.length > 0
+    html += '<div class="_news-row"><p class="_news-title">Disabled:'
+    html += '<ul class="_notif-list">'
+    for doc in disabledDocs
+      html += "<li>#{doc.name}"
+      html += " <code>&rarr;</code> #{doc.release}" if doc.release
+      html += """<span class="_notif-info"><a data-pick-docs>Enable</a></span>"""
+    html += '</ul></div>'
+
+  notif 'Updates', "#{html}</div>"
 
 app.templates.notifShare = ->
   textNotif """ Hi there! """,

+ 9 - 3
assets/javascripts/views/misc/updates.coffee

@@ -7,18 +7,24 @@ class app.views.Updates extends app.views.Notif
     autoHide: 30000
 
   init: ->
+    @lastUpdateTime = @getLastUpdateTime()
     @updatedDocs = @getUpdatedDocs()
+    @updatedDisabledDocs = @getUpdatedDisabledDocs()
     @show() if @updatedDocs.length
     @markAllAsRead()
     return
 
   render: ->
-    @html app.templates.notifUpdates(@updatedDocs)
+    @html app.templates.notifUpdates(@updatedDocs, @updatedDisabledDocs)
     return
 
   getUpdatedDocs: ->
-    return [] unless time = @getLastUpdateTime()
-    doc for doc in app.docs.all() when doc.mtime > time
+    return [] unless @lastUpdateTime
+    doc for doc in app.docs.all() when doc.mtime > @lastUpdateTime
+
+  getUpdatedDisabledDocs: ->
+    return [] unless @lastUpdateTime
+    doc for doc in app.disabledDocs.all() when doc.mtime > @lastUpdateTime and app.docs.findBy('slug_without_version', doc.slug_without_version)
 
   getLastUpdateTime: ->
     app.settings.get 'version'