liquid_feedback_frontend

annotate app/main/initiative/_list.lua @ 4:80c215dbf076

Version alpha5

Many optical changes and improved usability

Support for different wiki-formatting-engines

Help system
author bsw/jbe
date Thu Dec 10 12:00:00 2009 +0100 (2009-12-10)
parents 768faea1096d
children afd9f769c7ae
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@3 58 ui.field.rank{ attr = { class = "rank" }, value = record.rank }
bsw@3 59 end
bsw@3 60 end
bsw@3 61 }
bsw@3 62 columns[#columns+1] = {
bsw@3 63 content = function(record)
bsw@3 64 if record.issue.accepted and record.issue.closed and record.issue.ranks_available then
bsw/jbe@0 65 if record.negative_votes and record.positive_votes then
bsw/jbe@0 66 local max_value = record.issue.voter_count
bsw/jbe@0 67 ui.bargraph{
bsw/jbe@0 68 max_value = max_value,
bsw/jbe@4 69 width = 100,
bsw/jbe@0 70 bars = {
bsw/jbe@0 71 { color = "#0a0", value = record.positive_votes },
bsw/jbe@0 72 { color = "#aaa", value = max_value - record.negative_votes - record.positive_votes },
bsw/jbe@0 73 { color = "#a00", value = record.negative_votes },
bsw/jbe@0 74 }
bsw/jbe@0 75 }
bsw/jbe@0 76 end
bsw@2 77 else
bsw/jbe@0 78 local max_value = (record.issue.population or 0)
bsw/jbe@0 79 ui.bargraph{
bsw/jbe@0 80 max_value = max_value,
bsw/jbe@4 81 width = 100,
bsw/jbe@0 82 bars = {
bsw@2 83 { color = "#0a0", value = (record.satisfied_supporter_count or 0) },
bsw@2 84 { color = "#8f8", value = (record.supporter_count or 0) - (record.satisfied_supporter_count or 0) },
bsw/jbe@0 85 { color = "#ddd", value = max_value - (record.supporter_count or 0) },
bsw/jbe@0 86 }
bsw/jbe@0 87 }
bsw/jbe@0 88 end
bsw@2 89 end
bsw@2 90 }
bsw/jbe@0 91 columns[#columns+1] = {
bsw/jbe@0 92 content = function(record)
bsw/jbe@0 93 ui.link{
bsw/jbe@0 94 content = function()
bsw@2 95 local name
bsw@2 96 if record.name_highlighted then
bsw@2 97 name = encode.highlight(record.name_highlighted)
bsw@2 98 else
bsw@2 99 name = encode.html(record.name)
bsw@2 100 end
bsw@2 101 slot.put(name)
bsw/jbe@0 102 end,
bsw/jbe@0 103 module = "initiative",
bsw/jbe@0 104 view = "show",
bsw/jbe@0 105 id = record.id
bsw/jbe@0 106 }
bsw@2 107 if record.issue.state == "new" then
bsw@2 108 ui.image{
bsw@2 109 static = "icons/16/new.png"
bsw@2 110 }
bsw@2 111 end
bsw/jbe@0 112 end
bsw/jbe@0 113 }
bsw/jbe@0 114
bsw/jbe@0 115 ui.list{
bsw/jbe@0 116 attr = { class = "initiatives" },
bsw/jbe@0 117 records = initiatives,
bsw/jbe@0 118 columns = columns
bsw/jbe@0 119 }
bsw/jbe@0 120 end
bsw/jbe@0 121 }
bsw/jbe@0 122 end
bsw/jbe@0 123 }

Impressum / About Us