liquid_feedback_frontend
view app/main/issue/_show_head.lua @ 274:aec9df5b4cd3
More optical enhancements and repositioning of elements
author | bsw |
---|---|
date | Sun Feb 12 12:20:19 2012 +0100 (2012-02-12) |
parents | 7196685f9dd7 |
children | bde068b37608 |
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 ui.link{
50 text = issue.policy.name,
51 module = "policy",
52 view = "show",
53 id = issue.policy.id
54 }
56 slot.put(" · ")
57 ui.tag{ content = issue.state_name }
59 if issue.state_time_left then
60 slot.put(" · ")
61 ui.tag{ content = _("#{time_left} left", { time_left = issue.state_time_left }) }
62 end
64 end
65 }
68 end)
71 --[[
72 slot.select("content_navigation", function()
74 if app.session.member_id then
75 local records
76 local this = 0
77 local issues_selector = Issue:new_selector()
79 -- FIXME: !DRY
80 local issue_filter_map = {
81 new = "new.png",
82 accepted = "comments.png",
83 half_frozen = "lock.png",
84 frozen ="email_open.png",
85 finished = "tick.png",
86 cancelled = "cross.png",
87 }
90 local mk_link = function(index, text, icon, module)
91 content = function()
92 if index > 0 then
93 slot.put(text)
94 ui.image{ static = "icons/16/"..icon }
95 else
96 ui.image{ static = "icons/16/"..icon }
97 slot.put(text)
98 end
99 end
100 if records[this+index] then
101 ui.link{
102 content = content,
103 module = module,
104 view = "show",
105 id = records[this+index].id,
106 }
107 else
108 ui.container{
109 content = content,
110 }
111 end
112 end
114 issues_selector
115 :add_where{"issue.area_id = ?", issue.area.id}
117 local filters = execute.load_chunk{module="issue", chunk="_filters.lua", params = {filter = "frozen"}}
119 local state = issue.state
121 -- FIXME: fix filter names to reflect issue.state values
122 if state == "voting" then
123 state = "frozen"
124 elseif state == "frozen" then
125 state = "half_frozen"
126 end
128 filter = filters:get_filter("filter", state)
129 if filter then
130 filter.selector_modifier(issues_selector)
132 -- add subfilter to voting pager, so only not voted entries will be shown
133 -- as this seems the most usefull exception
134 if filter.name == "frozen" then
135 filter_voting_name = "not_voted"
136 local vfilter = filters:get_filter("filter_voting", "not_voted")
137 if vfilter then
138 vfilter.selector_modifier(issues_selector)
139 end
140 end
141 end
143 records = issues_selector:exec()
145 for i,cissue in ipairs(records) do
146 if cissue.id == issue.id then
147 this = i
148 break
149 end
150 end
152 mk_link(-1, _("Previous issue"), "resultset_previous.png", "issue")
153 if issue.area then
154 ui.link{
155 content = function()
156 if issue_filter_map[state] then
157 ui.image{ static = "icons/16/"..issue_filter_map[state] }
158 end
159 slot.put(issue.area.name)
160 end,
161 module = "area",
162 view = "show",
163 id = issue.area.id,
164 params = {
165 filter = filter and filter.name or nil,
166 filter_voting = filter_voting_name,
167 tab = "issues"
168 }
169 }
170 end
171 mk_link(1, _("Next issue"), "resultset_next.png", "issue")
173 -- show pager for initiatives if available
174 if initiative then
175 ui.container{ content = function() end, attr = {class = "content_navigation_seperator"}}
177 records = issue:get_reference_selector("initiatives"):exec()
178 for i,cissue in ipairs(records) do
179 if cissue.id == initiative.id then
180 this = i
181 break
182 end
183 end
184 mk_link(-1, _("Previous initiative"), "resultset_previous.png", "initiative")
185 mk_link(1, _("Next initiative"), "resultset_next.png", "initiative")
186 end
187 end
188 end
190 )
191 --]]
193 slot.select("actions", function()
195 if app.session.member_id then
197 if issue.state == 'voting' then
198 local text
199 if not direct_voter then
200 text = _"Vote now"
201 else
202 text = _"Change vote"
203 end
204 ui.link{
205 content = function()
206 ui.image{ static = "icons/16/email_open.png" }
207 slot.put(text)
208 end,
209 module = "vote",
210 view = "list",
211 params = { issue_id = issue.id }
212 }
213 end
215 execute.view{
216 module = "interest",
217 view = "_show_box",
218 params = { issue = issue }
219 }
221 if not issue.closed then
222 execute.view{
223 module = "delegation",
224 view = "_show_box",
225 params = { issue_id = issue.id,
226 initiative_id = initiative and initiative.id or nil}
227 }
228 end
230 end
232 if config.issue_discussion_url_func then
233 local url = config.issue_discussion_url_func(issue)
234 ui.link{
235 attr = { target = "_blank" },
236 external = url,
237 content = function()
238 ui.image{ static = "icons/16/comments.png" }
239 slot.put(_"Discussion on issue")
240 end,
241 }
242 end
243 end)
245 if app.session.member_id then
246 slot.select("actions", function()
247 if not issue.fully_frozen and not issue.closed then
248 ui.link{
249 image = { static = "icons/16/script_add.png" },
250 attr = { class = "action" },
251 text = _"Create alternative initiative",
252 module = "initiative",
253 view = "new",
254 params = { issue_id = issue.id }
255 }
256 end
257 end)
258 end
260 local issue = param.get("issue", "table")
264 -- ui.twitter("http://example.com/t" .. tostring(issue.id))
266 if config.public_access_issue_head and not app.session.member_id then
267 config.public_access_issue_head(issue)
268 end
270 if app.session.member_id and issue.state == 'voting' and not direct_voter then
271 ui.container{
272 attr = { class = "voting_active_info" },
273 content = function()
274 slot.put(_"Voting for this issue is currently running!")
275 slot.put(" ")
276 if app.session.member_id then
277 ui.link{
278 content = function()
279 slot.put(_"Vote now")
280 end,
281 module = "vote",
282 view = "list",
283 params = { issue_id = issue.id }
284 }
285 end
286 end
287 }
288 slot.put("<br />")
289 end