liquid_feedback_frontend
view app/main/event/_list.lua @ 423:0a895704373a
Fixed typo and german translations
author | bsw |
---|---|
date | Sat Mar 10 18:04:36 2012 +0100 (2012-03-10) |
parents | 7ebf90c7d436 |
children | 37a623b43e0a |
line source
1 local global = param.get("global", atom.boolean)
2 local for_member = param.get("for_member", "table")
3 local for_unit = param.get("for_unit", "table")
4 local for_area = param.get("for_area", "table")
5 local event_max_id = param.get_all_cgi()["event_max_id"]
6 local event_selector = Event:new_selector()
7 :add_order_by("event.id DESC")
8 :limit(25)
9 :join("issue", nil, "issue.id = event.issue_id")
11 if event_max_id then
12 event_selector:add_where{ "event.id < ?", event_max_id }
13 end
15 if for_member then
16 event_selector:add_where{ "event.member_id = ?", for_member.id }
17 elseif for_unit then
18 event_selector:join("area", nil, "area.id = issue.area_id")
19 event_selector:add_where{ "area.unit_id = ?", for_unit.id }
20 elseif for_area then
21 event_selector:add_where{ "issue.area_id = ?", for_area.id }
22 elseif not global then
23 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 })
24 end
26 if app.session.member_id then
27 event_selector
28 :left_join("interest", "_interest", { "_interest.issue_id = issue.id AND _interest.member_id = ?", app.session.member.id } )
29 :add_field("(_interest.member_id NOTNULL)", "is_interested")
30 :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 } )
31 :add_field("_delegating_interest.delegate_member_ids[1]", "is_interested_by_delegation_to_member_id")
32 :add_field("_delegating_interest.delegate_member_ids[array_upper(_delegating_interest.delegate_member_ids, 1)]", "is_interested_via_member_id")
33 :add_field("array_length(_delegating_interest.delegate_member_ids, 1)", "delegation_chain_length")
34 end
36 local last_event_id
38 ui.container{ attr = { class = "issues events" }, content = function()
40 local last_event_date
41 for i, event in ipairs(event_selector:exec()) do
42 last_event_id = event.id
44 if event.occurrence.date ~= last_event_date then
45 ui.container{ attr = { class = "date" }, content = format.date(event.occurrence.date) }
46 last_event_date = event.occurrence.date
47 end
48 local class = "issue"
49 if event.is_interested then
50 class = class .. " interested"
51 elseif event.is_interested_by_delegation_to_member_id then
52 class = class .. " interested_by_delegation"
53 end
54 ui.container{ attr = { class = class }, content = function()
56 ui.container { attr = { class = "issue_info" }, content = function()
58 ui.container{ content = function()
59 ui.link{
60 attr = { class = "issue_id" },
61 text = _("Issue ##{id}", { id = tostring(event.issue_id) }),
62 module = "issue",
63 view = "show",
64 id = event.issue_id
65 }
67 slot.put(" · ")
68 ui.tag{ content = event.issue.area.name }
69 slot.put(" · ")
70 ui.tag{ content = event.issue.area.unit.name }
71 slot.put(" · ")
72 ui.tag{ content = event.issue.policy.name }
73 end }
75 ui.container{ attr = { class = "issue_policy_info" }, content = function()
76 if event.member_id then
77 ui.link{
78 content = function()
79 execute.view{
80 module = "member_image",
81 view = "_show",
82 params = {
83 member = event.member,
84 image_type = "avatar",
85 show_dummy = true,
86 class = "micro_avatar",
87 popup_text = text
88 }
89 }
90 end,
91 module = "member", view = "show", id = event.member_id
92 }
93 slot.put(" ")
94 ui.link{
95 text = event.member.name,
96 module = "member", view = "show", id = event.member_id
97 }
98 slot.put(" · ")
99 end
100 local event_name = event.event_name
101 local event_image
102 if event.event == "issue_state_changed" then
103 if event.state == "discussion" then
104 event_name = _"Discussion started"
105 event_image = "comments.png"
106 elseif event.state == "verification" then
107 event_name = _"Verification started"
108 event_image = "lock.png"
109 elseif event.state == "voting" then
110 event_name = _"Voting started"
111 event_image = "email_open.png"
112 else
113 event_name = event.state_name
114 end
115 if event_image then
116 ui.image{ static = "icons/16/" .. event_image }
117 slot.put(" ")
118 end
119 end
120 ui.tag{ attr = { class = "event_name" }, content = event_name }
121 slot.put(" · ")
122 ui.tag{ attr = { class = "time" }, content = format.time(event.occurrence) }
123 end }
125 end }
127 if event.suggestion_id then
128 ui.container{ attr = { class = "suggestion" }, content = function()
129 ui.link{
130 text = event.suggestion.name,
131 module = "suggestion", view = "show", id = event.suggestion_id
132 }
133 end }
134 end
136 ui.container{ attr = { class = "initiative_list" }, content = function()
137 if not event.initiative_id then
138 local initiatives_selector = Initiative:new_selector()
139 :add_where{ "initiative.issue_id = ?", event.issue_id }
140 :add_order_by("initiative.rank, initiative.supporter_count")
141 execute.view{ module = "initiative", view = "_list", params = {
142 issue = event.issue,
143 initiatives_selector = initiatives_selector,
144 no_sort = true,
145 limit = 3
146 } }
147 else
148 local initiatives_selector = Initiative:new_selector()
149 :add_where{ "initiative.id = ?", event.initiative_id }
150 execute.view{ module = "initiative", view = "_list", params = {
151 issue = event.issue,
152 initiatives_selector = initiatives_selector,
153 no_sort = true,
154 limit = 1
155 } }
156 end
157 end }
159 --[[
160 if event.initiative_id then
161 ui.container{ attr = { class = "initiative_id" }, content = event.initiative_id }
162 end
163 if event.draft_id then
164 ui.container{ attr = { class = "draft_id" }, content = event.draft_id }
165 end
166 if event.suggestion_id then
167 ui.container{ attr = { class = "suggestion_id" }, content = event.suggestion_id }
168 end
169 --]]
171 end }
172 end
174 end }
176 ui.link{
177 text = _"Show older events",
178 module = request.get_module(),
179 view = request.get_view(),
180 id = param.get_id(),
181 params = {
182 tab = param.get_all_cgi()["tab"],
183 events = param.get_all_cgi()["events"],
184 event_max_id = last_event_id
185 }
186 }