liquid_feedback_frontend
view app/main/lf2/_sidebar_issue.lua @ 214:7e3acb2f6284
Disable current member as delegation target through initiatorship
author | bsw |
---|---|
date | Thu Mar 03 23:47:35 2011 +0100 (2011-03-03) |
parents | acf92c2d33f4 |
children | 1dab81353eb1 |
line source
1 local issue = param.get("issue", "table")
2 local initiative_id = param.get("initiative_id", atom.integer)
4 local initiatives = issue.initiatives
6 local interested_members_selector = Member:new_selector()
7 :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 })
8 :add_field("dis.weight", "weight")
9 :add_order_by("dis.weight DESC")
10 local interested_members = interested_members_selector:exec()
12 local interest = issue.interest
14 local trustees = Member:new_selector()
15 :add_field("delegation_chain.*")
16 :join("delegation_chain(" .. tostring(app.session.member.id) .. ", NULL, " .. tostring(issue.id or "NULL") .. ")", "delegation_chain", "member.id = delegation_chain.member_id")
17 :add_order_by("index")
18 :exec()
20 local delegating_interest = issue.delegating_interest
22 ui.box{ class = "issue", content = function()
24 ui.box_row{ class = "issue_id head", content = function() ui.box_col{ class = "head", content = function()
25 ui.link{
26 module = "lf2", view = "issue", id = issue.id,
27 content = _("Issue ##{id}", { id = issue.id })
28 }
29 end } end }
31 ui.box_row{ class = "unit_name head2", content = function() ui.box_col{ content = function()
32 ui.link{
33 module = "lf2", view = "unit", id = 1,
34 content = "DE / Berlin / Friedrichshain-Kreuzberg"
35 }
36 end } end }
38 ui.box_row{ class = "area_name head2", content = function() ui.box_col{ content = function()
39 ui.link{
40 module = "lf2", view = "area", id = issue.area_id,
41 content = issue.area.name
42 }
43 end } end }
45 ui.box_row{ class = "policy_name head2", content = function() ui.box_col{ content = function()
46 ui.link{
47 module = "lf2", view = "policy", id = issue.policy_id,
48 content = issue.policy.name
49 }
50 end } end }
52 ui.box_row{ class = "time_left", content = function()
53 ui.box_col{ content = issue.closed and _("Closed since #{date}", { date = format.date(issue.closed.date) }) or _("#{time_left} left", { time_left = issue.state_time_left }) }
54 end }
56 ui.box_row{ class = "interest hoverbutton_container", content = function() ui.box_col{ content = function()
57 if interest then
58 ui.image{ static = "lf2/icon_star.png" }
59 if issue.closed then
60 slot.put(" ", _"You were interested in this issue")
61 else
62 slot.put(" ", _"You are interested in this issue")
63 end
64 else
65 if not issue.closed and not issue.fully_frozen then
66 ui.image{ static = "lf2/icon_star_grey.png" }
67 end
68 slot.put(_"You are not interested in this issue")
69 end
71 if issue.closed then
72 ui.container{ attr = { class = "hoverbutton noaction"}, content = function()
73 ui.container{ attr = { class = "content"}, content = function()
74 slot.put(" ", encode.html(_"This issue is closed"))
75 end }
76 end }
77 elseif issue.fully_frozen then
78 ui.container{ attr = { class = "hoverbutton noaction"}, content = function()
79 ui.container{ attr = { class = "content"}, content = function()
80 slot.put(" ", encode.html(_"This issue is in voting"))
81 end }
82 end }
83 else
84 if interest then
85 ui.link{
86 module = "interest", action = "update", params = { issue_id = issue.id, delete = true },
87 routing = { default = {
88 mode = "redirect", module = "lf2", view = initiative_id and "initiative" or "issue", id = initiative_id or issue.id,
89 } },
90 attr = { class = "hoverbutton red"},
91 content = function()
92 ui.container{ attr = { class = "content"}, content = function()
93 ui.image{ static = "lf2/icon_star_crossed.png" }
94 slot.put(" ", encode.html(_"Remove my interest"))
95 end }
96 end
97 }
99 else
100 ui.link{
101 module = "interest", action = "update", params = { issue_id = issue.id },
102 routing = { default = {
103 mode = "redirect", module = "lf2", view = initiative_id and "initiative" or "issue", id = initiative_id or issue.id,
104 } },
105 attr = { class = "hoverbutton green"},
106 content = function()
107 ui.container{ attr = { class = "content"}, content = function()
108 ui.image{ static = "lf2/icon_star.png" }
109 slot.put(" ", encode.html(_"Add my interest"))
110 end
111 }
112 end }
114 end
115 end
116 end } end }
118 ui.box_row{ class = "delegation hoverbutton_container", content = function() ui.box_col{ content = function()
119 if trustees[1].scope_out then
120 if trustees[1].disabled_out == false then
121 if trustees[1].scope_out == "issue" then
122 slot.put(encode.html(_"You have delegated this issue"))
123 elseif trustees[1].scope_out == "area" then
124 slot.put(encode.html(_"You have delegated this area"))
125 elseif trustees[1].scope_out == "global" then
126 slot.put(encode.html(_"You have delegated globally"))
127 end
128 else
129 if trustees[1].scope_out == "issue" then
130 slot.put(encode.html(_"Issue delegation abandoned"))
131 elseif trustees[1].scope_out == "area" then
132 slot.put(encode.html(_"Area delegation abandoned"))
133 elseif trustees[1].scope_out == "global" then
134 slot.put(encode.html(_"Global delegation abandoned"))
135 end
136 end
137 else
138 slot.put(encode.html(_"No delegation active"))
139 end
141 if issue.closed then
142 ui.container{ attr = { class = "hoverbutton noaction"}, content = function()
143 ui.container{ attr = { class = "content"}, content = function()
144 slot.put(" ", encode.html(_"This issue is closed"))
145 end }
146 end }
147 else
148 if #trustees > 1 then
149 ui.link{
150 module = "lf2", view = "delegation", params = { issue_id = issue.id, initiative_id = initiative_id },
151 attr = { class = "hoverbutton red"}, content = function()
152 ui.container{ attr = { class = "content"}, content = function()
153 ui.image{ static = "lf2/icon_delegation.png" }
154 slot.put(" ", encode.html(_"Change issue delegation..."))
155 end }
156 end }
158 else
159 ui.link{
160 module = "lf2", view = "delegation", params = { issue_id = issue.id, initiative_id = initiative_id },
161 attr = { class = "hoverbutton green"}, content = function()
162 ui.container{ attr = { class = "content"}, content = function()
163 ui.image{ static = "lf2/icon_delegation.png" }
164 slot.put(" ")
165 slot.put(" ", encode.html(_"Set issue delegation..."))
167 end }
168 end }
170 end
171 end
173 end } end }
175 if #trustees > 1 then
176 ui.box_row{ class = "delegation", content = function() ui.box_col{ content = function()
177 execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small" } }
178 end } end }
179 end
181 end }