rev |
line source |
bsw@414
|
1 local global = param.get("global", atom.boolean)
|
bsw@414
|
2 local for_member = param.get("for_member", "table")
|
bsw@414
|
3 local for_unit = param.get("for_unit", "table")
|
bsw@414
|
4 local for_area = param.get("for_area", "table")
|
bsw@422
|
5 local event_max_id = param.get_all_cgi()["event_max_id"]
|
bsw@414
|
6 local event_selector = Event:new_selector()
|
bsw@414
|
7 :add_order_by("event.id DESC")
|
bsw@414
|
8 :limit(25)
|
bsw@414
|
9 :join("issue", nil, "issue.id = event.issue_id")
|
bsw@437
|
10 :add_field("now()::date - event.occurrence::date", "time_ago")
|
bsw@437
|
11
|
bsw@422
|
12 if event_max_id then
|
bsw@422
|
13 event_selector:add_where{ "event.id < ?", event_max_id }
|
bsw@422
|
14 end
|
bsw@422
|
15
|
bsw@414
|
16 if for_member then
|
bsw@414
|
17 event_selector:add_where{ "event.member_id = ?", for_member.id }
|
bsw@414
|
18 elseif for_unit then
|
bsw@414
|
19 event_selector:join("area", nil, "area.id = issue.area_id")
|
bsw@414
|
20 event_selector:add_where{ "area.unit_id = ?", for_unit.id }
|
bsw@414
|
21 elseif for_area then
|
bsw@414
|
22 event_selector:add_where{ "issue.area_id = ?", for_area.id }
|
bsw@414
|
23 elseif not global then
|
bsw@414
|
24 event_selector:join("event_seen_by_member", nil, { "event_seen_by_member.id = event.id AND event_seen_by_member.seen_by_member_id = ?", app.session.member_id })
|
bsw@414
|
25 end
|
bsw@414
|
26
|
bsw@414
|
27 if app.session.member_id then
|
bsw@414
|
28 event_selector
|
bsw@414
|
29 :left_join("interest", "_interest", { "_interest.issue_id = issue.id AND _interest.member_id = ?", app.session.member.id } )
|
bsw@414
|
30 :add_field("(_interest.member_id NOTNULL)", "is_interested")
|
bsw@414
|
31 :left_join("delegating_interest_snapshot", "_delegating_interest", { "_delegating_interest.issue_id = issue.id AND _delegating_interest.member_id = ? AND _delegating_interest.event = issue.latest_snapshot_event", app.session.member.id } )
|
bsw@414
|
32 :add_field("_delegating_interest.delegate_member_ids[1]", "is_interested_by_delegation_to_member_id")
|
bsw@414
|
33 :add_field("_delegating_interest.delegate_member_ids[array_upper(_delegating_interest.delegate_member_ids, 1)]", "is_interested_via_member_id")
|
bsw@414
|
34 :add_field("array_length(_delegating_interest.delegate_member_ids, 1)", "delegation_chain_length")
|
bsw@414
|
35 end
|
bsw@414
|
36
|
bsw@422
|
37 local last_event_id
|
bsw@414
|
38
|
bsw@596
|
39 local events = event_selector:exec()
|
bsw@596
|
40
|
bsw@422
|
41 ui.container{ attr = { class = "issues events" }, content = function()
|
bsw@414
|
42
|
bsw@422
|
43 local last_event_date
|
bsw@596
|
44 for i, event in ipairs(events) do
|
bsw@422
|
45 last_event_id = event.id
|
bsw@553
|
46 event.issue:load_everything_for_member_id(app.session.member_id)
|
bsw@414
|
47
|
bsw@422
|
48 local class = "issue"
|
bsw@422
|
49 if event.is_interested then
|
bsw@422
|
50 class = class .. " interested"
|
bsw@422
|
51 elseif event.is_interested_by_delegation_to_member_id then
|
bsw@422
|
52 class = class .. " interested_by_delegation"
|
bsw@422
|
53 end
|
bsw@525
|
54
|
bsw@619
|
55 ui.container{ attr = { class = "issue_policy_info" }, content = function()
|
bsw@619
|
56 if (app.session.member_id or config.public_access == "pseudonym") and event.member_id then
|
bsw@619
|
57 if app.session.member_id then
|
bsw@619
|
58 ui.link{
|
bsw@619
|
59 content = function()
|
bsw@619
|
60 execute.view{
|
bsw@619
|
61 module = "member_image",
|
bsw@619
|
62 view = "_show",
|
bsw@619
|
63 params = {
|
bsw@619
|
64 member = event.member,
|
bsw@619
|
65 image_type = "avatar",
|
bsw@619
|
66 show_dummy = true,
|
bsw@619
|
67 class = "micro_avatar",
|
bsw@619
|
68 popup_text = text
|
bsw@619
|
69 }
|
bsw@525
|
70 }
|
bsw@619
|
71 end,
|
bsw@619
|
72 module = "member", view = "show", id = event.member_id
|
bsw@619
|
73 }
|
bsw@619
|
74 slot.put(" ")
|
bsw@619
|
75 end
|
bsw@619
|
76 ui.link{
|
bsw@619
|
77 text = event.member.name,
|
bsw@619
|
78 module = "member", view = "show", id = event.member_id
|
bsw@619
|
79 }
|
bsw@619
|
80 slot.put(" · ")
|
bsw@619
|
81 end
|
bsw@619
|
82 local event_name = event.event_name
|
bsw@619
|
83 local event_image
|
bsw@619
|
84 if event.event == "issue_state_changed" then
|
bsw@619
|
85 if event.state == "discussion" then
|
bsw@619
|
86 event_name = _"Discussion started"
|
bsw@619
|
87 event_image = "comments.png"
|
bsw@619
|
88 elseif event.state == "verification" then
|
bsw@619
|
89 event_name = _"Verification started"
|
bsw@619
|
90 event_image = "lock.png"
|
bsw@619
|
91 elseif event.state == "voting" then
|
bsw@619
|
92 event_name = _"Voting started"
|
bsw@619
|
93 event_image = "email_open.png"
|
bsw@619
|
94 else
|
bsw@619
|
95 event_name = event.state_name
|
bsw@619
|
96 end
|
bsw@619
|
97 if event_image then
|
bsw@619
|
98 ui.image{ static = "icons/16/" .. event_image }
|
bsw@619
|
99 slot.put(" ")
|
bsw@619
|
100 end
|
bsw@619
|
101 end
|
bsw@619
|
102 local days_ago_text
|
bsw@619
|
103 if event.time_ago == 0 then
|
bsw@619
|
104 days_ago_text = _("Today at #{time}", { time = format.time(event.occurrence) })
|
bsw@619
|
105 elseif event.time_ago == 1 then
|
bsw@619
|
106 days_ago_text = _("Yesterday at #{time}", { time = format.time(event.occurrence) })
|
bsw@619
|
107 else
|
bsw@619
|
108 days_ago_text = _("#{date} at #{time}", { date = format.date(event.occurrence.date), time = format.time(event.occurrence) })
|
bsw@619
|
109 end
|
bsw@619
|
110 ui.tag{ attr = { class = "event_name" }, content = event_name }
|
bsw@619
|
111 slot.put(" · ")
|
bsw@619
|
112 ui.tag{ content = days_ago_text }
|
bsw@619
|
113 if event.time_ago > 1 then
|
bsw@619
|
114 slot.put(" (")
|
bsw@619
|
115 ui.tag{ content = _("#{count} days ago", { count = event.time_ago }) }
|
bsw@619
|
116 slot.put(")")
|
bsw@619
|
117 end
|
bsw@619
|
118 end }
|
bsw@525
|
119
|
bsw@422
|
120 ui.container{ attr = { class = class }, content = function()
|
bsw@414
|
121
|
bsw@422
|
122 ui.container { attr = { class = "issue_info" }, content = function()
|
bsw@422
|
123
|
bsw@498
|
124 if event.is_interested then
|
bsw@498
|
125 ui.tag{
|
bsw@498
|
126 tag = "div", attr = { class = "interest_by_delegation"},
|
bsw@498
|
127 content = function()
|
bsw@498
|
128 local text = "You are interested in this issue"
|
bsw@498
|
129 ui.image{ attr = { alt = text, title = text }, static = "icons/16/eye.png" }
|
bsw@498
|
130 end
|
bsw@498
|
131 }
|
bsw@498
|
132
|
bsw@498
|
133 elseif event.is_interested_by_delegation_to_member_id then
|
bsw@498
|
134 ui.tag{
|
bsw@498
|
135 tag = "div", attr = { class = "interest_by_delegation"},
|
bsw@498
|
136 content = function()
|
bsw@498
|
137 local member = Member:by_id(event.is_interested_by_delegation_to_member_id)
|
bsw@498
|
138 local text = _"delegated to"
|
bsw@498
|
139 ui.image{
|
bsw@498
|
140 attr = { class = "delegation_arrow", alt = text, title = text },
|
bsw@498
|
141 static = "delegation_arrow_24_horizontal.png"
|
bsw@498
|
142 }
|
bsw@498
|
143 execute.view{
|
bsw@498
|
144 module = "member_image",
|
bsw@498
|
145 view = "_show",
|
bsw@498
|
146 params = {
|
bsw@498
|
147 member = member,
|
bsw@498
|
148 image_type = "avatar",
|
bsw@498
|
149 show_dummy = true,
|
bsw@498
|
150 class = "micro_avatar",
|
bsw@498
|
151 popup_text = member.name
|
bsw@498
|
152 }
|
bsw@498
|
153 }
|
bsw@498
|
154 if event.is_interested_by_delegation_to_member_id ~= event.is_interested_via_member_id then
|
bsw@498
|
155 if event.delegation_chain_length > 2 then
|
bsw@498
|
156 local text = _"delegated to"
|
bsw@498
|
157 ui.image{
|
bsw@498
|
158 attr = { class = "delegation_arrow", alt = text, title = text },
|
bsw@498
|
159 static = "delegation_arrow_24_horizontal.png"
|
bsw@498
|
160 }
|
bsw@498
|
161 ui.tag{ content = "..." }
|
bsw@498
|
162 end
|
bsw@498
|
163 local text = _"delegated to"
|
bsw@498
|
164 ui.image{
|
bsw@498
|
165 attr = { class = "delegation_arrow", alt = text, title = text },
|
bsw@498
|
166 static = "delegation_arrow_24_horizontal.png"
|
bsw@498
|
167 }
|
bsw@498
|
168 local member = Member:by_id(event.is_interested_via_member_id)
|
bsw@498
|
169 execute.view{
|
bsw@498
|
170 module = "member_image",
|
bsw@498
|
171 view = "_show",
|
bsw@498
|
172 params = {
|
bsw@498
|
173 member = member,
|
bsw@498
|
174 image_type = "avatar",
|
bsw@498
|
175 show_dummy = true,
|
bsw@498
|
176 class = "micro_avatar",
|
bsw@498
|
177 popup_text = member.name
|
bsw@498
|
178 }
|
bsw@498
|
179 }
|
bsw@498
|
180 end
|
bsw@498
|
181 end
|
bsw@498
|
182 }
|
bsw@498
|
183 end
|
bsw@498
|
184
|
bsw@422
|
185 ui.container{ content = function()
|
bsw@422
|
186 ui.link{
|
bsw@422
|
187 attr = { class = "issue_id" },
|
bsw@422
|
188 text = _("Issue ##{id}", { id = tostring(event.issue_id) }),
|
bsw@422
|
189 module = "issue",
|
bsw@422
|
190 view = "show",
|
bsw@422
|
191 id = event.issue_id
|
bsw@422
|
192 }
|
bsw@414
|
193
|
bsw@422
|
194 slot.put(" · ")
|
bsw@471
|
195 ui.tag{ content = event.issue.policy.name }
|
bsw@471
|
196 slot.put(" · ")
|
bsw@422
|
197 ui.tag{ content = event.issue.area.name }
|
bsw@422
|
198 slot.put(" · ")
|
bsw@422
|
199 ui.tag{ content = event.issue.area.unit.name }
|
bsw@414
|
200 end }
|
bsw@414
|
201
|
bsw@422
|
202
|
bsw@422
|
203 end }
|
bsw@422
|
204
|
bsw@422
|
205 if event.suggestion_id then
|
bsw@422
|
206 ui.container{ attr = { class = "suggestion" }, content = function()
|
bsw@422
|
207 ui.link{
|
bsw@422
|
208 text = event.suggestion.name,
|
bsw@422
|
209 module = "suggestion", view = "show", id = event.suggestion_id
|
bsw@422
|
210 }
|
bsw@422
|
211 end }
|
bsw@422
|
212 end
|
bsw@422
|
213
|
bsw@422
|
214 ui.container{ attr = { class = "initiative_list" }, content = function()
|
bsw@422
|
215 if not event.initiative_id then
|
bsw@422
|
216 local initiatives_selector = Initiative:new_selector()
|
bsw@422
|
217 :add_where{ "initiative.issue_id = ?", event.issue_id }
|
bsw@509
|
218 :add_order_by("initiative.rank, initiative.supporter_count DESC")
|
bsw@422
|
219 execute.view{ module = "initiative", view = "_list", params = {
|
bsw@422
|
220 issue = event.issue,
|
bsw@422
|
221 initiatives_selector = initiatives_selector,
|
bsw@422
|
222 no_sort = true,
|
bsw@422
|
223 limit = 3
|
bsw@422
|
224 } }
|
bsw@422
|
225 else
|
bsw@422
|
226 local initiatives_selector = Initiative:new_selector()
|
bsw@422
|
227 :add_where{ "initiative.id = ?", event.initiative_id }
|
bsw@422
|
228 execute.view{ module = "initiative", view = "_list", params = {
|
bsw@422
|
229 issue = event.issue,
|
bsw@422
|
230 initiatives_selector = initiatives_selector,
|
bsw@422
|
231 no_sort = true,
|
bsw@422
|
232 limit = 1
|
bsw@422
|
233 } }
|
bsw@414
|
234 end
|
bsw@414
|
235 end }
|
bsw@414
|
236
|
bsw@422
|
237 --[[
|
bsw@422
|
238 if event.initiative_id then
|
bsw@422
|
239 ui.container{ attr = { class = "initiative_id" }, content = event.initiative_id }
|
bsw@422
|
240 end
|
bsw@422
|
241 if event.draft_id then
|
bsw@422
|
242 ui.container{ attr = { class = "draft_id" }, content = event.draft_id }
|
bsw@422
|
243 end
|
bsw@422
|
244 if event.suggestion_id then
|
bsw@422
|
245 ui.container{ attr = { class = "suggestion_id" }, content = event.suggestion_id }
|
bsw@422
|
246 end
|
bsw@422
|
247 --]]
|
bsw@422
|
248
|
bsw@422
|
249 end }
|
bsw@422
|
250 end
|
bsw@414
|
251
|
bsw@422
|
252 end }
|
bsw@422
|
253
|
bsw@596
|
254 slot.put("<br />")
|
bsw@596
|
255
|
bsw@596
|
256 if #events > 0 then
|
bsw@596
|
257 ui.link{
|
bsw@596
|
258 text = _"Show older events",
|
bsw@596
|
259 module = request.get_module(),
|
bsw@596
|
260 view = request.get_view(),
|
bsw@596
|
261 id = param.get_id(),
|
bsw@596
|
262 params = {
|
bsw@596
|
263 tab = param.get_all_cgi()["tab"],
|
bsw@596
|
264 events = param.get_all_cgi()["events"],
|
bsw@596
|
265 event_max_id = last_event_id
|
bsw@596
|
266 }
|
bsw@422
|
267 }
|
bsw@596
|
268 else
|
bsw@596
|
269 ui.tag{ content = _"No more events available" }
|
bsw@596
|
270 end
|
bsw@456
|
271
|
bsw@456
|
272 slot.put("<br />")
|
bsw@456
|
273 slot.put("<br />")
|