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@414
|
5
|
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@414
|
10
|
bsw@414
|
11 if for_member then
|
bsw@414
|
12 event_selector:add_where{ "event.member_id = ?", for_member.id }
|
bsw@414
|
13 elseif for_unit then
|
bsw@414
|
14 event_selector:join("area", nil, "area.id = issue.area_id")
|
bsw@414
|
15 event_selector:add_where{ "area.unit_id = ?", for_unit.id }
|
bsw@414
|
16 elseif for_area then
|
bsw@414
|
17 event_selector:add_where{ "issue.area_id = ?", for_area.id }
|
bsw@414
|
18 elseif not global then
|
bsw@414
|
19 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
|
20 end
|
bsw@414
|
21
|
bsw@414
|
22 if app.session.member_id then
|
bsw@414
|
23 event_selector
|
bsw@414
|
24 :left_join("interest", "_interest", { "_interest.issue_id = issue.id AND _interest.member_id = ?", app.session.member.id } )
|
bsw@414
|
25 :add_field("(_interest.member_id NOTNULL)", "is_interested")
|
bsw@414
|
26 :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
|
27 :add_field("_delegating_interest.delegate_member_ids[1]", "is_interested_by_delegation_to_member_id")
|
bsw@414
|
28 :add_field("_delegating_interest.delegate_member_ids[array_upper(_delegating_interest.delegate_member_ids, 1)]", "is_interested_via_member_id")
|
bsw@414
|
29 :add_field("array_length(_delegating_interest.delegate_member_ids, 1)", "delegation_chain_length")
|
bsw@414
|
30 end
|
bsw@414
|
31
|
bsw@414
|
32 --local filters = execute.load_chunk{module="issue", chunk="_filters.lua", params = { member = app.session.member }}
|
bsw@414
|
33
|
bsw@414
|
34 --filters.content = function()
|
bsw@414
|
35
|
bsw@414
|
36 ui.container{ attr = { class = "issues events" }, content = function()
|
bsw@414
|
37
|
bsw@414
|
38 local last_event_date
|
bsw@414
|
39 for i, event in ipairs(event_selector:exec()) do
|
bsw@414
|
40 if event.occurrence.date ~= last_event_date then
|
bsw@414
|
41 ui.container{ attr = { class = "date" }, content = format.date(event.occurrence.date) }
|
bsw@414
|
42 last_event_date = event.occurrence.date
|
bsw@414
|
43 end
|
bsw@414
|
44 local class = "issue"
|
bsw@414
|
45 if event.is_interested then
|
bsw@414
|
46 class = class .. " interested"
|
bsw@414
|
47 elseif event.is_interested_by_delegation_to_member_id then
|
bsw@414
|
48 class = class .. " interested_by_delegation"
|
bsw@414
|
49 end
|
bsw@414
|
50 ui.container{ attr = { class = class }, content = function()
|
bsw@414
|
51
|
bsw@414
|
52 ui.container { attr = { class = "issue_info" }, content = function()
|
bsw@414
|
53
|
bsw@414
|
54 ui.container{ content = function()
|
bsw@414
|
55 ui.link{
|
bsw@414
|
56 attr = { class = "issue_id" },
|
bsw@414
|
57 text = _("Issue ##{id}", { id = tostring(event.issue_id) }),
|
bsw@414
|
58 module = "issue",
|
bsw@414
|
59 view = "show",
|
bsw@414
|
60 id = event.issue_id
|
bsw@414
|
61 }
|
bsw@414
|
62
|
bsw@414
|
63 slot.put(" · ")
|
bsw@414
|
64 ui.tag{ content = event.issue.area.name }
|
bsw@414
|
65 slot.put(" · ")
|
bsw@414
|
66 ui.tag{ content = event.issue.area.unit.name }
|
bsw@414
|
67 slot.put(" · ")
|
bsw@414
|
68 ui.tag{ content = event.issue.policy.name }
|
bsw@414
|
69 end }
|
bsw@414
|
70
|
bsw@414
|
71 ui.container{ attr = { class = "issue_policy_info" }, content = function()
|
bsw@414
|
72 if event.member_id then
|
bsw@414
|
73 ui.link{
|
bsw@414
|
74 content = function()
|
bsw@414
|
75 execute.view{
|
bsw@414
|
76 module = "member_image",
|
bsw@414
|
77 view = "_show",
|
bsw@414
|
78 params = {
|
bsw@414
|
79 member = event.member,
|
bsw@414
|
80 image_type = "avatar",
|
bsw@414
|
81 show_dummy = true,
|
bsw@414
|
82 class = "micro_avatar",
|
bsw@414
|
83 popup_text = text
|
bsw@414
|
84 }
|
bsw@414
|
85 }
|
bsw@414
|
86 end,
|
bsw@414
|
87 module = "member", view = "show", id = event.member_id
|
bsw@414
|
88 }
|
bsw@414
|
89 slot.put(" ")
|
bsw@414
|
90 ui.link{
|
bsw@414
|
91 text = event.member.name,
|
bsw@414
|
92 module = "member", view = "show", id = event.member_id
|
bsw@414
|
93 }
|
bsw@414
|
94 slot.put(" · ")
|
bsw@414
|
95 end
|
bsw@414
|
96 local event_name = event.event_name
|
bsw@414
|
97 local event_image
|
bsw@414
|
98 if event.event == "issue_state_changed" then
|
bsw@414
|
99 if event.state == "discussion" then
|
bsw@414
|
100 event_name = _"Discussion started"
|
bsw@414
|
101 event_image = "new.png"
|
bsw@414
|
102 elseif event.state == "verification" then
|
bsw@414
|
103 event_name = _"Verification started"
|
bsw@414
|
104 event_image = "lock.png"
|
bsw@414
|
105 elseif event.state == "voting" then
|
bsw@414
|
106 event_name = _"Voting started"
|
bsw@414
|
107 event_image = "email_open.png"
|
bsw@414
|
108 else
|
bsw@414
|
109 event_name = event.state_name
|
bsw@414
|
110 end
|
bsw@414
|
111 if event_image then
|
bsw@414
|
112 ui.image{ static = "icons/16/" .. event_image }
|
bsw@414
|
113 end
|
bsw@414
|
114 end
|
bsw@414
|
115 ui.tag{ attr = { class = "event_name" }, content = event_name }
|
bsw@414
|
116 slot.put(" · ")
|
bsw@414
|
117 ui.tag{ attr = { class = "time" }, content = format.time(event.occurrence) }
|
bsw@414
|
118 end }
|
bsw@414
|
119
|
bsw@414
|
120 end }
|
bsw@414
|
121
|
bsw@414
|
122 if event.suggestion_id then
|
bsw@414
|
123 ui.container{ attr = { class = "suggestion" }, content = function()
|
bsw@414
|
124 ui.link{
|
bsw@414
|
125 text = event.suggestion.name,
|
bsw@414
|
126 module = "suggestion", view = "show", id = event.suggestion_id
|
bsw@414
|
127 }
|
bsw@414
|
128 end }
|
bsw@414
|
129 end
|
bsw@414
|
130
|
bsw@414
|
131 ui.container{ attr = { class = "initiative_list" }, content = function()
|
bsw@414
|
132 if not event.initiative_id then
|
bsw@414
|
133 local initiatives_selector = Initiative:new_selector()
|
bsw@414
|
134 :add_where{ "initiative.issue_id = ?", event.issue_id }
|
bsw@414
|
135 :add_order_by("initiative.rank, initiative.supporter_count")
|
bsw@414
|
136 execute.view{ module = "initiative", view = "_list", params = {
|
bsw@414
|
137 issue = event.issue,
|
bsw@414
|
138 initiatives_selector = initiatives_selector,
|
bsw@414
|
139 no_sort = true,
|
bsw@414
|
140 limit = 3
|
bsw@414
|
141 } }
|
bsw@414
|
142 else
|
bsw@414
|
143 local initiatives_selector = Initiative:new_selector()
|
bsw@414
|
144 :add_where{ "initiative.id = ?", event.initiative_id }
|
bsw@414
|
145 execute.view{ module = "initiative", view = "_list", params = {
|
bsw@414
|
146 issue = event.issue,
|
bsw@414
|
147 initiatives_selector = initiatives_selector,
|
bsw@414
|
148 no_sort = true,
|
bsw@414
|
149 limit = 1
|
bsw@414
|
150 } }
|
bsw@414
|
151 end
|
bsw@414
|
152 end }
|
bsw@414
|
153
|
bsw@414
|
154 --[[
|
bsw@414
|
155 if event.initiative_id then
|
bsw@414
|
156 ui.container{ attr = { class = "initiative_id" }, content = event.initiative_id }
|
bsw@414
|
157 end
|
bsw@414
|
158 if event.draft_id then
|
bsw@414
|
159 ui.container{ attr = { class = "draft_id" }, content = event.draft_id }
|
bsw@414
|
160 end
|
bsw@414
|
161 if event.suggestion_id then
|
bsw@414
|
162 ui.container{ attr = { class = "suggestion_id" }, content = event.suggestion_id }
|
bsw@414
|
163 end
|
bsw@414
|
164 --]]
|
bsw@414
|
165
|
bsw@414
|
166 end }
|
bsw@414
|
167 end
|
bsw@414
|
168
|
bsw@414
|
169 end }
|
bsw@414
|
170
|
bsw@414
|
171 --end
|
bsw@414
|
172
|
bsw@414
|
173 --filters.selector = event_selector
|
bsw@414
|
174 --ui.filters(filters) |