liquid_feedback_frontend

annotate app/main/initiative/_list.lua @ 2:5c601807d397

Version alpha3

Dark green part of issue supporter bargraph represents all satisfied supporters, regardless of having seen the latest draft

Wiki formatting for drafts

Showing differences between two drafts of the same initiative

Display of outgoing delegation chains

Many other improvements
author bsw
date Mon Nov 23 12:00:00 2009 +0100 (2009-11-23)
parents 3bfb2fcf7ab9
children 768faea1096d
rev   line source
bsw/jbe@0 1 local initiatives_selector = param.get("initiatives_selector", "table")
bsw/jbe@0 2 initiatives_selector:join("issue", nil, "issue.id = initiative.issue_id")
bsw/jbe@0 3
bsw/jbe@0 4 local issue = param.get("issue", "table")
bsw/jbe@0 5
bsw/jbe@0 6 local order_options = {}
bsw/jbe@0 7
bsw/jbe@0 8 if issue and issue.ranks_available then
bsw/jbe@0 9 order_options[#order_options+1] = {
bsw/jbe@0 10 name = "rank",
bsw/jbe@0 11 label = _"Rank",
bsw/jbe@0 12 order_by = "initiative.rank"
bsw/jbe@0 13 }
bsw/jbe@0 14 end
bsw/jbe@0 15
bsw/jbe@0 16 order_options[#order_options+1] = {
bsw/jbe@0 17 name = "support",
bsw/jbe@0 18 label = _"Support",
bsw/jbe@0 19 order_by = "initiative.supporter_count::float / issue.population::float DESC"
bsw/jbe@0 20 }
bsw/jbe@0 21
bsw/jbe@0 22 order_options[#order_options+1] = {
bsw/jbe@0 23 name = "support_si",
bsw/jbe@0 24 label = _"Support S+I",
bsw/jbe@0 25 order_by = "initiative.satisfied_informed_supporter_count::float / issue.population::float DESC"
bsw/jbe@0 26 }
bsw/jbe@0 27
bsw/jbe@0 28 order_options[#order_options+1] = {
bsw/jbe@0 29 name = "newest",
bsw/jbe@0 30 label = _"Newest",
bsw/jbe@0 31 order_by = "initiative.created DESC"
bsw/jbe@0 32 }
bsw/jbe@0 33
bsw/jbe@0 34 order_options[#order_options+1] = {
bsw/jbe@0 35 name = "oldest",
bsw/jbe@0 36 label = _"Oldest",
bsw/jbe@0 37 order_by = "initiative.created"
bsw/jbe@0 38 }
bsw/jbe@0 39
bsw/jbe@0 40 local name = "initiative_list"
bsw/jbe@0 41 if issue then
bsw/jbe@0 42 name = "issue_" .. tostring(issue.id) .. "_initiative_list"
bsw/jbe@0 43 end
bsw/jbe@0 44
bsw/jbe@0 45 ui.order{
bsw/jbe@0 46 name = name,
bsw/jbe@0 47 selector = initiatives_selector,
bsw/jbe@0 48 options = order_options,
bsw/jbe@0 49 content = function()
bsw/jbe@0 50 ui.paginate{
bsw/jbe@0 51 selector = initiatives_selector,
bsw/jbe@0 52 content = function()
bsw/jbe@0 53 local initiatives = initiatives_selector:exec()
bsw/jbe@0 54 local columns = {}
bsw@2 55 columns[#columns+1] = {
bsw@2 56 content = function(record)
bsw@2 57 if record.issue.accepted and record.issue.closed and record.issue.ranks_available then
bsw/jbe@0 58 ui.field.rank{ value = record.rank }
bsw/jbe@0 59 if record.negative_votes and record.positive_votes then
bsw/jbe@0 60 local max_value = record.issue.voter_count
bsw/jbe@0 61 ui.bargraph{
bsw/jbe@0 62 max_value = max_value,
bsw@2 63 width = 200,
bsw/jbe@0 64 bars = {
bsw/jbe@0 65 { color = "#0a0", value = record.positive_votes },
bsw/jbe@0 66 { color = "#aaa", value = max_value - record.negative_votes - record.positive_votes },
bsw/jbe@0 67 { color = "#a00", value = record.negative_votes },
bsw/jbe@0 68 }
bsw/jbe@0 69 }
bsw/jbe@0 70 end
bsw@2 71 else
bsw/jbe@0 72 local max_value = (record.issue.population or 0)
bsw/jbe@0 73 ui.bargraph{
bsw/jbe@0 74 max_value = max_value,
bsw@2 75 width = 200,
bsw/jbe@0 76 bars = {
bsw@2 77 { color = "#0a0", value = (record.satisfied_supporter_count or 0) },
bsw@2 78 { color = "#8f8", value = (record.supporter_count or 0) - (record.satisfied_supporter_count or 0) },
bsw/jbe@0 79 { color = "#ddd", value = max_value - (record.supporter_count or 0) },
bsw/jbe@0 80 }
bsw/jbe@0 81 }
bsw/jbe@0 82 end
bsw@2 83 end
bsw@2 84 }
bsw/jbe@0 85 columns[#columns+1] = {
bsw/jbe@0 86 content = function(record)
bsw/jbe@0 87 ui.link{
bsw/jbe@0 88 content = function()
bsw@2 89 local name
bsw@2 90 if record.name_highlighted then
bsw@2 91 name = encode.highlight(record.name_highlighted)
bsw@2 92 else
bsw@2 93 name = encode.html(record.name)
bsw@2 94 end
bsw@2 95 slot.put(name)
bsw/jbe@0 96 end,
bsw/jbe@0 97 module = "initiative",
bsw/jbe@0 98 view = "show",
bsw/jbe@0 99 id = record.id
bsw/jbe@0 100 }
bsw@2 101 if record.issue.state == "new" then
bsw@2 102 ui.image{
bsw@2 103 static = "icons/16/new.png"
bsw@2 104 }
bsw@2 105 end
bsw/jbe@0 106 end
bsw/jbe@0 107 }
bsw/jbe@0 108
bsw/jbe@0 109 ui.list{
bsw/jbe@0 110 attr = { class = "initiatives" },
bsw/jbe@0 111 records = initiatives,
bsw/jbe@0 112 columns = columns
bsw/jbe@0 113 }
bsw/jbe@0 114 end
bsw/jbe@0 115 }
bsw/jbe@0 116 end
bsw/jbe@0 117 }

Impressum / About Us