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