liquid_feedback_frontend
view app/main/initiative/_list_element.lua @ 278:fecd4c13054a
Code/css clean up and minor enhancements
author | bsw |
---|---|
date | Mon Feb 13 01:53:41 2012 +0100 (2012-02-13) |
parents | aec9df5b4cd3 |
children | 808269b7f41c |
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; padding: 0; 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: 110px; padding: 0;"},
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 = "#eee", value = max_value - (initiative.supporter_count or 0) },
72 }
73 }
74 end
75 end
76 },
78 {
79 field_attr = { style = "padding: 0;"},
80 content = function()
81 local link_class = "initiative_link"
82 if initiative.revoked then
83 link_class = "revoked"
84 end
85 if selected then
86 link_class = link_class .. " selected"
87 end
88 if initiative.is_supporter then
89 link_class = link_class .. " supported"
90 end
91 if initiative.is_potential_supporter then
92 link_class = link_class .. " potentially_supported"
93 end
94 ui.link{
95 attr = { id = link_name, class = link_class },
96 content = function()
97 local name
98 if initiative.name_highlighted then
99 name = encode.highlight(initiative.name_highlighted)
100 else
101 name = encode.html(initiative.shortened_name)
102 end
103 ui.tag{ content = "i" .. initiative.id .. ": " }
104 slot.put(name)
105 end,
106 module = module,
107 view = view,
108 id = id,
109 params = params,
110 }
112 if initiative.is_initiator then
113 slot.put(" ")
114 local label = _"You are initiator of this initiative"
115 ui.image{
116 attr = { alt = label, title = label },
117 static = "icons/16/user_edit.png"
118 }
119 end
121 end
122 }
123 }
124 }
125 end
126 }
127 end
128 }
130 if ui.is_partial_loading_enabled() then
131 ui.container{
132 attr = {
133 id = name,
134 class = "ui_tabs_accordeon_content",
135 },
136 content = function()
137 ui.container{
138 attr = { id = name .. "_content", style = "clear: left;" },
139 content = function()
140 execute.view{
141 module = "initiative",
142 view = "show_partial",
143 params = {
144 initiative = initiative,
145 }
146 }
147 end
148 }
149 end
150 }
151 end