liquid_feedback_frontend

view app/main/issue/_show_head.lua @ 266:aab7b0c5543f

Disabled next/prev initiative/issue links
author bsw
date Tue Feb 07 19:25:29 2012 +0100 (2012-02-07)
parents d37dce888225
children d13b27a37ad5
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 if not config.single_unit_id then
20 ui.link{
21 content = issue.area.unit.name,
22 module = "area",
23 view = "list",
24 params = { unit_id = issue.area.unit_id }
25 }
26 slot.put(" · ")
27 end
28 ui.link{
29 content = issue.area.name,
30 module = "area",
31 view = "show",
32 id = issue.area.id
33 }
34 slot.put(" · ")
35 ui.link{
36 content = _("Issue ##{id}", { id = issue.id }),
37 module = "issue",
38 view = "show",
39 id = issue.id
40 }
41 slot.put(" · ")
42 ui.tag{
43 tag = "span",
44 content = issue.state_name,
45 }
46 end)
49 slot.select("content_navigation", function()
51 if app.session.member_id then
52 local records
53 local this = 0
54 local issues_selector = Issue:new_selector()
56 -- FIXME: !DRY
57 local issue_filter_map = {
58 new = "new.png",
59 accepted = "comments.png",
60 half_frozen = "lock.png",
61 frozen ="email_open.png",
62 finished = "tick.png",
63 cancelled = "cross.png",
64 }
67 local mk_link = function(index, text, icon, module)
68 content = function()
69 if index > 0 then
70 slot.put(text)
71 ui.image{ static = "icons/16/"..icon }
72 else
73 ui.image{ static = "icons/16/"..icon }
74 slot.put(text)
75 end
76 end
77 if records[this+index] then
78 ui.link{
79 content = content,
80 module = module,
81 view = "show",
82 id = records[this+index].id,
83 }
84 else
85 ui.container{
86 content = content,
87 }
88 end
89 end
91 issues_selector
92 :add_where{"issue.area_id = ?", issue.area.id}
94 local filters = execute.load_chunk{module="issue", chunk="_filters.lua", params = {filter = "frozen"}}
96 local state = issue.state
98 -- FIXME: fix filter names to reflect issue.state values
99 if state == "voting" then
100 state = "frozen"
101 elseif state == "frozen" then
102 state = "half_frozen"
103 end
105 filter = filters:get_filter("filter", state)
106 if filter then
107 filter.selector_modifier(issues_selector)
109 -- add subfilter to voting pager, so only not voted entries will be shown
110 -- as this seems the most usefull exception
111 if filter.name == "frozen" then
112 filter_voting_name = "not_voted"
113 local vfilter = filters:get_filter("filter_voting", "not_voted")
114 if vfilter then
115 vfilter.selector_modifier(issues_selector)
116 end
117 end
118 end
120 --[[
121 records = issues_selector:exec()
123 for i,cissue in ipairs(records) do
124 if cissue.id == issue.id then
125 this = i
126 break
127 end
128 end
130 mk_link(-1, _("Previous issue"), "resultset_previous.png", "issue")
131 if issue.area then
132 ui.link{
133 content = function()
134 if issue_filter_map[state] then
135 ui.image{ static = "icons/16/"..issue_filter_map[state] }
136 end
137 slot.put(issue.area.name)
138 end,
139 module = "area",
140 view = "show",
141 id = issue.area.id,
142 params = {
143 filter = filter and filter.name or nil,
144 filter_voting = filter_voting_name,
145 tab = "issues"
146 }
147 }
148 end
149 mk_link(1, _("Next issue"), "resultset_next.png", "issue")
151 -- show pager for initiatives if available
152 if initiative then
153 ui.container{ content = function() end, attr = {class = "content_navigation_seperator"}}
155 records = issue:get_reference_selector("initiatives"):exec()
156 for i,cissue in ipairs(records) do
157 if cissue.id == initiative.id then
158 this = i
159 break
160 end
161 end
162 mk_link(-1, _("Previous initiative"), "resultset_previous.png", "initiative")
163 mk_link(1, _("Next initiative"), "resultset_next.png", "initiative")
164 end
165 --]]
166 end
167 end
169 )
171 slot.select("actions", function()
173 if app.session.member_id then
175 if issue.state == 'voting' then
176 local text
177 if not direct_voter then
178 text = _"Vote now"
179 else
180 text = _"Change vote"
181 end
182 ui.link{
183 content = function()
184 ui.image{ static = "icons/16/email_open.png" }
185 slot.put(text)
186 end,
187 module = "vote",
188 view = "list",
189 params = { issue_id = issue.id }
190 }
191 end
193 execute.view{
194 module = "interest",
195 view = "_show_box",
196 params = { issue = issue }
197 }
199 if not issue.closed then
200 execute.view{
201 module = "delegation",
202 view = "_show_box",
203 params = { issue_id = issue.id,
204 initiative_id = initiative and initiative.id or nil}
205 }
206 end
208 end
210 if config.issue_discussion_url_func then
211 local url = config.issue_discussion_url_func(issue)
212 ui.link{
213 attr = { target = "_blank" },
214 external = url,
215 content = function()
216 ui.image{ static = "icons/16/comments.png" }
217 slot.put(_"Discussion on issue")
218 end,
219 }
220 end
221 end)
224 execute.view{
225 module = "issue",
226 view = "_show_box",
227 params = { issue = issue }
228 }
230 -- ui.twitter("http://example.com/t" .. tostring(issue.id))
232 if config.public_access_issue_head and not app.session.member_id then
233 config.public_access_issue_head(issue)
234 end
236 if app.session.member_id and issue.state == 'voting' and not direct_voter then
237 ui.container{
238 attr = { class = "voting_active_info" },
239 content = function()
240 slot.put(_"Voting for this issue is currently running!")
241 slot.put(" ")
242 if app.session.member_id then
243 ui.link{
244 content = function()
245 slot.put(_"Vote now")
246 end,
247 module = "vote",
248 view = "list",
249 params = { issue_id = issue.id }
250 }
251 end
252 end
253 }
254 slot.put("<br />")
255 end

Impressum / About Us