rev |
line source |
bsw@211
|
1 slot.set_layout("lf2")
|
bsw@211
|
2
|
bsw@213
|
3 slot.put_into("leftright_pre", '<div class="sidebar_right">')
|
bsw@213
|
4 slot.put_into("leftright_post", '</div>')
|
bsw@213
|
5
|
bsw@211
|
6 local initiative = Initiative:by_id(param.get_id())
|
bsw@211
|
7
|
bsw@211
|
8 local issue = initiative.issue
|
bsw@213
|
9 issue:load("interest_for_member", { member_id = app.session.member_id }, "interest")
|
bsw@211
|
10
|
bsw@211
|
11 local supporting_members_selector = Member:new_selector()
|
bsw@211
|
12 :join("direct_supporter_snapshot", "dss", { "dss.issue_id = ? AND dss.initiative_id = ? AND dss.member_id = member.id and dss.event = (select latest_snapshot_event from issue where id = ?)", issue.id, initiative.id, issue.id })
|
bsw@211
|
13 :join("direct_interest_snapshot", "dis", { "dis.issue_id = ? AND dis.member_id = member.id and dis.event = (select latest_snapshot_event from issue where id = ?)", issue.id, issue.id })
|
bsw@211
|
14 :add_field("dis.weight", "weight")
|
bsw@211
|
15 :add_order_by("dis.weight DESC")
|
bsw@211
|
16 local supporting_members = supporting_members_selector:exec()
|
bsw@211
|
17
|
bsw@211
|
18 local voting_members_selector = Member:new_selector()
|
bsw@211
|
19 :join("direct_voter", nil, { "direct_voter.issue_id = ? AND direct_voter.member_id = member.id", issue.id })
|
bsw@211
|
20 :add_field("direct_voter.weight", "weight")
|
bsw@211
|
21 :add_order_by("direct_voter.weight DESC")
|
bsw@211
|
22 local voting_members = voting_members_selector:exec()
|
bsw@211
|
23
|
bsw@211
|
24 local alternative_initiatives = initiative.issue.initiatives
|
bsw@211
|
25 alternative_initiatives:load("initiating_members", nil, "initiating_members")
|
bsw@211
|
26
|
bsw@215
|
27 local support = Supporter:by_pk(initiative.id, app.session.member.id)
|
bsw@215
|
28
|
bsw@215
|
29 app.topnav_phase = issue.phase
|
bsw@215
|
30
|
bsw@211
|
31
|
bsw@211
|
32 slot.select("sidebar", function()
|
bsw@211
|
33
|
bsw@215
|
34 execute.view{ module = "lf2", view = "_sidebar_issue", params = { issue = issue, initiative_id = initiative.id, alternative_initiatives = alternative_initiatives } }
|
bsw@215
|
35
|
bsw@211
|
36 execute.view{ module = "lf2", view = "_sidebar_drafts", params = {
|
bsw@211
|
37 initiative = initiative
|
bsw@211
|
38 } }
|
bsw@211
|
39
|
bsw@211
|
40 end)
|
bsw@211
|
41
|
bsw@211
|
42 local draft = initiative.current_draft
|
bsw@211
|
43
|
bsw@211
|
44 ui.box{
|
bsw@211
|
45 content = function()
|
bsw@211
|
46
|
bsw@215
|
47 ui.box_row{ class = "initiative head2", content = function() ui.box_col { content = function()
|
bsw@211
|
48 execute.view{ module = "lf2", view = "_initiative", params = { initiative = initiative } }
|
bsw@211
|
49 end } end }
|
bsw@211
|
50
|
bsw@215
|
51 ui.box_row{ class = "head", content = function() ui.box_col{ content = function()
|
bsw@215
|
52 if initiative.issue.closed then
|
bsw@215
|
53 if initiative.issue.accepted then
|
bsw@215
|
54 if initiative.admitted then
|
bsw@215
|
55 if initiative.agreed then
|
bsw@215
|
56 if initiative.rank == 1 then
|
bsw@215
|
57 ui.image{ static = "lf2/icon_award_gold.png" }
|
bsw@215
|
58 slot.put(" ")
|
bsw@215
|
59 ui.tag{ content = _"Approved" }
|
bsw@215
|
60 else
|
bsw@215
|
61 ui.image{ static = "lf2/icon_award_silver.png" }
|
bsw@215
|
62 slot.put(" ")
|
bsw@215
|
63 ui.tag{ content = _("Not approved (rank #{rank})", { rank = initiative.rank }) }
|
bsw@215
|
64 end
|
bsw@215
|
65 else
|
bsw@215
|
66 ui.image{ static = "lf2/icon_cross.png" }
|
bsw@215
|
67 slot.put(" ")
|
bsw@215
|
68 ui.tag{ content = _"Initiative not approved" }
|
bsw@215
|
69 end
|
bsw@215
|
70 else
|
bsw@215
|
71 ui.image{ static = "lf2/icon_cross.png" }
|
bsw@215
|
72 slot.put(" ")
|
bsw@215
|
73 ui.tag{ content = _"Initiative not admitted" }
|
bsw@215
|
74 end
|
bsw@215
|
75 else
|
bsw@215
|
76 ui.image{ static = "lf2/icon_cross.png" }
|
bsw@215
|
77 slot.put(" ")
|
bsw@215
|
78 ui.tag{ content = _"Issue not accepted" }
|
bsw@215
|
79 end
|
bsw@215
|
80 slot.put(" ")
|
bsw@215
|
81 end
|
bsw@215
|
82
|
bsw@211
|
83 if initiative.issue.fully_frozen and initiative.issue.closed then
|
bsw@215
|
84 if initiative.admitted and initiative.issue.ranks_available then
|
bsw@215
|
85 slot.put(" · ")
|
bsw@215
|
86 ui.link{ external = "#votes", text = _("#{vote_count}+#{delegated_weight} votes", { vote_count = #voting_members, delegated_weight = initiative.issue.voter_count - #voting_members }) }
|
bsw@215
|
87 end
|
bsw@215
|
88 end
|
bsw@215
|
89 if initiative.issue.closed then
|
bsw@211
|
90 slot.put(" · ")
|
bsw@211
|
91 end
|
bsw@211
|
92 ui.link{ external = "#suggestions", text = _("#{suggestion_count} suggestions", { suggestion_count = 23 }) }
|
bsw@211
|
93 slot.put(" · ")
|
bsw@215
|
94 ui.link{ external = "#supporters", text = _("#{supporter_count}+#{delegated_weight} supporters", { supporter_count = #supporting_members, delegated_weight = initiative.supporter_count - #supporting_members }) }
|
bsw@211
|
95 end } end }
|
bsw@211
|
96
|
bsw@215
|
97 execute.view{ module = "lf2", view = "_initiative_support", params = {
|
bsw@215
|
98 initiative = initiative
|
bsw@215
|
99 } }
|
bsw@215
|
100
|
bsw@215
|
101 ui.box_row{ class = "subhead", content = function() ui.box_col{ class = "head", content = _"Current draft" } end }
|
bsw@211
|
102 ui.box_row{ content = function() ui.box_col{ content = function()
|
bsw@211
|
103 execute.view{ module = "lf2", view = "_draft", params = { draft = draft } }
|
bsw@211
|
104 end } end }
|
bsw@211
|
105
|
bsw@215
|
106 if initiative.issue.fully_frozen and initiative.issue.closed then
|
bsw@215
|
107 ui.box_row{ class = "subhead", content = function() ui.box_col{ class = "head", content = _"Voters" } end }
|
bsw@211
|
108 ui.box_row{ content = function() ui.box_col{ content = function()
|
bsw@211
|
109 execute.view{ module = "lf2", view = "_avatars", params = { members = voting_members } }
|
bsw@211
|
110 end } end }
|
bsw@211
|
111 end
|
bsw@211
|
112
|
bsw@215
|
113 ui.box_row{ class = "subhead", content = function() ui.box_col{ class = "head", content = _"Suggestions" } end }
|
bsw@211
|
114 ui.box_row{ content = function() ui.box_col{ content = function()
|
bsw@211
|
115 slot.put("suggestions")
|
bsw@211
|
116 end } end }
|
bsw@215
|
117
|
bsw@215
|
118 ui.box_row{ class = "subhead", content = function() ui.box_col{ class = "head", content = _"Supporters" } end }
|
bsw@211
|
119 ui.box_row{ content = function() ui.box_col{ content = function()
|
bsw@211
|
120 execute.view{ module = "lf2", view = "_avatars", params = { members = supporting_members } }
|
bsw@211
|
121 end } end }
|
bsw@215
|
122
|
bsw@215
|
123 end }
|