liquid_feedback_frontend
view app/main/index/show_tab.lua @ 124:f740026b1518
add initiator support in delegation
if a delegation is issued from the initiative view, the initiators
from that one are added to the delegation target list. this makes it easier to delegate to the author without the need to add him to the contact list.
if a delegation is issued from the initiative view, the initiators
from that one are added to the delegation target list. this makes it easier to delegate to the author without the need to add him to the contact list.
author | Daniel Poelzleithner <poelzi@poelzi.org> |
---|---|
date | Mon Sep 20 20:32:04 2010 +0200 (2010-09-20) |
parents | 4f39f0a0d5b5 |
children |
line source
1 local tabs = {
2 module = "index",
3 view = "show_tab"
4 }
6 local selector = Area:new_selector()
7 :reset_fields()
8 :add_field("area.id", nil, { "grouped" })
9 :add_field("area.name", nil, { "grouped" })
10 :add_field("membership.member_id NOTNULL", "is_member", { "grouped" })
11 :add_field("count(issue.id)", "issues_to_vote_count")
12 :add_field("count(interest.member_id)", "interested_issues_to_vote_count")
13 :add_field("count(interest.member_id NOTNULL OR interest.member_id NOTNULL)", "issues_to_vote_count_sum")
14 :join("issue", nil, "issue.area_id = area.id AND issue.fully_frozen NOTNULL AND issue.closed ISNULL")
15 :left_join("direct_voter", nil, { "direct_voter.issue_id = issue.id AND direct_voter.member_id = ?", app.session.member.id })
16 :add_where{ "direct_voter.member_id ISNULL" }
17 :left_join("interest", nil, { "interest.issue_id = issue.id AND interest.member_id = ?", app.session.member.id })
18 :left_join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ? ", app.session.member.id })
20 local not_voted_areas = {}
21 local issues_to_vote_count = 0
22 for i, area in ipairs(selector:exec()) do
23 if area.is_member or area.interested_issues_to_vote_count > 0 then
24 not_voted_areas[#not_voted_areas+1] = area
25 end
26 issues_to_vote_count = issues_to_vote_count + area.issues_to_vote_count_sum
27 end
29 tabs[#tabs+1] = {
30 name = "not_voted_issues",
31 label = _"Not voted issues" .. " (" .. tostring(issues_to_vote_count) .. ")",
32 icon = { static = "icons/16/email_open.png" },
33 module = "index",
34 view = "_not_voted_issues",
35 params = {
36 areas = not_voted_areas
37 }
38 }
40 local initiator_invites_selector = Initiative:new_selector()
41 :join("issue", "_issue_state", "_issue_state.id = initiative.issue_id")
42 :join("initiator", nil, { "initiator.initiative_id = initiative.id AND initiator.member_id = ? AND initiator.accepted ISNULL", app.session.member.id })
43 :add_where("_issue_state.closed ISNULL AND _issue_state.half_frozen ISNULL")
45 tabs[#tabs+1] = {
46 name = "initiator_invites",
47 label = _"Initiator invites" .. " (" .. tostring(initiator_invites_selector:count()) .. ")",
48 icon = { static = "icons/16/email_open.png" },
49 module = "index",
50 view = "_initiator_invites",
51 params = {
52 initiatives_selector = initiator_invites_selector
53 }
54 }
56 local updated_drafts_selector = Initiative:new_selector()
57 :join("issue", "_issue_state", "_issue_state.id = initiative.issue_id AND _issue_state.closed ISNULL AND _issue_state.fully_frozen ISNULL")
58 :join("current_draft", "_current_draft", "_current_draft.initiative_id = initiative.id")
59 :join("supporter", "supporter", { "supporter.member_id = ? AND supporter.initiative_id = initiative.id AND supporter.draft_id < _current_draft.id", app.session.member_id })
61 tabs[#tabs+1] = {
62 name = "updated_drafts",
63 label = _"Updated drafts" .. " (" .. tostring(updated_drafts_selector:count()) .. ")",
64 icon = { static = "icons/16/email_open.png" },
65 module = "index",
66 view = "_updated_drafts",
67 params = {
68 initiatives_selector = updated_drafts_selector
69 }
70 }
72 ui.tabs(tabs)