liquid_feedback_frontend
view app/main/issue/_show_head.lua @ 272:65a1f7a01e7b
More optical enhancements and repositioning of elements
author | bsw |
---|---|
date | Wed Feb 08 00:55:17 2012 +0100 (2012-02-08) |
parents | d13b27a37ad5 |
children | 7196685f9dd7 |
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 slot.put(" · ")
73 local time_left = issue.state_time_left
74 if time_left then
75 ui.tag{ content = _("#{time_left} left", { time_left = time_left }) }
76 end
78 slot.put(" · ")
79 local next_state_names = issue.next_states_names
80 if next_state_names then
81 ui.tag{ content = _("Next state: #{state}", { state = next_state_names }) }
82 end
83 end
84 }
87 end)
90 --[[
91 slot.select("content_navigation", function()
93 if app.session.member_id then
94 local records
95 local this = 0
96 local issues_selector = Issue:new_selector()
98 -- FIXME: !DRY
99 local issue_filter_map = {
100 new = "new.png",
101 accepted = "comments.png",
102 half_frozen = "lock.png",
103 frozen ="email_open.png",
104 finished = "tick.png",
105 cancelled = "cross.png",
106 }
109 local mk_link = function(index, text, icon, module)
110 content = function()
111 if index > 0 then
112 slot.put(text)
113 ui.image{ static = "icons/16/"..icon }
114 else
115 ui.image{ static = "icons/16/"..icon }
116 slot.put(text)
117 end
118 end
119 if records[this+index] then
120 ui.link{
121 content = content,
122 module = module,
123 view = "show",
124 id = records[this+index].id,
125 }
126 else
127 ui.container{
128 content = content,
129 }
130 end
131 end
133 issues_selector
134 :add_where{"issue.area_id = ?", issue.area.id}
136 local filters = execute.load_chunk{module="issue", chunk="_filters.lua", params = {filter = "frozen"}}
138 local state = issue.state
140 -- FIXME: fix filter names to reflect issue.state values
141 if state == "voting" then
142 state = "frozen"
143 elseif state == "frozen" then
144 state = "half_frozen"
145 end
147 filter = filters:get_filter("filter", state)
148 if filter then
149 filter.selector_modifier(issues_selector)
151 -- add subfilter to voting pager, so only not voted entries will be shown
152 -- as this seems the most usefull exception
153 if filter.name == "frozen" then
154 filter_voting_name = "not_voted"
155 local vfilter = filters:get_filter("filter_voting", "not_voted")
156 if vfilter then
157 vfilter.selector_modifier(issues_selector)
158 end
159 end
160 end
162 records = issues_selector:exec()
164 for i,cissue in ipairs(records) do
165 if cissue.id == issue.id then
166 this = i
167 break
168 end
169 end
171 mk_link(-1, _("Previous issue"), "resultset_previous.png", "issue")
172 if issue.area then
173 ui.link{
174 content = function()
175 if issue_filter_map[state] then
176 ui.image{ static = "icons/16/"..issue_filter_map[state] }
177 end
178 slot.put(issue.area.name)
179 end,
180 module = "area",
181 view = "show",
182 id = issue.area.id,
183 params = {
184 filter = filter and filter.name or nil,
185 filter_voting = filter_voting_name,
186 tab = "issues"
187 }
188 }
189 end
190 mk_link(1, _("Next issue"), "resultset_next.png", "issue")
192 -- show pager for initiatives if available
193 if initiative then
194 ui.container{ content = function() end, attr = {class = "content_navigation_seperator"}}
196 records = issue:get_reference_selector("initiatives"):exec()
197 for i,cissue in ipairs(records) do
198 if cissue.id == initiative.id then
199 this = i
200 break
201 end
202 end
203 mk_link(-1, _("Previous initiative"), "resultset_previous.png", "initiative")
204 mk_link(1, _("Next initiative"), "resultset_next.png", "initiative")
205 end
206 end
207 end
209 )
210 --]]
212 slot.select("actions", function()
214 if app.session.member_id then
216 if issue.state == 'voting' then
217 local text
218 if not direct_voter then
219 text = _"Vote now"
220 else
221 text = _"Change vote"
222 end
223 ui.link{
224 content = function()
225 ui.image{ static = "icons/16/email_open.png" }
226 slot.put(text)
227 end,
228 module = "vote",
229 view = "list",
230 params = { issue_id = issue.id }
231 }
232 end
234 execute.view{
235 module = "interest",
236 view = "_show_box",
237 params = { issue = issue }
238 }
240 if not issue.closed then
241 execute.view{
242 module = "delegation",
243 view = "_show_box",
244 params = { issue_id = issue.id,
245 initiative_id = initiative and initiative.id or nil}
246 }
247 end
249 end
251 if config.issue_discussion_url_func then
252 local url = config.issue_discussion_url_func(issue)
253 ui.link{
254 attr = { target = "_blank" },
255 external = url,
256 content = function()
257 ui.image{ static = "icons/16/comments.png" }
258 slot.put(_"Discussion on issue")
259 end,
260 }
261 end
262 end)
264 if app.session.member_id then
265 slot.select("actions", function()
266 if not issue.fully_frozen and not issue.closed then
267 ui.link{
268 image = { static = "icons/16/script_add.png" },
269 attr = { class = "action" },
270 text = _"Create alternative initiative",
271 module = "initiative",
272 view = "new",
273 params = { issue_id = issue.id }
274 }
275 end
276 end)
277 end
279 local issue = param.get("issue", "table")
283 -- ui.twitter("http://example.com/t" .. tostring(issue.id))
285 if config.public_access_issue_head and not app.session.member_id then
286 config.public_access_issue_head(issue)
287 end
289 if app.session.member_id and issue.state == 'voting' and not direct_voter then
290 ui.container{
291 attr = { class = "voting_active_info" },
292 content = function()
293 slot.put(_"Voting for this issue is currently running!")
294 slot.put(" ")
295 if app.session.member_id then
296 ui.link{
297 content = function()
298 slot.put(_"Vote now")
299 end,
300 module = "vote",
301 view = "list",
302 params = { issue_id = issue.id }
303 }
304 end
305 end
306 }
307 slot.put("<br />")
308 end