# HG changeset patch # User bsw # Date 1331398952 -3600 # Node ID 7ebf90c7d43682b10d1f5175ff0f6fa2ad0e6e15 # Parent b863d069ddb1af2419f22643d32f00bb8fe9468f Show more events link and code cleanup diff -r b863d069ddb1 -r 7ebf90c7d436 app/main/event/_list.lua --- a/app/main/event/_list.lua Sat Mar 10 17:54:15 2012 +0100 +++ b/app/main/event/_list.lua Sat Mar 10 18:02:32 2012 +0100 @@ -2,12 +2,16 @@ local for_member = param.get("for_member", "table") local for_unit = param.get("for_unit", "table") local for_area = param.get("for_area", "table") - +local event_max_id = param.get_all_cgi()["event_max_id"] local event_selector = Event:new_selector() :add_order_by("event.id DESC") :limit(25) :join("issue", nil, "issue.id = event.issue_id") +if event_max_id then + event_selector:add_where{ "event.id < ?", event_max_id } +end + if for_member then event_selector:add_where{ "event.member_id = ?", for_member.id } elseif for_unit then @@ -29,147 +33,154 @@ :add_field("array_length(_delegating_interest.delegate_member_ids, 1)", "delegation_chain_length") end ---local filters = execute.load_chunk{module="issue", chunk="_filters.lua", params = { member = app.session.member }} +local last_event_id ---filters.content = function() - - ui.container{ attr = { class = "issues events" }, content = function() +ui.container{ attr = { class = "issues events" }, content = function() - local last_event_date - for i, event in ipairs(event_selector:exec()) do - if event.occurrence.date ~= last_event_date then - ui.container{ attr = { class = "date" }, content = format.date(event.occurrence.date) } - last_event_date = event.occurrence.date - end - local class = "issue" - if event.is_interested then - class = class .. " interested" - elseif event.is_interested_by_delegation_to_member_id then - class = class .. " interested_by_delegation" - end - ui.container{ attr = { class = class }, content = function() - - ui.container { attr = { class = "issue_info" }, content = function() - - ui.container{ content = function() - ui.link{ - attr = { class = "issue_id" }, - text = _("Issue ##{id}", { id = tostring(event.issue_id) }), - module = "issue", - view = "show", - id = event.issue_id - } - - slot.put(" · ") - ui.tag{ content = event.issue.area.name } - slot.put(" · ") - ui.tag{ content = event.issue.area.unit.name } - slot.put(" · ") - ui.tag{ content = event.issue.policy.name } - end } + local last_event_date + for i, event in ipairs(event_selector:exec()) do + last_event_id = event.id - ui.container{ attr = { class = "issue_policy_info" }, content = function() - if event.member_id then - ui.link{ - content = function() - execute.view{ - module = "member_image", - view = "_show", - params = { - member = event.member, - image_type = "avatar", - show_dummy = true, - class = "micro_avatar", - popup_text = text - } - } - end, - module = "member", view = "show", id = event.member_id - } - slot.put(" ") - ui.link{ - text = event.member.name, - module = "member", view = "show", id = event.member_id - } - slot.put(" · ") - end - local event_name = event.event_name - local event_image - if event.event == "issue_state_changed" then - if event.state == "discussion" then - event_name = _"Discussion started" - event_image = "comments.png" - elseif event.state == "verification" then - event_name = _"Verification started" - event_image = "lock.png" - elseif event.state == "voting" then - event_name = _"Voting started" - event_image = "email_open.png" - else - event_name = event.state_name - end - if event_image then - ui.image{ static = "icons/16/" .. event_image } - slot.put(" ") - end - end - ui.tag{ attr = { class = "event_name" }, content = event_name } - slot.put(" · ") - ui.tag{ attr = { class = "time" }, content = format.time(event.occurrence) } - end } + if event.occurrence.date ~= last_event_date then + ui.container{ attr = { class = "date" }, content = format.date(event.occurrence.date) } + last_event_date = event.occurrence.date + end + local class = "issue" + if event.is_interested then + class = class .. " interested" + elseif event.is_interested_by_delegation_to_member_id then + class = class .. " interested_by_delegation" + end + ui.container{ attr = { class = class }, content = function() - end } - - if event.suggestion_id then - ui.container{ attr = { class = "suggestion" }, content = function() - ui.link{ - text = event.suggestion.name, - module = "suggestion", view = "show", id = event.suggestion_id - } - end } - end + ui.container { attr = { class = "issue_info" }, content = function() + + ui.container{ content = function() + ui.link{ + attr = { class = "issue_id" }, + text = _("Issue ##{id}", { id = tostring(event.issue_id) }), + module = "issue", + view = "show", + id = event.issue_id + } - ui.container{ attr = { class = "initiative_list" }, content = function() - if not event.initiative_id then - local initiatives_selector = Initiative:new_selector() - :add_where{ "initiative.issue_id = ?", event.issue_id } - :add_order_by("initiative.rank, initiative.supporter_count") - execute.view{ module = "initiative", view = "_list", params = { - issue = event.issue, - initiatives_selector = initiatives_selector, - no_sort = true, - limit = 3 - } } - else - local initiatives_selector = Initiative:new_selector() - :add_where{ "initiative.id = ?", event.initiative_id } - execute.view{ module = "initiative", view = "_list", params = { - issue = event.issue, - initiatives_selector = initiatives_selector, - no_sort = true, - limit = 1 - } } - end + slot.put(" · ") + ui.tag{ content = event.issue.area.name } + slot.put(" · ") + ui.tag{ content = event.issue.area.unit.name } + slot.put(" · ") + ui.tag{ content = event.issue.policy.name } end } - --[[ - if event.initiative_id then - ui.container{ attr = { class = "initiative_id" }, content = event.initiative_id } - end - if event.draft_id then - ui.container{ attr = { class = "draft_id" }, content = event.draft_id } - end - if event.suggestion_id then - ui.container{ attr = { class = "suggestion_id" }, content = event.suggestion_id } + ui.container{ attr = { class = "issue_policy_info" }, content = function() + if event.member_id then + ui.link{ + content = function() + execute.view{ + module = "member_image", + view = "_show", + params = { + member = event.member, + image_type = "avatar", + show_dummy = true, + class = "micro_avatar", + popup_text = text + } + } + end, + module = "member", view = "show", id = event.member_id + } + slot.put(" ") + ui.link{ + text = event.member.name, + module = "member", view = "show", id = event.member_id + } + slot.put(" · ") + end + local event_name = event.event_name + local event_image + if event.event == "issue_state_changed" then + if event.state == "discussion" then + event_name = _"Discussion started" + event_image = "comments.png" + elseif event.state == "verification" then + event_name = _"Verification started" + event_image = "lock.png" + elseif event.state == "voting" then + event_name = _"Voting started" + event_image = "email_open.png" + else + event_name = event.state_name + end + if event_image then + ui.image{ static = "icons/16/" .. event_image } + slot.put(" ") + end + end + ui.tag{ attr = { class = "event_name" }, content = event_name } + slot.put(" · ") + ui.tag{ attr = { class = "time" }, content = format.time(event.occurrence) } + end } + + end } + + if event.suggestion_id then + ui.container{ attr = { class = "suggestion" }, content = function() + ui.link{ + text = event.suggestion.name, + module = "suggestion", view = "show", id = event.suggestion_id + } + end } + end + + ui.container{ attr = { class = "initiative_list" }, content = function() + if not event.initiative_id then + local initiatives_selector = Initiative:new_selector() + :add_where{ "initiative.issue_id = ?", event.issue_id } + :add_order_by("initiative.rank, initiative.supporter_count") + execute.view{ module = "initiative", view = "_list", params = { + issue = event.issue, + initiatives_selector = initiatives_selector, + no_sort = true, + limit = 3 + } } + else + local initiatives_selector = Initiative:new_selector() + :add_where{ "initiative.id = ?", event.initiative_id } + execute.view{ module = "initiative", view = "_list", params = { + issue = event.issue, + initiatives_selector = initiatives_selector, + no_sort = true, + limit = 1 + } } end - --]] - end } - end - end } + --[[ + if event.initiative_id then + ui.container{ attr = { class = "initiative_id" }, content = event.initiative_id } + end + if event.draft_id then + ui.container{ attr = { class = "draft_id" }, content = event.draft_id } + end + if event.suggestion_id then + ui.container{ attr = { class = "suggestion_id" }, content = event.suggestion_id } + end +--]] + + end } + end ---end - ---filters.selector = event_selector ---ui.filters(filters) \ No newline at end of file +end } + +ui.link{ + text = _"Show old events", + module = request.get_module(), + view = request.get_view(), + id = param.get_id(), + params = { + tab = param.get_all_cgi()["tab"], + events = param.get_all_cgi()["events"], + event_max_id = last_event_id + } +} diff -r b863d069ddb1 -r 7ebf90c7d436 app/main/issue/_list.lua --- a/app/main/issue/_list.lua Sat Mar 10 17:54:15 2012 +0100 +++ b/app/main/issue/_list.lua Sat Mar 10 18:02:32 2012 +0100 @@ -36,7 +36,7 @@ filters.content = function() ui.paginate{ - per_page = tonumber(param.get("per_page")), + per_page = tonumber(param.get("per_page") or 25), selector = issues_selector, content = function() local highlight_string = param.get("highlight_string", "string")