liquid_feedback_frontend
view app/main/initiative/_list_element.lua @ 552:3344717939f0
Improved interest and support filters for issues
author | bsw |
---|---|
date | Fri Jun 15 20:46:25 2012 +0200 (2012-06-15) |
parents | c1dc3b14a4f3 |
children | 53f93f0ffa6e |
line source
1 local initiative = param.get("initiative", "table")
2 local selected = param.get("selected", atom.boolean)
5 ui.container{ attr = { class = "initiative" }, content = function()
7 ui.container{ attr = { class = "rank" }, content = function()
8 if initiative.issue.accepted and initiative.issue.closed
9 and initiative.issue.ranks_available or initiative.admitted == false
10 then
11 ui.field.rank{ attr = { class = "rank" }, value = initiative.rank, eligible = initiative.eligible }
12 elseif not initiative.issue.closed then
13 ui.image{ static = "icons/16/script.png" }
14 else
15 ui.image{ static = "icons/16/cross.png" }
16 end
17 end }
19 ui.container{ attr = { class = "bar" }, content = function()
20 if initiative.issue.fully_frozen and initiative.issue.closed then
21 if initiative.issue.ranks_available then
22 if initiative.negative_votes and initiative.positive_votes then
23 local max_value = initiative.issue.voter_count
24 ui.bargraph{
25 max_value = max_value,
26 width = 100,
27 bars = {
28 { color = "#0a0", value = initiative.positive_votes },
29 { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes },
30 { color = "#a00", value = initiative.negative_votes },
31 }
32 }
33 else
34 slot.put(" ")
35 end
36 else
37 slot.put(_"Counting of votes")
38 end
39 else
40 local max_value = initiative.issue.population or 0
41 local quorum
42 if initiative.issue.accepted then
43 quorum = initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den
44 else
45 quorum = initiative.issue.policy.issue_quorum_num / initiative.issue.policy.issue_quorum_den
46 end
47 ui.bargraph{
48 max_value = max_value,
49 width = 100,
50 quorum = max_value * quorum,
51 quorum_color = "#00F",
52 bars = {
53 { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) },
54 { color = "#999", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
55 { color = "#ddd", value = max_value - (initiative.supporter_count or 0) },
56 }
57 }
58 end
59 end }
61 ui.container{ attr = { class = "interest" }, content = function()
62 if initiative.member_info.initiated then
63 local label = _"You are initiator of this initiative"
64 ui.image{
65 attr = { alt = label, title = label },
66 static = "icons/16/user_edit.png"
67 }
68 elseif initiative.member_info.directly_supported then
69 if initiative.member_info.satisfied then
70 local label = _"You are supporter of this initiative"
71 ui.image{
72 attr = { alt = label, title = label },
73 static = "icons/16/thumb_up_green.png"
74 }
75 else
76 local label = _"You are potential supporter of this initiative"
77 ui.image{
78 attr = { alt = label, title = label },
79 static = "icons/16/thumb_up.png"
80 }
81 end
82 elseif initiative.member_info.supported then
83 if initiative.member_info.satisfied then
84 local label = _"You are supporter of this initiative via delegation"
85 ui.image{
86 attr = { alt = label, title = label },
87 static = "icons/16/thumb_up_green_arrow.png"
88 }
89 else
90 local label = _"You are potential supporter of this initiative via delegation"
91 ui.image{
92 attr = { alt = label, title = label },
93 static = "icons/16/thumb_up_arrow.png"
94 }
95 end
96 end
97 end }
99 ui.container{ attr = { class = "name" }, content = function()
100 local link_class = "initiative_link"
101 if initiative.revoked then
102 link_class = "revoked"
103 end
104 if selected then
105 link_class = link_class .. " selected"
106 end
107 if initiative.is_supporter then
108 link_class = link_class .. " supported"
109 end
110 if initiative.is_potential_supporter then
111 link_class = link_class .. " potentially_supported"
112 end
113 if initiative.is_supporter_via_delegation then
114 link_class = link_class .. " supported"
115 end
116 ui.link{
117 attr = { class = link_class },
118 content = function()
119 local name
120 if initiative.name_highlighted then
121 name = encode.highlight(initiative.name_highlighted)
122 else
123 name = encode.html(initiative.shortened_name)
124 end
125 ui.tag{ content = "i" .. initiative.id .. ": " }
126 slot.put(name)
127 end,
128 module = "initiative",
129 view = "show",
130 id = initiative.id
131 }
133 end }
135 end }