liquid_feedback_frontend
view app/main/issue/_show_head.lua @ 273:7196685f9dd7
More optical enhancements, more repositioning
author | bsw |
---|---|
date | Wed Feb 08 18:49:22 2012 +0100 (2012-02-08) |
parents | 65a1f7a01e7b |
children | aec9df5b4cd3 |
line source
1 local issue = param.get("issue", "table")
2 local initiative = param.get("initiative", "table")
4 local direct_voter
6 if app.session.member_id then
7 direct_voter = DirectVoter:by_pk(issue.id, app.session.member.id)
8 end
10 if config.feature_rss_enabled then
11 util.html_rss_head{ title = _"Initiatives in this issue (last created first)", module = "initiative", view = "list_rss", params = { issue_id = issue.id } }
12 util.html_rss_head{ title = _"Initiatives in this issue (last updated first)", module = "initiative", view = "list_rss", params = { issue_id = issue.id, order = "last_updated" } }
13 end
15 slot.select("path", function()
16 end)
18 slot.select("title", function()
19 ui.link{
20 content = _("Issue ##{id}", { id = issue.id }),
21 module = "issue",
22 view = "show",
23 id = issue.id
24 }
25 slot.put(" · ")
26 ui.link{
27 content = issue.area.name,
28 module = "area",
29 view = "show",
30 id = issue.area.id
31 }
32 if not config.single_unit_id then
33 slot.put(" · ")
34 ui.link{
35 content = issue.area.unit.name,
36 module = "area",
37 view = "list",
38 params = { unit_id = issue.area.unit_id }
39 }
40 end
41 end)
44 slot.select("title2", function()
45 ui.tag{
46 tag = "div",
47 content = function()
49 local initiative_count = issue:get_reference_selector("initiatives"):count()
50 local text
51 if initiative_count == 1 then
52 text = _("1 initiative", { count = initiative_count })
53 else
54 text = _("#{count} initiatives", { count = initiative_count })
55 end
56 ui.link{
57 text = text,
58 module = "issue", view = "show", id = issue.id
59 }
61 slot.put(" · ")
62 ui.link{
63 text = issue.policy.name,
64 module = "policy",
65 view = "show",
66 id = issue.policy.id
67 }
69 slot.put(" · ")
70 ui.tag{ content = issue.state_name }
72 if issue.state_time_left then
73 slot.put(" · ")
74 ui.tag{ content = _("#{time_left} left", { time_left = issue.state_time_left }) }
75 end
77 if issue.next_states_names then
78 slot.put(" · ")
79 ui.tag{ content = _("Next state: #{state}", { state = issue.next_states_names }) }
80 end
81 end
82 }
85 end)
88 --[[
89 slot.select("content_navigation", function()
91 if app.session.member_id then
92 local records
93 local this = 0
94 local issues_selector = Issue:new_selector()
96 -- FIXME: !DRY
97 local issue_filter_map = {
98 new = "new.png",
99 accepted = "comments.png",
100 half_frozen = "lock.png",
101 frozen ="email_open.png",
102 finished = "tick.png",
103 cancelled = "cross.png",
104 }
107 local mk_link = function(index, text, icon, module)
108 content = function()
109 if index > 0 then
110 slot.put(text)
111 ui.image{ static = "icons/16/"..icon }
112 else
113 ui.image{ static = "icons/16/"..icon }
114 slot.put(text)
115 end
116 end
117 if records[this+index] then
118 ui.link{
119 content = content,
120 module = module,
121 view = "show",
122 id = records[this+index].id,
123 }
124 else
125 ui.container{
126 content = content,
127 }
128 end
129 end
131 issues_selector
132 :add_where{"issue.area_id = ?", issue.area.id}
134 local filters = execute.load_chunk{module="issue", chunk="_filters.lua", params = {filter = "frozen"}}
136 local state = issue.state
138 -- FIXME: fix filter names to reflect issue.state values
139 if state == "voting" then
140 state = "frozen"
141 elseif state == "frozen" then
142 state = "half_frozen"
143 end
145 filter = filters:get_filter("filter", state)
146 if filter then
147 filter.selector_modifier(issues_selector)
149 -- add subfilter to voting pager, so only not voted entries will be shown
150 -- as this seems the most usefull exception
151 if filter.name == "frozen" then
152 filter_voting_name = "not_voted"
153 local vfilter = filters:get_filter("filter_voting", "not_voted")
154 if vfilter then
155 vfilter.selector_modifier(issues_selector)
156 end
157 end
158 end
160 records = issues_selector:exec()
162 for i,cissue in ipairs(records) do
163 if cissue.id == issue.id then
164 this = i
165 break
166 end
167 end
169 mk_link(-1, _("Previous issue"), "resultset_previous.png", "issue")
170 if issue.area then
171 ui.link{
172 content = function()
173 if issue_filter_map[state] then
174 ui.image{ static = "icons/16/"..issue_filter_map[state] }
175 end
176 slot.put(issue.area.name)
177 end,
178 module = "area",
179 view = "show",
180 id = issue.area.id,
181 params = {
182 filter = filter and filter.name or nil,
183 filter_voting = filter_voting_name,
184 tab = "issues"
185 }
186 }
187 end
188 mk_link(1, _("Next issue"), "resultset_next.png", "issue")
190 -- show pager for initiatives if available
191 if initiative then
192 ui.container{ content = function() end, attr = {class = "content_navigation_seperator"}}
194 records = issue:get_reference_selector("initiatives"):exec()
195 for i,cissue in ipairs(records) do
196 if cissue.id == initiative.id then
197 this = i
198 break
199 end
200 end
201 mk_link(-1, _("Previous initiative"), "resultset_previous.png", "initiative")
202 mk_link(1, _("Next initiative"), "resultset_next.png", "initiative")
203 end
204 end
205 end
207 )
208 --]]
210 slot.select("actions", function()
212 if app.session.member_id then
214 if issue.state == 'voting' then
215 local text
216 if not direct_voter then
217 text = _"Vote now"
218 else
219 text = _"Change vote"
220 end
221 ui.link{
222 content = function()
223 ui.image{ static = "icons/16/email_open.png" }
224 slot.put(text)
225 end,
226 module = "vote",
227 view = "list",
228 params = { issue_id = issue.id }
229 }
230 end
232 execute.view{
233 module = "interest",
234 view = "_show_box",
235 params = { issue = issue }
236 }
238 if not issue.closed then
239 execute.view{
240 module = "delegation",
241 view = "_show_box",
242 params = { issue_id = issue.id,
243 initiative_id = initiative and initiative.id or nil}
244 }
245 end
247 end
249 if config.issue_discussion_url_func then
250 local url = config.issue_discussion_url_func(issue)
251 ui.link{
252 attr = { target = "_blank" },
253 external = url,
254 content = function()
255 ui.image{ static = "icons/16/comments.png" }
256 slot.put(_"Discussion on issue")
257 end,
258 }
259 end
260 end)
262 if app.session.member_id then
263 slot.select("actions", function()
264 if not issue.fully_frozen and not issue.closed then
265 ui.link{
266 image = { static = "icons/16/script_add.png" },
267 attr = { class = "action" },
268 text = _"Create alternative initiative",
269 module = "initiative",
270 view = "new",
271 params = { issue_id = issue.id }
272 }
273 end
274 end)
275 end
277 local issue = param.get("issue", "table")
281 -- ui.twitter("http://example.com/t" .. tostring(issue.id))
283 if config.public_access_issue_head and not app.session.member_id then
284 config.public_access_issue_head(issue)
285 end
287 if app.session.member_id and issue.state == 'voting' and not direct_voter then
288 ui.container{
289 attr = { class = "voting_active_info" },
290 content = function()
291 slot.put(_"Voting for this issue is currently running!")
292 slot.put(" ")
293 if app.session.member_id then
294 ui.link{
295 content = function()
296 slot.put(_"Vote now")
297 end,
298 module = "vote",
299 view = "list",
300 params = { issue_id = issue.id }
301 }
302 end
303 end
304 }
305 slot.put("<br />")
306 end