bsw@11: local timeline_selector = param.get("timeline_selector", "table") bsw@11: local event_names = param.get("event_names", "table") bsw@11: local initiatives_per_page = param.get("initiatives_per_page", atom.number) or 3 bsw@11: poelzi@136: poelzi@136: -- test if selector is valid poelzi@136: local test_selector = timeline_selector:get_db_conn():new_selector() poelzi@136: test_selector:add_field('count(1)') poelzi@136: test_selector:add_from(timeline_selector) poelzi@136: test_selector:single_object_mode() poelzi@136: poelzi@136: err, x = test_selector:try_exec() bsw/jbe@19: poelzi@136: if err then poelzi@136: slot.put_into("error", _"Invalid query") poelzi@136: else poelzi@136: ui.paginate{ poelzi@136: per_page = param.get("per_page", atom.number) or 25, poelzi@136: selector = timeline_selector, poelzi@145: container_attr = { class = "ui_paginate timeline_results" }, poelzi@136: content = function() poelzi@136: local timelines = timeline_selector:exec() poelzi@136: timelines:load("issue") poelzi@136: timelines:load("initiative") poelzi@136: timelines:load("member") poelzi@136: ui.list{ poelzi@136: attr = { class = "nohover" }, poelzi@136: records = timelines, poelzi@136: columns = { poelzi@136: { poelzi@136: field_attr = { style = "width: 10em;" }, poelzi@136: content = function(timeline) bsw/jbe@19: ui.field.text{ poelzi@136: attr = { style = "font-size: 75%; font-weight: bold; background-color: #ccc; display: block; margin-bottom: 1ex;"}, poelzi@136: value = format.time(timeline.occurrence) bsw/jbe@19: } poelzi@136: poelzi@136: ui.field.text{ poelzi@136: attr = { style = "font-size: 75%; font-weight: bold;"}, poelzi@136: value = event_names[timeline.event] or timeline.event poelzi@136: } poelzi@136: if timeline.event == "draft_created" and timeline.count > 1 then poelzi@136: ui.field.text{ poelzi@136: attr = { style = "font-size: 75%;"}, poelzi@136: value = _("(#{more_count} duplicates removed)", { more_count = timeline.count - 1 }) bsw@11: } bsw@11: end bsw@11: end poelzi@136: }, poelzi@136: { poelzi@136: content = function(timeline) poelzi@136: local issue poelzi@136: local initiative poelzi@136: if timeline.issue then poelzi@136: issue = timeline.issue poelzi@136: elseif timeline.initiative then poelzi@136: initiative = timeline.initiative poelzi@136: issue = initiative.issue poelzi@136: elseif timeline.draft then poelzi@136: initiative = timeline.draft.initiative poelzi@136: issue = initiative.issue poelzi@136: elseif timeline.suggestion then poelzi@136: initiative = timeline.suggestion.initiative poelzi@136: issue = initiative.issue poelzi@136: end poelzi@136: if issue then poelzi@136: if timeline.is_interested then poelzi@136: local label = _"You are interested in this issue", poelzi@136: ui.image{ poelzi@136: attr = { alt = label, title = label, style = "float: left; margin-right: 0.5em;" }, poelzi@136: static = "icons/16/eye.png" poelzi@136: } poelzi@136: end poelzi@136: slot.put(" ") poelzi@136: ui.tag{ poelzi@136: tag = "span", poelzi@136: attr = { style = "font-size: 75%; font-weight: bold; background-color: #ccc; display: block; margin-bottom: 1ex;"}, bsw@265: content = issue.area.name_with_unit_name .. ", " .. _("Issue ##{id}", { id = issue.id }) poelzi@136: } poelzi@136: else poelzi@136: ui.tag{ poelzi@136: tag = "span", poelzi@136: attr = { style = "font-size: 75%; background-color: #ccc; display: block; margin-bottom: 1ex;"}, poelzi@136: content = function() slot.put(" ") end poelzi@136: } poelzi@136: end poelzi@136: poelzi@136: if timeline.member then poelzi@136: execute.view{ poelzi@136: module = "member_image", poelzi@136: view = "_show", poelzi@136: params = { poelzi@136: member = timeline.member, poelzi@136: image_type = "avatar", poelzi@136: show_dummy = true poelzi@136: } bsw@11: } poelzi@136: ui.link{ poelzi@136: content = timeline.member.name, poelzi@136: module = "member", poelzi@136: view = "show", poelzi@136: id = timeline.member.id poelzi@136: } poelzi@136: end poelzi@136: if timeline.issue then poelzi@136: local initiatives_selector = timeline.issue poelzi@136: :get_reference_selector("initiatives") poelzi@136: execute.view{ poelzi@136: module = "initiative", poelzi@136: view = "_list", poelzi@136: params = { poelzi@136: issue = timeline.issue, poelzi@136: initiatives_selector = initiatives_selector, poelzi@136: per_page = initiatives_per_page, poelzi@136: no_sort = true, poelzi@136: limit = initiatives_per_page poelzi@136: } bsw@11: } poelzi@136: elseif initiative then poelzi@136: execute.view{ poelzi@136: module = "initiative", poelzi@136: view = "_list", poelzi@136: params = { poelzi@136: issue = initiative.issue, poelzi@136: initiatives_selector = Initiative:new_selector():add_where{ "initiative.id = ?", initiative.id }, poelzi@136: per_page = initiatives_per_page, poelzi@136: no_sort = true poelzi@136: } poelzi@136: } poelzi@136: end poelzi@136: if timeline.suggestion then poelzi@136: ui.link{ poelzi@136: module = "suggestion", poelzi@136: view = "show", poelzi@136: id = timeline.suggestion.id, poelzi@136: content = timeline.suggestion.name poelzi@136: } poelzi@136: end bsw@11: end poelzi@136: }, poelzi@136: } bsw@11: } poelzi@136: end poelzi@136: } poelzi@136: end