liquid_feedback_frontend
changeset 422:7ebf90c7d436
Show more events link and code cleanup
author | bsw |
---|---|
date | Sat Mar 10 18:02:32 2012 +0100 (2012-03-10) |
parents | b863d069ddb1 |
children | 0a895704373a |
files | app/main/event/_list.lua app/main/issue/_list.lua |
line diff
1.1 --- a/app/main/event/_list.lua Sat Mar 10 17:54:15 2012 +0100 1.2 +++ b/app/main/event/_list.lua Sat Mar 10 18:02:32 2012 +0100 1.3 @@ -2,12 +2,16 @@ 1.4 local for_member = param.get("for_member", "table") 1.5 local for_unit = param.get("for_unit", "table") 1.6 local for_area = param.get("for_area", "table") 1.7 - 1.8 +local event_max_id = param.get_all_cgi()["event_max_id"] 1.9 local event_selector = Event:new_selector() 1.10 :add_order_by("event.id DESC") 1.11 :limit(25) 1.12 :join("issue", nil, "issue.id = event.issue_id") 1.13 1.14 +if event_max_id then 1.15 + event_selector:add_where{ "event.id < ?", event_max_id } 1.16 +end 1.17 + 1.18 if for_member then 1.19 event_selector:add_where{ "event.member_id = ?", for_member.id } 1.20 elseif for_unit then 1.21 @@ -29,147 +33,154 @@ 1.22 :add_field("array_length(_delegating_interest.delegate_member_ids, 1)", "delegation_chain_length") 1.23 end 1.24 1.25 ---local filters = execute.load_chunk{module="issue", chunk="_filters.lua", params = { member = app.session.member }} 1.26 +local last_event_id 1.27 1.28 ---filters.content = function() 1.29 - 1.30 - ui.container{ attr = { class = "issues events" }, content = function() 1.31 +ui.container{ attr = { class = "issues events" }, content = function() 1.32 1.33 - local last_event_date 1.34 - for i, event in ipairs(event_selector:exec()) do 1.35 - if event.occurrence.date ~= last_event_date then 1.36 - ui.container{ attr = { class = "date" }, content = format.date(event.occurrence.date) } 1.37 - last_event_date = event.occurrence.date 1.38 - end 1.39 - local class = "issue" 1.40 - if event.is_interested then 1.41 - class = class .. " interested" 1.42 - elseif event.is_interested_by_delegation_to_member_id then 1.43 - class = class .. " interested_by_delegation" 1.44 - end 1.45 - ui.container{ attr = { class = class }, content = function() 1.46 - 1.47 - ui.container { attr = { class = "issue_info" }, content = function() 1.48 - 1.49 - ui.container{ content = function() 1.50 - ui.link{ 1.51 - attr = { class = "issue_id" }, 1.52 - text = _("Issue ##{id}", { id = tostring(event.issue_id) }), 1.53 - module = "issue", 1.54 - view = "show", 1.55 - id = event.issue_id 1.56 - } 1.57 - 1.58 - slot.put(" · ") 1.59 - ui.tag{ content = event.issue.area.name } 1.60 - slot.put(" · ") 1.61 - ui.tag{ content = event.issue.area.unit.name } 1.62 - slot.put(" · ") 1.63 - ui.tag{ content = event.issue.policy.name } 1.64 - end } 1.65 + local last_event_date 1.66 + for i, event in ipairs(event_selector:exec()) do 1.67 + last_event_id = event.id 1.68 1.69 - ui.container{ attr = { class = "issue_policy_info" }, content = function() 1.70 - if event.member_id then 1.71 - ui.link{ 1.72 - content = function() 1.73 - execute.view{ 1.74 - module = "member_image", 1.75 - view = "_show", 1.76 - params = { 1.77 - member = event.member, 1.78 - image_type = "avatar", 1.79 - show_dummy = true, 1.80 - class = "micro_avatar", 1.81 - popup_text = text 1.82 - } 1.83 - } 1.84 - end, 1.85 - module = "member", view = "show", id = event.member_id 1.86 - } 1.87 - slot.put(" ") 1.88 - ui.link{ 1.89 - text = event.member.name, 1.90 - module = "member", view = "show", id = event.member_id 1.91 - } 1.92 - slot.put(" · ") 1.93 - end 1.94 - local event_name = event.event_name 1.95 - local event_image 1.96 - if event.event == "issue_state_changed" then 1.97 - if event.state == "discussion" then 1.98 - event_name = _"Discussion started" 1.99 - event_image = "comments.png" 1.100 - elseif event.state == "verification" then 1.101 - event_name = _"Verification started" 1.102 - event_image = "lock.png" 1.103 - elseif event.state == "voting" then 1.104 - event_name = _"Voting started" 1.105 - event_image = "email_open.png" 1.106 - else 1.107 - event_name = event.state_name 1.108 - end 1.109 - if event_image then 1.110 - ui.image{ static = "icons/16/" .. event_image } 1.111 - slot.put(" ") 1.112 - end 1.113 - end 1.114 - ui.tag{ attr = { class = "event_name" }, content = event_name } 1.115 - slot.put(" · ") 1.116 - ui.tag{ attr = { class = "time" }, content = format.time(event.occurrence) } 1.117 - end } 1.118 + if event.occurrence.date ~= last_event_date then 1.119 + ui.container{ attr = { class = "date" }, content = format.date(event.occurrence.date) } 1.120 + last_event_date = event.occurrence.date 1.121 + end 1.122 + local class = "issue" 1.123 + if event.is_interested then 1.124 + class = class .. " interested" 1.125 + elseif event.is_interested_by_delegation_to_member_id then 1.126 + class = class .. " interested_by_delegation" 1.127 + end 1.128 + ui.container{ attr = { class = class }, content = function() 1.129 1.130 - end } 1.131 - 1.132 - if event.suggestion_id then 1.133 - ui.container{ attr = { class = "suggestion" }, content = function() 1.134 - ui.link{ 1.135 - text = event.suggestion.name, 1.136 - module = "suggestion", view = "show", id = event.suggestion_id 1.137 - } 1.138 - end } 1.139 - end 1.140 + ui.container { attr = { class = "issue_info" }, content = function() 1.141 + 1.142 + ui.container{ content = function() 1.143 + ui.link{ 1.144 + attr = { class = "issue_id" }, 1.145 + text = _("Issue ##{id}", { id = tostring(event.issue_id) }), 1.146 + module = "issue", 1.147 + view = "show", 1.148 + id = event.issue_id 1.149 + } 1.150 1.151 - ui.container{ attr = { class = "initiative_list" }, content = function() 1.152 - if not event.initiative_id then 1.153 - local initiatives_selector = Initiative:new_selector() 1.154 - :add_where{ "initiative.issue_id = ?", event.issue_id } 1.155 - :add_order_by("initiative.rank, initiative.supporter_count") 1.156 - execute.view{ module = "initiative", view = "_list", params = { 1.157 - issue = event.issue, 1.158 - initiatives_selector = initiatives_selector, 1.159 - no_sort = true, 1.160 - limit = 3 1.161 - } } 1.162 - else 1.163 - local initiatives_selector = Initiative:new_selector() 1.164 - :add_where{ "initiative.id = ?", event.initiative_id } 1.165 - execute.view{ module = "initiative", view = "_list", params = { 1.166 - issue = event.issue, 1.167 - initiatives_selector = initiatives_selector, 1.168 - no_sort = true, 1.169 - limit = 1 1.170 - } } 1.171 - end 1.172 + slot.put(" · ") 1.173 + ui.tag{ content = event.issue.area.name } 1.174 + slot.put(" · ") 1.175 + ui.tag{ content = event.issue.area.unit.name } 1.176 + slot.put(" · ") 1.177 + ui.tag{ content = event.issue.policy.name } 1.178 end } 1.179 1.180 - --[[ 1.181 - if event.initiative_id then 1.182 - ui.container{ attr = { class = "initiative_id" }, content = event.initiative_id } 1.183 - end 1.184 - if event.draft_id then 1.185 - ui.container{ attr = { class = "draft_id" }, content = event.draft_id } 1.186 - end 1.187 - if event.suggestion_id then 1.188 - ui.container{ attr = { class = "suggestion_id" }, content = event.suggestion_id } 1.189 + ui.container{ attr = { class = "issue_policy_info" }, content = function() 1.190 + if event.member_id then 1.191 + ui.link{ 1.192 + content = function() 1.193 + execute.view{ 1.194 + module = "member_image", 1.195 + view = "_show", 1.196 + params = { 1.197 + member = event.member, 1.198 + image_type = "avatar", 1.199 + show_dummy = true, 1.200 + class = "micro_avatar", 1.201 + popup_text = text 1.202 + } 1.203 + } 1.204 + end, 1.205 + module = "member", view = "show", id = event.member_id 1.206 + } 1.207 + slot.put(" ") 1.208 + ui.link{ 1.209 + text = event.member.name, 1.210 + module = "member", view = "show", id = event.member_id 1.211 + } 1.212 + slot.put(" · ") 1.213 + end 1.214 + local event_name = event.event_name 1.215 + local event_image 1.216 + if event.event == "issue_state_changed" then 1.217 + if event.state == "discussion" then 1.218 + event_name = _"Discussion started" 1.219 + event_image = "comments.png" 1.220 + elseif event.state == "verification" then 1.221 + event_name = _"Verification started" 1.222 + event_image = "lock.png" 1.223 + elseif event.state == "voting" then 1.224 + event_name = _"Voting started" 1.225 + event_image = "email_open.png" 1.226 + else 1.227 + event_name = event.state_name 1.228 + end 1.229 + if event_image then 1.230 + ui.image{ static = "icons/16/" .. event_image } 1.231 + slot.put(" ") 1.232 + end 1.233 + end 1.234 + ui.tag{ attr = { class = "event_name" }, content = event_name } 1.235 + slot.put(" · ") 1.236 + ui.tag{ attr = { class = "time" }, content = format.time(event.occurrence) } 1.237 + end } 1.238 + 1.239 + end } 1.240 + 1.241 + if event.suggestion_id then 1.242 + ui.container{ attr = { class = "suggestion" }, content = function() 1.243 + ui.link{ 1.244 + text = event.suggestion.name, 1.245 + module = "suggestion", view = "show", id = event.suggestion_id 1.246 + } 1.247 + end } 1.248 + end 1.249 + 1.250 + ui.container{ attr = { class = "initiative_list" }, content = function() 1.251 + if not event.initiative_id then 1.252 + local initiatives_selector = Initiative:new_selector() 1.253 + :add_where{ "initiative.issue_id = ?", event.issue_id } 1.254 + :add_order_by("initiative.rank, initiative.supporter_count") 1.255 + execute.view{ module = "initiative", view = "_list", params = { 1.256 + issue = event.issue, 1.257 + initiatives_selector = initiatives_selector, 1.258 + no_sort = true, 1.259 + limit = 3 1.260 + } } 1.261 + else 1.262 + local initiatives_selector = Initiative:new_selector() 1.263 + :add_where{ "initiative.id = ?", event.initiative_id } 1.264 + execute.view{ module = "initiative", view = "_list", params = { 1.265 + issue = event.issue, 1.266 + initiatives_selector = initiatives_selector, 1.267 + no_sort = true, 1.268 + limit = 1 1.269 + } } 1.270 end 1.271 - --]] 1.272 - 1.273 end } 1.274 - end 1.275 1.276 - end } 1.277 + --[[ 1.278 + if event.initiative_id then 1.279 + ui.container{ attr = { class = "initiative_id" }, content = event.initiative_id } 1.280 + end 1.281 + if event.draft_id then 1.282 + ui.container{ attr = { class = "draft_id" }, content = event.draft_id } 1.283 + end 1.284 + if event.suggestion_id then 1.285 + ui.container{ attr = { class = "suggestion_id" }, content = event.suggestion_id } 1.286 + end 1.287 +--]] 1.288 + 1.289 + end } 1.290 + end 1.291 1.292 ---end 1.293 - 1.294 ---filters.selector = event_selector 1.295 ---ui.filters(filters) 1.296 \ No newline at end of file 1.297 +end } 1.298 + 1.299 +ui.link{ 1.300 + text = _"Show old events", 1.301 + module = request.get_module(), 1.302 + view = request.get_view(), 1.303 + id = param.get_id(), 1.304 + params = { 1.305 + tab = param.get_all_cgi()["tab"], 1.306 + events = param.get_all_cgi()["events"], 1.307 + event_max_id = last_event_id 1.308 + } 1.309 +}
2.1 --- a/app/main/issue/_list.lua Sat Mar 10 17:54:15 2012 +0100 2.2 +++ b/app/main/issue/_list.lua Sat Mar 10 18:02:32 2012 +0100 2.3 @@ -36,7 +36,7 @@ 2.4 2.5 filters.content = function() 2.6 ui.paginate{ 2.7 - per_page = tonumber(param.get("per_page")), 2.8 + per_page = tonumber(param.get("per_page") or 25), 2.9 selector = issues_selector, 2.10 content = function() 2.11 local highlight_string = param.get("highlight_string", "string")