liquid_feedback_frontend

view app/main/initiative/_list_element.lua @ 317:9c639a2f3262

More color changes and some shadows added
author bsw
date Tue Feb 28 15:43:22 2012 +0100 (2012-02-28)
parents 5e6bdf07e3a1
children 0ec49ed35954
line source
1 local initiative = param.get("initiative", "table")
2 local selected = param.get("selected", atom.boolean)
4 local head_name = "initiative_head_" .. tostring(initiative.id)
5 local link_name = "initiative_link_" .. tostring(initiative.id)
6 local name = "initiative_content_" .. tostring(initiative.id)
7 local icon_name = "initiative_icon_" .. tostring(initiative.id)
9 ui.container{
10 attr = { class = "ui_tabs" .. (initiative.id == for_initiative_id and " active" or "") },
11 content = function()
12 local module = "initiative"
13 local view = "show"
14 local id = initiative.id
15 local params = {}
16 ui.container{
17 attr = {
18 name = name,
19 class = "ui_tabs_accordeon_head",
20 id = head_name,
21 },
22 content = function()
24 ui.list{
25 attr = { class = "nohover" },
26 records = { { a = 1} },
27 columns = {
28 {
29 field_attr = { style = "width: 3em; text-align: center;"},
30 content = function()
31 if initiative.issue.accepted and initiative.issue.closed and initiative.issue.ranks_available or initiative.admitted == false then
32 ui.field.rank{ image_attr = { id = icon_name }, attr = { class = "rank" }, value = initiative.rank }
33 else
34 slot.put(" ")
35 end
36 end
37 },
39 {
40 field_attr = { style = "width: 100px;"},
41 content = function()
42 if initiative.issue.fully_frozen and initiative.issue.closed then
43 if initiative.issue.ranks_available then
44 if initiative.negative_votes and initiative.positive_votes then
45 local max_value = initiative.issue.voter_count
46 ui.bargraph{
47 max_value = max_value,
48 width = 100,
49 bars = {
50 { color = "#0a0", value = initiative.positive_votes },
51 { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes },
52 { color = "#a00", value = initiative.negative_votes },
53 }
54 }
55 else
56 slot.put(" ")
57 end
58 else
59 slot.put(_"Counting of votes")
60 end
61 else
62 local max_value = initiative.issue.population or 0
63 ui.bargraph{
64 max_value = max_value,
65 width = 100,
66 quorum = max_value * (initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den),
67 quorum_color = "#00F",
68 bars = {
69 { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) },
70 { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
71 { color = "#f7f7f7", value = max_value - (initiative.supporter_count or 0) },
72 }
73 }
74 end
75 end
76 },
77 {
78 field_attr = { style = "width: 24px;" },
79 content = function()
80 if initiative.is_initiator then
81 slot.put(" ")
82 local label = _"You are initiator of this initiative"
83 ui.image{
84 attr = { alt = label, title = label },
85 static = "icons/16/user_edit.png"
86 }
87 elseif initiative.is_supporter then
88 slot.put(" ")
89 local label = _"You are supporter of this initiative"
90 ui.image{
91 attr = { alt = label, title = label },
92 static = "icons/16/thumb_up_green.png"
93 }
94 elseif initiative.is_potential_supporter then
95 slot.put(" ")
96 local label = _"You are potentially supporter of this initiative"
97 ui.image{
98 attr = { alt = label, title = label },
99 static = "icons/16/thumb_up.png"
100 }
101 elseif initiative.is_supporter_via_delegation then
102 slot.put(" ")
103 local label = _"You are supporter of this initiative via delegation"
104 ui.image{
105 attr = { alt = label, title = label },
106 static = "icons/16/thumb_up_green.png"
107 }
108 end
110 end
111 },
112 {
113 content = function()
114 local link_class = "initiative_link"
115 if initiative.revoked then
116 link_class = "revoked"
117 end
118 if selected then
119 link_class = link_class .. " selected"
120 end
121 if initiative.is_supporter then
122 link_class = link_class .. " supported"
123 end
124 if initiative.is_potential_supporter then
125 link_class = link_class .. " potentially_supported"
126 end
127 if initiative.is_supporter_via_delegation then
128 link_class = link_class .. " supported"
129 end
130 ui.link{
131 attr = { id = link_name, class = link_class },
132 content = function()
133 local name
134 if initiative.name_highlighted then
135 name = encode.highlight(initiative.name_highlighted)
136 else
137 name = encode.html(initiative.shortened_name)
138 end
139 ui.tag{ content = "i" .. initiative.id .. ": " }
140 slot.put(name)
141 end,
142 module = module,
143 view = view,
144 id = id,
145 params = params,
146 }
148 end
149 }
150 }
151 }
152 end
153 }
154 end
155 }
157 if ui.is_partial_loading_enabled() then
158 ui.container{
159 attr = {
160 id = name,
161 class = "ui_tabs_accordeon_content",
162 },
163 content = function()
164 ui.container{
165 attr = { id = name .. "_content", style = "clear: left;" },
166 content = function()
167 execute.view{
168 module = "initiative",
169 view = "show_partial",
170 params = {
171 initiative = initiative,
172 }
173 }
174 end
175 }
176 end
177 }
178 end

Impressum / About Us