liquid_feedback_frontend
view app/main/issue/_show_head.lua @ 127:4fb486bce608
add pageinator to issue view.
this "paginator" shows links to the prev/area/next issues that have the same
state then the current one. This helps a lot when inspecting new issues or voting.
The voting filter works a little bit different, as he also activtes the not_voted subfilter
because it is most likely only not voted issues are interessting to the user
this "paginator" shows links to the prev/area/next issues that have the same
state then the current one. This helps a lot when inspecting new issues or voting.
The voting filter works a little bit different, as he also activtes the not_voted subfilter
because it is most likely only not voted issues are interessting to the user
author | Daniel Poelzleithner <poelzi@poelzi.org> |
---|---|
date | Tue Oct 05 04:44:06 2010 +0200 (2010-10-05) |
parents | bf885faf3452 |
children | 850d02b1fc6d |
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.area.name,
21 module = "area",
22 view = "show",
23 id = issue.area.id
24 }
25 slot.put(" · ")
26 ui.link{
27 content = _("Issue ##{id}", { id = issue.id }),
28 module = "issue",
29 view = "show",
30 id = issue.id
31 }
32 slot.put(" · ")
33 ui.tag{
34 tag = "span",
35 content = issue.state_name,
36 }
37 end)
40 slot.select("content_navigation", function()
42 if app.session.member_id then
44 local this = 0
45 local issues_selector = Issue:new_selector()
47 -- FIXME: !DRY
48 local issue_filter_map = {
49 new = "new.png",
50 accepted = "comments.png",
51 half_frozen = "lock.png",
52 frozen ="email_open.png",
53 finished = "tick.png",
54 cancelled = "cross.png",
55 }
58 local mk_link = function(index, text, icon, ltr)
59 content = function()
60 if ltr then
61 slot.put(text)
62 ui.image{ static = "icons/16/"..icon }
63 else
64 ui.image{ static = "icons/16/"..icon }
65 slot.put(text)
66 end
67 end
68 if records[this+index] then
69 ui.link{
70 content = content,
71 module = "issue",
72 view = "show",
73 id = records[this+index].id,
74 }
75 else
76 ui.container{
77 content = content,
78 }
79 end
80 end
82 issues_selector
83 :add_where{"issue.area_id = ?", issue.area.id}
85 local filters = execute.load_chunk{module="issue", chunk="_filters.lua", params = {filter = "frozen"}}
87 local state = issue.state
89 -- FIXME: fix filter names to reflect issue.state values
90 if state == "voting" then
91 state = "frozen"
92 elseif state == "frozen" then
93 state = "half_frozen"
94 end
96 filter = filters:get_filter("filter", state)
97 if filter then
98 filter.selector_modifier(issues_selector)
100 -- add subfilter to voting pager, so only not voted entries will be shown
101 -- as this seems the most usefull exception
102 if filter.name == "frozen" then
103 filter_voting_name = "not_voted"
104 local vfilter = filters:get_filter("filter_voting", "not_voted")
105 if vfilter then
106 vfilter.selector_modifier(issues_selector)
107 end
108 end
109 end
111 records = issues_selector:exec()
113 for i,cissue in ipairs(records) do
114 if cissue.id == issue.id then
115 this = i
116 break
117 end
118 end
120 mk_link(-1, "Previous", "resultset_previous.png")
121 if issue.area then
122 ui.link{
123 content = function()
124 if issue_filter_map[state] then
125 ui.image{ static = "icons/16/"..issue_filter_map[state] }
126 end
127 slot.put(issue.area.name)
128 end,
129 module = "area",
130 view = "show",
131 id = issue.area.id,
132 params = {
133 filter = filter and filter.name or nil,
134 filter_voting = filter_voting_name,
135 tab = "issues"
136 }
137 }
138 end
139 mk_link(1, "Next", "resultset_next.png", 1)
140 end
141 end
143 )
145 slot.select("actions", function()
147 if app.session.member_id then
149 if issue.state == 'voting' then
150 local text
151 if not direct_voter then
152 text = _"Vote now"
153 else
154 text = _"Change vote"
155 end
156 ui.link{
157 content = function()
158 ui.image{ static = "icons/16/email_open.png" }
159 slot.put(text)
160 end,
161 module = "vote",
162 view = "list",
163 params = { issue_id = issue.id }
164 }
165 end
167 execute.view{
168 module = "interest",
169 view = "_show_box",
170 params = { issue = issue }
171 }
173 if not issue.closed then
174 execute.view{
175 module = "delegation",
176 view = "_show_box",
177 params = { issue_id = issue.id,
178 initiative_id = initiative and initiative.id or nil}
179 }
180 end
182 execute.view{
183 module = "issue",
184 view = "_show_vote_later_box",
185 params = { issue = issue }
186 }
188 end
190 if config.issue_discussion_url_func then
191 local url = config.issue_discussion_url_func(issue)
192 ui.link{
193 attr = { target = "_blank" },
194 external = url,
195 content = function()
196 ui.image{ static = "icons/16/comments.png" }
197 slot.put(_"Discussion on issue")
198 end,
199 }
200 end
201 end)
204 execute.view{
205 module = "issue",
206 view = "_show_box",
207 params = { issue = issue }
208 }
210 -- ui.twitter("http://example.com/t" .. tostring(issue.id))
212 if config.public_access_issue_head and not app.session.member_id then
213 config.public_access_issue_head(issue)
214 end
216 if app.session.member_id and issue.state == 'voting' and not direct_voter then
217 ui.container{
218 attr = { class = "voting_active_info" },
219 content = function()
220 slot.put(_"Voting for this issue is currently running!")
221 slot.put(" ")
222 if app.session.member_id then
223 ui.link{
224 content = function()
225 slot.put(_"Vote now")
226 end,
227 module = "vote",
228 view = "list",
229 params = { issue_id = issue.id }
230 }
231 end
232 end
233 }
234 slot.put("<br />")
235 end