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
26app.templates.notifNews = (news) ->26app.templates.notifNews = (news) ->
27 notif 'Changelog', """<div class="_notif-content _notif-news">#{app.templates.newsList(news, years: false)}</div>"""27 notif 'Changelog', """<div class="_notif-content _notif-news">#{app.templates.newsList(news, years: false)}</div>"""
28 28
29app.templates.notifUpdates = (docs) ->29app.templates.notifUpdates = (docs, disabledDocs) ->
30 html = """<ul class="_notif-content _notif-list">"""30 html = '<div class="_notif-content _notif-news">'
31 for doc in docs31
32 html += "<li>#{doc.name}"32 if docs.length > 0
33 html += " (#{doc.release})" if doc.release33 html += '<div class="_news-row">'
34 html += "</li>"34 html += '<ul class="_notif-list">'
35 html += "</ul>"35 for doc in docs
36 notif 'Updates', html36 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>"
37 50
38app.templates.notifShare = ->51app.templates.notifShare = ->
39 textNotif """ Hi there! """,52 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
7 autoHide: 300007 autoHide: 30000
8 8
9 init: ->9 init: ->
10 @lastUpdateTime = @getLastUpdateTime()
10 @updatedDocs = @getUpdatedDocs()11 @updatedDocs = @getUpdatedDocs()
12 @updatedDisabledDocs = @getUpdatedDisabledDocs()
11 @show() if @updatedDocs.length13 @show() if @updatedDocs.length
12 @markAllAsRead()14 @markAllAsRead()
13 return15 return
14 16
15 render: ->17 render: ->
16 @html app.templates.notifUpdates(@updatedDocs)18 @html app.templates.notifUpdates(@updatedDocs, @updatedDisabledDocs)
17 return19 return
18 20
19 getUpdatedDocs: ->21 getUpdatedDocs: ->
20 return [] unless time = @getLastUpdateTime()22 return [] unless @lastUpdateTime
21 doc for doc in app.docs.all() when doc.mtime > time23 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)
22 28
23 getLastUpdateTime: ->29 getLastUpdateTime: ->
24 app.settings.get 'version'30 app.settings.get 'version'