liquid_feedback_frontend
view app/main/delegation/_show_box.lua @ 23:e04122245a44
Bugfix in app/main/initiative/show_static.lua: Added neccessary "expanded" argument
author | bsw |
---|---|
date | Sun Feb 21 13:09:00 2010 +0100 (2010-02-21) |
parents | 00d1004545f1 |
children | bf885faf3452 |
line source
1 function change_delegation(scope, area_id, issue, delegation)
2 local image
3 local text
4 if scope == "global" and delegation then
5 image = { static = "icons/16/table_go.png" }
6 text = _"Change global delegation"
7 elseif scope == "global" and not delegation then
8 image = { static = "icons/16/table_go.png" }
9 text = _"Set global delegation"
10 elseif scope == "area" and delegation and delegation.area_id then
11 image = { static = "icons/16/table_go.png" }
12 text = _"Change area delegation"
13 elseif scope == "area" and not (delegation and delegation.area_id) then
14 image = { static = "icons/16/table_go.png" }
15 text = _"Set area delegation"
16 elseif scope == "issue" then
17 if delegation and delegation.issue_id then
18 image = { static = "icons/16/table_go.png" }
19 text = _"Change issue delegation"
20 elseif issue.state ~= "finished" and issue.state ~= "cancelled" then
21 image = { static = "icons/16/table_go.png" }
22 text = _"Set issue delegation"
23 end
24 end
25 ui.container{
26 attr = {
27 class = "change_delegation",
28 },
29 content = function()
30 ui.link{
31 image = image,
32 text = text,
33 module = "delegation",
34 view = "new",
35 params = {
36 issue_id = issue and issue.id or nil,
37 area_id = area_id
38 },
39 }
40 if delegation then
41 ui.link{
42 image = { static = "icons/16/delete.png" },
43 text = _"Revoke",
44 module = "delegation",
45 action = "update",
46 params = { issue_id = delegation.issue_id, area_id = delegation.area_id, delete = true },
47 routing = {
48 default = {
49 mode = "redirect",
50 module = request.get_module(),
51 view = request.get_view(),
52 id = param.get_id_cgi(),
53 params = param.get_all_cgi()
54 }
55 }
56 }
57 end
58 end
59 }
60 end
62 local delegation
63 local area_id
64 local issue_id
66 local scope = "global"
68 if param.get("initiative_id", atom.integer) then
69 issue_id = Initiative:by_id(param.get("initiative_id", atom.integer)).issue_id
70 scope = "issue"
71 end
73 if param.get("issue_id", atom.integer) then
74 issue_id = param.get("issue_id", atom.integer)
75 scope = "issue"
76 end
78 if param.get("area_id", atom.integer) then
79 area_id = param.get("area_id", atom.integer)
80 scope = "area"
81 end
85 local delegation
86 local issue
87 if issue_id then
88 issue = Issue:by_id(issue_id)
89 delegation = Delegation:by_pk(app.session.member.id, nil, issue_id)
90 if not delegation then
91 delegation = Delegation:by_pk(app.session.member.id, issue.area_id)
92 end
93 elseif area_id then
94 delegation = Delegation:by_pk(app.session.member.id, area_id)
95 end
97 if not delegation then
98 delegation = Delegation:by_pk(app.session.member.id)
99 end
102 slot.select("actions", function()
104 if delegation then
105 ui.container{
106 attr = { class = "delegation vote_info"},
107 content = function()
108 ui.container{
109 attr = {
110 title = _"Click for details",
111 class = "head head_active",
112 style = "cursor: pointer;",
113 onclick = "document.getElementById('delegation_content').style.display = 'block';"
114 },
115 content = function()
116 ui.image{
117 static = "icons/16/error.png"
118 }
119 if delegation.issue_id then
120 slot.put(_"Issue delegation active")
121 elseif delegation.area_id then
122 slot.put(_"Area wide delegation active")
123 else
124 slot.put(_"Global delegation active")
125 end
126 ui.image{
127 static = "icons/16/dropdown.png"
128 }
129 end
130 }
131 ui.container{
132 attr = { class = "content", id = "delegation_content" },
133 content = function()
134 ui.container{
135 attr = {
136 class = "close",
137 style = "cursor: pointer;",
138 onclick = "document.getElementById('delegation_content').style.display = 'none';"
139 },
140 content = function()
141 ui.image{ static = "icons/16/cross.png" }
142 end
143 }
145 local delegation_chain = Member:new_selector()
146 :add_field("delegation_chain.*")
147 :join("delegation_chain(" .. tostring(app.session.member.id) .. ", " .. tostring(area_id or "NULL") .. ", " .. tostring(issue_id or "NULL") .. ")", "delegation_chain", "member.id = delegation_chain.member_id")
148 :add_order_by("index")
149 :exec()
151 if not issue or (issue.state ~= "finished" and issue.state ~= "cancelled") then
152 change_delegation(scope, area_id, issue, delegation)
153 end
155 for i, record in ipairs(delegation_chain) do
156 local style
157 local overridden = record.overridden
158 if record.scope_in then
159 ui.container{
160 attr = { class = "delegation_info" },
161 content = function()
162 if not overridden then
163 ui.image{
164 attr = { class = "delegation_arrow" },
165 static = "delegation_arrow_vertical.jpg"
166 }
167 else
168 ui.image{
169 attr = { class = "delegation_arrow delegation_arrow_overridden" },
170 static = "delegation_arrow_vertical.jpg"
171 }
172 end
173 ui.container{
174 attr = { class = "delegation_scope" .. (overridden and " delegation_scope_overridden" or "") },
175 content = function()
176 if record.scope_in == "global" then
177 slot.put(_"Global delegation")
178 elseif record.scope_in == "area" then
179 slot.put(_"Area delegation")
180 elseif record.scope_in == "issue" then
181 slot.put(_"Issue delegation")
182 end
183 end
184 }
185 end
186 }
187 end
188 ui.container{
189 attr = { class = overridden and "delegation_overridden" or "" },
190 content = function()
191 execute.view{
192 module = "member",
193 view = "_show_thumb",
194 params = { member = record }
195 }
196 end
197 }
198 if record.participation and not record.overridden then
199 ui.container{
200 attr = { class = "delegation_participation" },
201 content = function()
202 slot.put(_"This member is participating, the rest of delegation chain is suspended while discussing")
203 end
204 }
205 end
206 slot.put("<br style='clear: left'/>")
207 end
208 end
209 }
210 end
211 }
212 else
213 change_delegation(scope, area_id, issue)
214 end
215 end)