bsw@414: local global = param.get("global", atom.boolean) bsw@414: local for_member = param.get("for_member", "table") bsw@414: local for_unit = param.get("for_unit", "table") bsw@414: local for_area = param.get("for_area", "table") bsw@414: bsw@414: local event_selector = Event:new_selector() bsw@414: :add_order_by("event.id DESC") bsw@414: :limit(25) bsw@414: :join("issue", nil, "issue.id = event.issue_id") bsw@414: bsw@414: if for_member then bsw@414: event_selector:add_where{ "event.member_id = ?", for_member.id } bsw@414: elseif for_unit then bsw@414: event_selector:join("area", nil, "area.id = issue.area_id") bsw@414: event_selector:add_where{ "area.unit_id = ?", for_unit.id } bsw@414: elseif for_area then bsw@414: event_selector:add_where{ "issue.area_id = ?", for_area.id } bsw@414: elseif not global then bsw@414: 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: end bsw@414: bsw@414: if app.session.member_id then bsw@414: event_selector bsw@414: :left_join("interest", "_interest", { "_interest.issue_id = issue.id AND _interest.member_id = ?", app.session.member.id } ) bsw@414: :add_field("(_interest.member_id NOTNULL)", "is_interested") bsw@414: :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: :add_field("_delegating_interest.delegate_member_ids[1]", "is_interested_by_delegation_to_member_id") bsw@414: :add_field("_delegating_interest.delegate_member_ids[array_upper(_delegating_interest.delegate_member_ids, 1)]", "is_interested_via_member_id") bsw@414: :add_field("array_length(_delegating_interest.delegate_member_ids, 1)", "delegation_chain_length") bsw@414: end bsw@414: bsw@414: --local filters = execute.load_chunk{module="issue", chunk="_filters.lua", params = { member = app.session.member }} bsw@414: bsw@414: --filters.content = function() bsw@414: bsw@414: ui.container{ attr = { class = "issues events" }, content = function() bsw@414: bsw@414: local last_event_date bsw@414: for i, event in ipairs(event_selector:exec()) do bsw@414: if event.occurrence.date ~= last_event_date then bsw@414: ui.container{ attr = { class = "date" }, content = format.date(event.occurrence.date) } bsw@414: last_event_date = event.occurrence.date bsw@414: end bsw@414: local class = "issue" bsw@414: if event.is_interested then bsw@414: class = class .. " interested" bsw@414: elseif event.is_interested_by_delegation_to_member_id then bsw@414: class = class .. " interested_by_delegation" bsw@414: end bsw@414: ui.container{ attr = { class = class }, content = function() bsw@414: bsw@414: ui.container { attr = { class = "issue_info" }, content = function() bsw@414: bsw@414: ui.container{ content = function() bsw@414: ui.link{ bsw@414: attr = { class = "issue_id" }, bsw@414: text = _("Issue ##{id}", { id = tostring(event.issue_id) }), bsw@414: module = "issue", bsw@414: view = "show", bsw@414: id = event.issue_id bsw@414: } bsw@414: bsw@414: slot.put(" · ") bsw@414: ui.tag{ content = event.issue.area.name } bsw@414: slot.put(" · ") bsw@414: ui.tag{ content = event.issue.area.unit.name } bsw@414: slot.put(" · ") bsw@414: ui.tag{ content = event.issue.policy.name } bsw@414: end } bsw@414: bsw@414: ui.container{ attr = { class = "issue_policy_info" }, content = function() bsw@414: if event.member_id then bsw@414: ui.link{ bsw@414: content = function() bsw@414: execute.view{ bsw@414: module = "member_image", bsw@414: view = "_show", bsw@414: params = { bsw@414: member = event.member, bsw@414: image_type = "avatar", bsw@414: show_dummy = true, bsw@414: class = "micro_avatar", bsw@414: popup_text = text bsw@414: } bsw@414: } bsw@414: end, bsw@414: module = "member", view = "show", id = event.member_id bsw@414: } bsw@414: slot.put(" ") bsw@414: ui.link{ bsw@414: text = event.member.name, bsw@414: module = "member", view = "show", id = event.member_id bsw@414: } bsw@414: slot.put(" · ") bsw@414: end bsw@414: local event_name = event.event_name bsw@414: local event_image bsw@414: if event.event == "issue_state_changed" then bsw@414: if event.state == "discussion" then bsw@414: event_name = _"Discussion started" bsw@414: event_image = "new.png" bsw@414: elseif event.state == "verification" then bsw@414: event_name = _"Verification started" bsw@414: event_image = "lock.png" bsw@414: elseif event.state == "voting" then bsw@414: event_name = _"Voting started" bsw@414: event_image = "email_open.png" bsw@414: else bsw@414: event_name = event.state_name bsw@414: end bsw@414: if event_image then bsw@414: ui.image{ static = "icons/16/" .. event_image } bsw@414: end bsw@414: end bsw@414: ui.tag{ attr = { class = "event_name" }, content = event_name } bsw@414: slot.put(" · ") bsw@414: ui.tag{ attr = { class = "time" }, content = format.time(event.occurrence) } bsw@414: end } bsw@414: bsw@414: end } bsw@414: bsw@414: if event.suggestion_id then bsw@414: ui.container{ attr = { class = "suggestion" }, content = function() bsw@414: ui.link{ bsw@414: text = event.suggestion.name, bsw@414: module = "suggestion", view = "show", id = event.suggestion_id bsw@414: } bsw@414: end } bsw@414: end bsw@414: bsw@414: ui.container{ attr = { class = "initiative_list" }, content = function() bsw@414: if not event.initiative_id then bsw@414: local initiatives_selector = Initiative:new_selector() bsw@414: :add_where{ "initiative.issue_id = ?", event.issue_id } bsw@414: :add_order_by("initiative.rank, initiative.supporter_count") bsw@414: execute.view{ module = "initiative", view = "_list", params = { bsw@414: issue = event.issue, bsw@414: initiatives_selector = initiatives_selector, bsw@414: no_sort = true, bsw@414: limit = 3 bsw@414: } } bsw@414: else bsw@414: local initiatives_selector = Initiative:new_selector() bsw@414: :add_where{ "initiative.id = ?", event.initiative_id } bsw@414: execute.view{ module = "initiative", view = "_list", params = { bsw@414: issue = event.issue, bsw@414: initiatives_selector = initiatives_selector, bsw@414: no_sort = true, bsw@414: limit = 1 bsw@414: } } bsw@414: end bsw@414: end } bsw@414: bsw@414: --[[ bsw@414: if event.initiative_id then bsw@414: ui.container{ attr = { class = "initiative_id" }, content = event.initiative_id } bsw@414: end bsw@414: if event.draft_id then bsw@414: ui.container{ attr = { class = "draft_id" }, content = event.draft_id } bsw@414: end bsw@414: if event.suggestion_id then bsw@414: ui.container{ attr = { class = "suggestion_id" }, content = event.suggestion_id } bsw@414: end bsw@414: --]] bsw@414: bsw@414: end } bsw@414: end bsw@414: bsw@414: end } bsw@414: bsw@414: --end bsw@414: bsw@414: --filters.selector = event_selector bsw@414: --ui.filters(filters)