liquid_feedback_frontend

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

Impressum / About Us