liquid_feedback_frontend
diff app/main/index/_notifications.lua @ 558:18e8de7a2b6a
Show notifications on start page as ulli list with links instead of tabs
author | bsw |
---|---|
date | Tue Jun 19 21:20:46 2012 +0200 (2012-06-19) |
parents | |
children | afd406d96044 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/app/main/index/_notifications.lua Tue Jun 19 21:20:46 2012 +0200 1.3 @@ -0,0 +1,79 @@ 1.4 +local notification_links = {} 1.5 + 1.6 +if app.session.member.notify_email_unconfirmed then 1.7 + notification_links[#notification_links+1] = { 1.8 + module = "index", view = "email_unconfirmed", 1.9 + text = _"Please confirm your email address" 1.10 + } 1.11 +end 1.12 + 1.13 +if app.session.member.notify_level == nil then 1.14 + notification_links[#notification_links+1] = { 1.15 + module = "member", view = "settings_notification", 1.16 + text = _"Please select your preferred notification level" 1.17 + } 1.18 +end 1.19 + 1.20 +local broken_delegations_count = Delegation:selector_for_broken(app.session.member_id):count() 1.21 + 1.22 +if broken_delegations_count > 0 then 1.23 + notification_links[#notification_links+1] = { 1.24 + module = "index", view = "broken_delegations", 1.25 + text = _("#{count} of your outgoing delegation(s) are broken", { count = broken_delegations_count }) 1.26 + } 1.27 + 1.28 +end 1.29 + 1.30 +local selector = Issue:new_selector() 1.31 + :join("area", nil, "area.id = issue.area_id") 1.32 + :join("privilege", nil, { "privilege.unit_id = area.unit_id AND privilege.member_id = ? AND privilege.voting_right", app.session.member_id }) 1.33 + :left_join("direct_voter", nil, { "direct_voter.issue_id = issue.id AND direct_voter.member_id = ?", app.session.member.id }) 1.34 + :left_join("interest", nil, { "interest.issue_id = issue.id AND interest.member_id = ?", app.session.member.id }) 1.35 + :add_where{ "direct_voter.member_id ISNULL" } 1.36 + :add_where{ "interest.member_id NOTNULL" } 1.37 + :add_where{ "issue.fully_frozen NOTNULL" } 1.38 + :add_where{ "issue.closed ISNULL" } 1.39 + :add_order_by{ "issue.fully_frozen + issue.voting_time ASC" } 1.40 + 1.41 +local issues_to_vote_count = selector:count() 1.42 +if issues_to_vote_count > 0 then 1.43 + notification_links[#notification_links+1] = { 1.44 + module = "index", view = "index", 1.45 + params = { 1.46 + tab = "open", filter = "frozen", filter_interest = "issue", filter_voting = "not_voted" 1.47 + }, 1.48 + text = _("You have not voted #{count} issue(s) you was interested in", { count = issues_to_vote_count }) 1.49 + } 1.50 +end 1.51 + 1.52 +local initiator_invites_count = Initiator:selector_for_invites(app.session.member_id):count() 1.53 + 1.54 +if initiator_invites_count > 0 then 1.55 + notification_links[#notification_links+1] = { 1.56 + module = "index", view = "initiator_invites", 1.57 + text = _("You are invited to #{count} initiative(s)", { count = initiator_invites_count }) 1.58 + } 1.59 +end 1.60 + 1.61 +updated_drafts_count = Initiative:selector_for_updated_drafts(app.session.member_id):count() 1.62 + 1.63 +if updated_drafts_count > 0 then 1.64 + notification_links[#notification_links+1] = { 1.65 + module = "index", view = "updated_drafts", 1.66 + text = _("New drafts for #{count} initiative(s) you are supporting", { count = updated_drafts_count }) 1.67 + } 1.68 +end 1.69 + 1.70 +if #notification_links > 0 then 1.71 + ui.container{ attr = { class = "notifications" }, content = function() 1.72 + ui.tag{ tag = "ul", attr = { class = "notifications" }, content = function() 1.73 + for i, notification_link in ipairs(notification_links) do 1.74 + ui.tag{ tag = "li", content = function() 1.75 + ui.link(notification_link) 1.76 + end } 1.77 + end 1.78 + end } 1.79 + end } 1.80 +end 1.81 + 1.82 +