# HG changeset patch # User bsw # Date 1330450449 -3600 # Node ID 609e37247615136e3398bdbfccbd51392e41f736 # Parent b471e24298388ee498578d5f9158895cd1a86728 Removed old report views diff -r b471e2429838 -r 609e37247615 app/main/report/area.lua --- a/app/main/report/area.lua Tue Feb 28 18:31:58 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,226 +0,0 @@ -function show_issue(issue, initiatives_selector) - ui.list{ - records = initiatives_selector:exec(), - columns = { - { - label = _"Date", - label_attr = { style = "width: 7.5em;" }, - content = function(initiative) - slot.put(format.date(issue.closed)) - end - }, - { - label_attr = { style = "width: 8em;" }, - label = _"Id", - content = function(initiative) - ui.link{ - external = "", - text = "#" .. tostring(issue.id) .. "." .. tostring(initiative.id), - attr = { - onclick = - "openEl('initiative_" .. tostring(initiative.id) .. "');" .. - "return(false);" - } - } - end - }, - { - label = _"Rank", - label_attr = { style = "width: 3em;" }, - field_attr = { style = "text-align: right;" }, - content = function(initiative) - ui.field.rank{ value = initiative.rank } - end - }, - { - label = _"Name", - content = function(initiative) - if initiative.rank and initiative.rank == 1 then - slot.put("") - end - ui.field.text{ value = initiative.name } - if initiative.rank and initiative.rank == 1 then - slot.put("") - end - end - } - } - } -end - -function link_issue(issue) - ui.link{ - external = "", - attr = { - style = "text-decoration: none;", - name = "issue_" .. tostring(issue.id), - onclick = - "openEl('issue_" .. tostring(issue.id) .. "');" .. - "return(false);" - }, - content = function() - ui.heading{ - attr = { style = "background-color: #ddd; color: #000;" }, - content = _("##{id}", { id = issue.id }) - } - end - } -end - - -local area = param.get("area", "table") - -local issue_selector = Issue:new_selector() -issue_selector:add_where{ "area_id = ?", area.id } -issue_selector:add_where("closed NOTNULL") -issue_selector:add_order_by("id") - - -local issues = issue_selector:exec() - -ui.container{ - attr = { - id = "area_" .. tostring(area.id) - }, - content = function() - - link_area(area) - - for i, issue in ipairs(issues) do - - link_issue(issue) - - local initiatives_selector = issue:get_reference_selector("initiatives") - - local initiatives_count = initiatives_selector:count() - - initiatives_selector:add_order_by("rank") - initiatives_selector:limit(3) - - show_issue(issue, initiatives_selector) - - if initiatives_count > 3 then - ui.link{ - attr = { - style = "margin-left: 8em; font-style: italic;", - onclick = "openEl('issue_" .. tostring(issue.id) .. "'); return(false);" - }, - content = _("and #{count} more initiatives", { count = initiatives_count - 3 }), - external = "" - } - end - - slot.put("
") - - end - - end -} - -ui.script{ script = "parents['area_" .. tostring(area.id) .. "'] = 'areas';" } - -local next_issue = issues[1] -if next_issue then - ui.script{ script = "next_issues['area_" .. tostring(area.id) .. "'] = 'issue_" .. tostring(next_issue.id) .. "';" } -end - -if next_issue then - local next_initiative = next_issue.initiatives[1] - if next_initiative then - ui.script{ script = "next_initiatives['area_" .. tostring(area.id) .. "'] = 'initiative_" .. tostring(next_initiative.id) .. "';" } - end -end - - -for i, issue in ipairs(issues) do - local initiatives_selector = issue:get_reference_selector("initiatives") - :add_order_by("rank") - - local initiatives = initiatives_selector:exec() - - ui.container{ - attr = { - id = "issue_" .. tostring(issue.id) - }, - content = function() - link_area(area) - link_issue(issue) - show_issue(issue, initiatives_selector) - end - } - - local previous_issue = issues[i-1] - if previous_issue then - ui.script{ script = "prev_issues['issue_" .. tostring(issue.id) .. "'] = 'issue_" .. tostring(previous_issue.id) .. "';" } - end - - local next_initiative = initiatives[1] - if next_initiative then - ui.script{ script = "next_initiatives['issue_" .. tostring(issue.id) .. "'] = 'initiative_" .. tostring(next_initiative.id) .. "';" } - end - - ui.script{ script = "parents['issue_" .. tostring(issue.id) .. "'] = 'area_" .. tostring(area.id) .. "';" } - - local next_issue = issues[i+1] - if next_issue then - ui.script{ script = "next_issues['issue_" .. tostring(issue.id) .. "'] = 'issue_" .. tostring(next_issue.id) .. "';" } - end - - ui.script{ - script = "document.getElementById('issue_" .. tostring(issue.id) .. "').style.display = 'none';" - } - - - for j, initiative in ipairs(initiatives) do - - ui.container{ - attr = { - id = "initiative_" .. tostring(initiative.id) - }, - content = function() - execute.view{ - module = "report", - view = "initiative", - params = { initiative = initiative } - } - slot.put("
") - slot.put("
") - slot.put("
") - slot.put("
") - slot.put("
") - end - } - - local previous_issue = issues[i-1] - if previous_issue then - ui.script{ script = "prev_issues['initiative_" .. tostring(initiative.id) .. "'] = 'issue_" .. tostring(previous_issue.id) .. "';" } - end - - local previous_initiative = initiatives[j-1] - if previous_initiative then - ui.script{ script = "prev_initiatives['initiative_" .. tostring(initiative.id) .. "'] = 'initiative_" .. tostring(previous_initiative.id) .. "';" } - end - - ui.script{ script = "parents['initiative_" .. tostring(initiative.id) .. "'] = 'issue_" .. tostring(issue.id) .. "';" } - - local next_initiative = initiatives[j+1] - if next_initiative then - ui.script{ script = "next_initiatives['initiative_" .. tostring(initiative.id) .. "'] = 'initiative_" .. tostring(next_initiative.id) .. "';" } - end - - local next_issue = issues[i+1] - if next_issue then - ui.script{ script = "next_issues['initiative_" .. tostring(initiative.id) .. "'] = 'issue_" .. tostring(next_issue.id) .. "';" } - end - - ui.script{ - script = "document.getElementById('initiative_" .. tostring(initiative.id) .. "').style.display = 'none';" - } - - end -end - -ui.script{ - script = "document.getElementById('area_" .. tostring(area.id) .. "').style.display = 'none';" -} - diff -r b471e2429838 -r 609e37247615 app/main/report/index.lua --- a/app/main/report/index.lua Tue Feb 28 18:31:58 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,170 +0,0 @@ -function link_area(area) - ui.link{ - external = "", - attr = { - onclick = - "openEl('area_" .. tostring(area.id) .. "');" .. - "return(false);" - }, - content = function() - ui.heading{ - content = area.name - } - end - } -end - -slot.set_layout("report") - -slot.put("
") - -ui.container{ - attr = { - class = "nav", - style = "text-align: center;" - }, - content = function() - - - ui.container{ - attr = { - class = "left", - }, - content = function() - ui.link{ - external = "", - attr = { - onclick = "undo(); return(false);" - }, - content = function() - ui.image{ static = "icons/16/cancel.png" } - slot.put(" ") - slot.put(_"Back") - end - } - end - } - - ui.form{ - attr = { - style = "float: right;", - onsubmit = "openElDirect(); return(false);" - }, - content = function() - slot.put("#") - ui.tag{ - tag = "input", - attr = { - id = "input_issue", - type = "text", - style = "width: 4em;" - } - } - slot.put(".") - ui.tag{ - tag = "input", - attr = { - id = "input_initiative", - type = "text", - style = "width: 4em;" - } - } - slot.put(" ") - ui.tag{ - tag = "input", - attr = { - type = "submit", - value = "OK", - } - } - end - } - - - ui.link{ - external = "", - attr = { - onclick = "openPrevIssue(); return(false);" - }, - content = function() - ui.image{ static = "icons/16/resultset_previous_double.png" } - slot.put(" ") - slot.put(_"Previous issue") - end - } - - ui.link{ - external = "", - attr = { - onclick = "openPrevInitiative(); return(false);" - }, - content = function() - ui.image{ static = "icons/16/resultset_previous.png" } - slot.put(" ") - slot.put(_"Previous initiative") - end - } - - ui.link{ - external = "", - attr = { - onclick = "openParent(); return(false);" - }, - content = function() - ui.image{ static = "icons/16/go_up.png" } - slot.put(" ") - slot.put(_"Go up") - end - } - - ui.link{ - external = "", - attr = { - onclick = "openNextInitiative(); return(false);" - }, - content = function() - ui.image{ static = "icons/16/resultset_next.png" } - slot.put(" ") - slot.put(_"Next initiative") - end - } - - ui.link{ - external = "", - attr = { - onclick = "openNextIssue(); return(false);" - }, - content = function() - ui.image{ static = "icons/16/resultset_next_double.png" } - slot.put(" ") - slot.put(_"Next issue") - end - } - end -} - -slot.put("
") - -local areas = Area:new_selector():add_order_by("name"):exec() - - -ui.container{ - attr = { id = "areas" }, - content = function() - for i, area in ipairs(areas) do - link_area(area) - end - slot.put("

