liquid_feedback_frontend
diff app/main/initiative/_battles.lua @ 31:a6caaff47205
Report view for all closed issues added
author | bsw |
---|---|
date | Tue Feb 23 21:09:10 2010 +0100 (2010-02-23) |
parents | |
children | cc64a4fc6ab6 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/app/main/initiative/_battles.lua Tue Feb 23 21:09:10 2010 +0100 1.3 @@ -0,0 +1,99 @@ 1.4 +local initiative = param.get("initiative", "table") 1.5 + 1.6 +if not initiative.issue.closed then 1.7 + return 1.8 +end 1.9 + 1.10 +local battled_initiatives = Initiative:new_selector() 1.11 + :add_field("winning_battle.count", "winning_count") 1.12 + :add_field("losing_battle.count", "losing_count") 1.13 + :join("battle", "winning_battle", { "winning_battle.winning_initiative_id = ? AND winning_battle.losing_initiative_id = initiative.id", initiative.id }) 1.14 + :join("battle", "losing_battle", { "losing_battle.losing_initiative_id = ? AND losing_battle.winning_initiative_id = initiative.id", initiative.id }) 1.15 + :add_order_by("rank") 1.16 + :exec() 1.17 + 1.18 + 1.19 +local number_of_initiatives = Initiative:new_selector() 1.20 + :add_where{ "issue_id = ?", initiative.issue_id } 1.21 + :add_where("admitted") 1.22 + :count() 1.23 + 1.24 +if number_of_initiatives > 1 then 1.25 + ui.container{ 1.26 + attr = { class = "heading first" }, 1.27 + content = _"This initiative compared to alternative initiatives" 1.28 + } 1.29 + 1.30 + ui.list{ 1.31 + records = battled_initiatives, 1.32 + columns = { 1.33 + { 1.34 + content = function() 1.35 + slot.put(_"This initiative") 1.36 + end 1.37 + }, 1.38 + { 1.39 + content = function(record) 1.40 + local population = initiative.issue.voter_count 1.41 + local value = record.winning_count 1.42 + ui.bargraph{ 1.43 + class = "bargraph bargraph50", 1.44 + max_value = population, 1.45 + width = 50, 1.46 + bars = { 1.47 + { color = "#aaa", value = population - value }, 1.48 + { color = "#444", value = value }, 1.49 + } 1.50 + } 1.51 + end 1.52 + }, 1.53 + { 1.54 + content = function(record) 1.55 + slot.put(record.winning_count) 1.56 + end 1.57 + }, 1.58 + { 1.59 + content = function(record) 1.60 + if record.winning_count == record.losing_count then 1.61 + ui.image{ static = "icons/16/bullet_blue.png" } 1.62 + elseif record.winning_count > record.losing_count then 1.63 + ui.image{ static = "icons/16/resultset_previous.png" } 1.64 + else 1.65 + ui.image{ static = "icons/16/resultset_next.png" } 1.66 + end 1.67 + end 1.68 + }, 1.69 + { 1.70 + field_attr = { style = "text-align: right;" }, 1.71 + content = function(record) 1.72 + slot.put(record.losing_count) 1.73 + end 1.74 + }, 1.75 + { 1.76 + content = function(record) 1.77 + local population = initiative.issue.voter_count 1.78 + local value = record.losing_count 1.79 + ui.bargraph{ 1.80 + class = "bargraph bargraph50", 1.81 + max_value = population, 1.82 + width = 50, 1.83 + bars = { 1.84 + { color = "#444", value = value }, 1.85 + { color = "#aaa", value = population - value }, 1.86 + } 1.87 + } 1.88 + end 1.89 + }, 1.90 + { 1.91 + content = function(record) 1.92 + ui.link{ 1.93 + module = "initiative", 1.94 + view = "show", 1.95 + id = record.id, 1.96 + text = record.name 1.97 + } 1.98 + end 1.99 + } 1.100 + } 1.101 + } 1.102 +end