bsw@31: function show_issue(issue, initiatives_selector)
bsw@31: ui.list{
bsw@31: records = initiatives_selector:exec(),
bsw@31: columns = {
bsw@31: {
bsw@31: label = _"Date",
bsw@31: label_attr = { style = "width: 7.5em;" },
bsw@31: content = function(initiative)
bsw@31: slot.put(format.date(issue.closed))
bsw@31: end
bsw@31: },
bsw@31: {
bsw@31: label_attr = { style = "width: 8em;" },
bsw@31: label = _"Id",
bsw@31: content = function(initiative)
bsw@31: ui.link{
bsw@31: external = "",
bsw@31: text = "#" .. tostring(issue.id) .. "." .. tostring(initiative.id),
bsw@31: attr = {
bsw@31: onclick =
bsw@31: "openEl('initiative_" .. tostring(initiative.id) .. "');" ..
bsw@31: "return(false);"
bsw@31: }
bsw@31: }
bsw@31: end
bsw@31: },
bsw@31: {
bsw@31: label = _"Rank",
bsw@31: label_attr = { style = "width: 3em;" },
bsw@31: field_attr = { style = "text-align: right;" },
bsw@31: content = function(initiative)
bsw@31: ui.field.rank{ value = initiative.rank }
bsw@31: end
bsw@31: },
bsw@31: {
bsw@31: label = _"Name",
bsw@31: content = function(initiative)
bsw@31: if initiative.rank and initiative.rank == 1 then
bsw@31: slot.put("")
bsw@31: end
bsw@31: ui.field.text{ value = initiative.name }
bsw@31: if initiative.rank and initiative.rank == 1 then
bsw@31: slot.put("")
bsw@31: end
bsw@31: end
bsw@31: }
bsw@31: }
bsw@31: }
bsw@31: end
bsw@31:
bsw@31: function link_issue(issue)
bsw@31: ui.link{
bsw@31: external = "",
bsw@31: attr = {
bsw@31: style = "text-decoration: none;",
bsw@31: name = "issue_" .. tostring(issue.id),
bsw@31: onclick =
bsw@31: "openEl('issue_" .. tostring(issue.id) .. "');" ..
bsw@31: "return(false);"
bsw@31: },
bsw@31: content = function()
bsw@31: ui.heading{
bsw@31: attr = { style = "background-color: #ddd; color: #000;" },
bsw@31: content = _("##{id}", { id = issue.id })
bsw@31: }
bsw@31: end
bsw@31: }
bsw@31: end
bsw@31:
bsw@31:
bsw@31: local area = param.get("area", "table")
bsw@31:
bsw@31: local issue_selector = Issue:new_selector()
bsw@31: issue_selector:add_where{ "area_id = ?", area.id }
bsw@31: issue_selector:add_where("closed NOTNULL")
bsw@31: issue_selector:add_order_by("id")
bsw@31:
bsw@31:
bsw@31: local issues = issue_selector:exec()
bsw@31:
bsw@31: ui.container{
bsw@31: attr = {
bsw@31: id = "area_" .. tostring(area.id)
bsw@31: },
bsw@31: content = function()
bsw@31:
bsw@31: link_area(area)
bsw@31:
bsw@31: for i, issue in ipairs(issues) do
bsw@31:
bsw@31: link_issue(issue)
bsw@31:
bsw@31: local initiatives_selector = issue:get_reference_selector("initiatives")
bsw@31:
bsw@31: local initiatives_count = initiatives_selector:count()
bsw@31:
bsw@31: initiatives_selector:add_order_by("rank")
bsw@31: initiatives_selector:limit(3)
bsw@31:
bsw@31: show_issue(issue, initiatives_selector)
bsw@31:
bsw@31: if initiatives_count > 3 then
bsw@31: ui.link{
bsw@31: attr = {
bsw@31: style = "margin-left: 8em; font-style: italic;",
bsw@31: onclick = "openEl('issue_" .. tostring(issue.id) .. "'); return(false);"
bsw@31: },
bsw@31: content = _("and #{count} more initiatives", { count = initiatives_count - 3 }),
bsw@31: external = ""
bsw@31: }
bsw@31: end
bsw@31:
bsw@31: slot.put("
")
bsw@31:
bsw@31: end
bsw@31:
bsw@31: end
bsw@31: }
bsw@31:
bsw@34: ui.script{ script = "parents['area_" .. tostring(area.id) .. "'] = 'areas';" }
bsw@34:
bsw@31: local next_issue = issues[1]
bsw@31: if next_issue then
bsw@31: ui.script{ script = "next_issues['area_" .. tostring(area.id) .. "'] = 'issue_" .. tostring(next_issue.id) .. "';" }
bsw@31: end
bsw@31:
bsw@31: if next_issue then
bsw@31: local next_initiative = next_issue.initiatives[1]
bsw@31: if next_initiative then
bsw@31: ui.script{ script = "next_initiatives['area_" .. tostring(area.id) .. "'] = 'initiative_" .. tostring(next_initiative.id) .. "';" }
bsw@31: end
bsw@31: end
bsw@31:
bsw@31:
bsw@31: for i, issue in ipairs(issues) do
bsw@31: local initiatives_selector = issue:get_reference_selector("initiatives")
bsw@31: :add_order_by("rank")
bsw@31:
bsw@31: local initiatives = initiatives_selector:exec()
bsw@31:
bsw@31: ui.container{
bsw@31: attr = {
bsw@31: id = "issue_" .. tostring(issue.id)
bsw@31: },
bsw@31: content = function()
bsw@31: link_area(area)
bsw@31: link_issue(issue)
bsw@31: show_issue(issue, initiatives_selector)
bsw@31: end
bsw@31: }
bsw@31:
bsw@31: local previous_issue = issues[i-1]
bsw@31: if previous_issue then
bsw@31: ui.script{ script = "prev_issues['issue_" .. tostring(issue.id) .. "'] = 'issue_" .. tostring(previous_issue.id) .. "';" }
bsw@31: end
bsw@31:
bsw@31: local next_initiative = initiatives[1]
bsw@31: if next_initiative then
bsw@31: ui.script{ script = "next_initiatives['issue_" .. tostring(issue.id) .. "'] = 'initiative_" .. tostring(next_initiative.id) .. "';" }
bsw@31: end
bsw@31:
bsw@34: ui.script{ script = "parents['issue_" .. tostring(issue.id) .. "'] = 'area_" .. tostring(area.id) .. "';" }
bsw@34:
bsw@31: local next_issue = issues[i+1]
bsw@31: if next_issue then
bsw@31: ui.script{ script = "next_issues['issue_" .. tostring(issue.id) .. "'] = 'issue_" .. tostring(next_issue.id) .. "';" }
bsw@31: end
bsw@31:
bsw@31: ui.script{
bsw@31: script = "document.getElementById('issue_" .. tostring(issue.id) .. "').style.display = 'none';"
bsw@31: }
bsw@31:
bsw@31:
bsw@31: for j, initiative in ipairs(initiatives) do
bsw@31:
bsw@31: ui.container{
bsw@31: attr = {
bsw@31: id = "initiative_" .. tostring(initiative.id)
bsw@31: },
bsw@31: content = function()
bsw@31: execute.view{
bsw@31: module = "report",
bsw@31: view = "initiative",
bsw@31: params = { initiative = initiative }
bsw@31: }
bsw@31: slot.put("
")
bsw@31: slot.put("
")
bsw@31: slot.put("
")
bsw@31: slot.put("
")
bsw@31: slot.put("
")
bsw@31: end
bsw@31: }
bsw@31:
bsw@31: local previous_issue = issues[i-1]
bsw@31: if previous_issue then
bsw@31: ui.script{ script = "prev_issues['initiative_" .. tostring(initiative.id) .. "'] = 'issue_" .. tostring(previous_issue.id) .. "';" }
bsw@31: end
bsw@31:
bsw@31: local previous_initiative = initiatives[j-1]
bsw@31: if previous_initiative then
bsw@31: ui.script{ script = "prev_initiatives['initiative_" .. tostring(initiative.id) .. "'] = 'initiative_" .. tostring(previous_initiative.id) .. "';" }
bsw@31: end
bsw@31:
bsw@34: ui.script{ script = "parents['initiative_" .. tostring(initiative.id) .. "'] = 'issue_" .. tostring(issue.id) .. "';" }
bsw@34:
bsw@31: local next_initiative = initiatives[j+1]
bsw@31: if next_initiative then
bsw@31: ui.script{ script = "next_initiatives['initiative_" .. tostring(initiative.id) .. "'] = 'initiative_" .. tostring(next_initiative.id) .. "';" }
bsw@31: end
bsw@31:
bsw@31: local next_issue = issues[i+1]
bsw@31: if next_issue then
bsw@31: ui.script{ script = "next_issues['initiative_" .. tostring(initiative.id) .. "'] = 'issue_" .. tostring(next_issue.id) .. "';" }
bsw@31: end
bsw@31:
bsw@31: ui.script{
bsw@31: script = "document.getElementById('initiative_" .. tostring(initiative.id) .. "').style.display = 'none';"
bsw@31: }
bsw@31:
bsw@31: end
bsw@31: end
bsw@31:
bsw@31: ui.script{
bsw@31: script = "document.getElementById('area_" .. tostring(area.id) .. "').style.display = 'none';"
bsw@31: }
bsw@31: