liquid_feedback_frontend

view app/main/initiative/_list.lua @ 3:768faea1096d

Version alpha4

Members interested in an issue or supporting an initiative have a weight information attached. Browsing the members causing that weight is possible.

Initiatives may provide a link to an external discussion platform

Direct link on every initiative page to create an alternative initiative

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

Impressum / About Us