") - slot.put(_"This report can be saved (use 'save complete website') and used offline.") end -} - -ui.script{ script = "openEl('areas')" } - -for i, area in ipairs(areas) do - execute.view{ - module = "report", - view = "area", - params = { area = area } - } -end - diff -r b471e2429838 -r 609e37247615 app/main/report/initiative.lua --- a/app/main/report/initiative.lua Tue Feb 28 18:31:58 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +0,0 @@ -local initiative = param.get("initiative", "table") - -link_area(initiative.issue.area) - -link_issue(initiative.issue) - -ui.link{ - external = "", - attr = { - style = "display: block; text-decoration: none;", - name = "initiative_" .. tostring(initiative.id), - }, - content = function() - ui.heading{ - content = _("##{issue_id}.#{id} #{name}", { issue_id = initiative.issue.id, id = initiative.id, name = initiative.shortened_name }) - } - end -} - -slot.put("
") - -if initiative.issue.ranks_available and initiative.admitted then - local class = initiative.rank == 1 and "admitted_info" or "not_admitted_info" - ui.container{ - attr = { class = class }, - content = function() - local max_value = initiative.issue.voter_count - slot.put(" ") - local positive_votes = initiative.positive_votes - local negative_votes = initiative.negative_votes - slot.put(_"Yes" .. ": " .. tostring(positive_votes) .. "") - slot.put(" · ") - slot.put(_"Abstention" .. ": " .. tostring(max_value - initiative.negative_votes - initiative.positive_votes) .. "") - slot.put(" · ") - slot.put(_"No" .. ": " .. tostring(initiative.negative_votes) .. "") - slot.put(" · ") - slot.put("") - if initiative.rank == 1 then - slot.put(_"Approved") - elseif initiative.rank then - slot.put(_("Not approved (rank #{rank})", { rank = initiative.rank })) - else - slot.put(_"Not approved") - end - slot.put("") - end - } -end - -if initiative.issue.state == "cancelled" then - local policy = initiative.issue.policy - ui.container{ - attr = { class = "not_admitted_info" }, - content = _("This issue has been cancelled. It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.issue_quorum_num / policy.issue_quorum_den) }) - } -elseif initiative.admitted == false then - local policy = initiative.issue.policy - ui.container{ - attr = { class = "not_admitted_info" }, - content = _("This initiative has not been admitted! It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.initiative_quorum_num / policy.initiative_quorum_den) }) - } -end - -if initiative.revoked then - ui.container{ - attr = { class = "revoked_info" }, - content = function() - slot.put(_("This initiative has been revoked at #{revoked}", { revoked = format.timestamp(initiative.revoked) })) - end - } -end - - -ui.container{ - attr = { class = "draft_content wiki" }, - content = function() - slot.put(format.wiki_text(initiative.current_draft.content, initiative.current_draft.formatting_engine)) - end -} - -execute.view{ - module = "initiative", - view = "_battles", - params = { initiative = initiative } -} -