History

Improve 'Updates' notification

Thibaut Courouble committed 10 years ago

Commit 430524f1 parent 4c2a5562 files · +30 −11Browse files

Unified · Split

2 files
  1. assets/javascripts/templates/notif_tmpl.coffee +21 −8
  2. assets/javascripts/views/misc/updates.coffee +9 −3
assets/javascripts/templates/notif_tmpl.coffee+21−8
@@ -26,14 +26,27 @@ app.templates.notifInvalidLocation = -> · 25 unmodified lines
2626 app.templates.notifNews = (news) ->
2727 notif 'Changelog', """<div class="_notif-content _notif-news">#{app.templates.newsList(news, years: false)}</div>"""
2828
29−app.templates.notifUpdates = (docs) ->
30− html = """<ul class="_notif-content _notif-list">"""
31− for doc in docs
32− html += "<li>#{doc.name}"
33− html += " (#{doc.release})" if doc.release
34− html += "</li>"
35− html += "</ul>"
36− notif 'Updates', html
29+app.templates.notifUpdates = (docs, disabledDocs) ->
30+ html = '<div class="_notif-content _notif-news">'
31+
32+ if docs.length > 0
33+ html += '<div class="_news-row">'
34+ html += '<ul class="_notif-list">'
35+ for doc in docs
36+ html += "<li>#{doc.name}"
37+ html += " <code>&rarr;</code> #{doc.release}" if doc.release
38+ html += '</ul></div>'
39+
40+ if disabledDocs.length > 0
41+ html += '<div class="_news-row"><p class="_news-title">Disabled:'
42+ html += '<ul class="_notif-list">'
43+ for doc in disabledDocs
44+ html += "<li>#{doc.name}"
45+ html += " <code>&rarr;</code> #{doc.release}" if doc.release
46+ html += """<span class="_notif-info"><a data-pick-docs>Enable</a></span>"""
47+ html += '</ul></div>'
48+
49+ notif 'Updates', "#{html}</div>"
3750
3851 app.templates.notifShare = ->
3952 textNotif """ Hi there! """,
assets/javascripts/views/misc/updates.coffee+9−3
@@ -7,18 +7,24 @@ class app.views.Updates extends app.views.Notif · 6 unmodified lines
77 autoHide: 30000
88
99 init: ->
10+ @lastUpdateTime = @getLastUpdateTime()
1011 @updatedDocs = @getUpdatedDocs()
12+ @updatedDisabledDocs = @getUpdatedDisabledDocs()
1113 @show() if @updatedDocs.length
1214 @markAllAsRead()
1315 return
1416
1517 render: ->
16− @html app.templates.notifUpdates(@updatedDocs)
18+ @html app.templates.notifUpdates(@updatedDocs, @updatedDisabledDocs)
1719 return
1820
1921 getUpdatedDocs: ->
20− return [] unless time = @getLastUpdateTime()
21− doc for doc in app.docs.all() when doc.mtime > time
22+ return [] unless @lastUpdateTime
23+ doc for doc in app.docs.all() when doc.mtime > @lastUpdateTime
24+
25+ getUpdatedDisabledDocs: ->
26+ return [] unless @lastUpdateTime
27+ doc for doc in app.disabledDocs.all() when doc.mtime > @lastUpdateTime and app.docs.findBy('slug_without_version', doc.slug_without_version)
2228
2329 getLastUpdateTime: ->
2430 app.settings.get 'version'