liquid_feedback_frontend

view app/main/initiative/_list_element.lua @ 280:808269b7f41c

More repositioning and optical enhancements
author bsw
date Thu Feb 16 14:08:55 2012 +0100 (2012-02-16)
parents fecd4c13054a
children 6c88b4bfb56c
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: 110px;"},
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 content = function()
80 local link_class = "initiative_link"
81 if initiative.revoked then
82 link_class = "revoked"
83 end
84 if selected then
85 link_class = link_class .. " selected"
86 end
87 if initiative.is_supporter then
88 link_class = link_class .. " supported"
89 end
90 if initiative.is_potential_supporter then
91 link_class = link_class .. " potentially_supported"
92 end
93 ui.link{
94 attr = { id = link_name, class = link_class },
95 content = function()
96 local name
97 if initiative.name_highlighted then
98 name = encode.highlight(initiative.name_highlighted)
99 else
100 name = encode.html(initiative.shortened_name)
101 end
102 ui.tag{ content = "i" .. initiative.id .. ": " }
103 slot.put(name)
104 end,
105 module = module,
106 view = view,
107 id = id,
108 params = params,
109 }
111 if initiative.is_initiator then
112 slot.put(" ")
113 local label = _"You are initiator of this initiative"
114 ui.image{
115 attr = { alt = label, title = label },
116 static = "icons/16/user_edit.png"
117 }
118 end
120 end
121 }
122 }
123 }
124 end
125 }
126 end
127 }
129 if ui.is_partial_loading_enabled() then
130 ui.container{
131 attr = {
132 id = name,
133 class = "ui_tabs_accordeon_content",
134 },
135 content = function()
136 ui.container{
137 attr = { id = name .. "_content", style = "clear: left;" },
138 content = function()
139 execute.view{
140 module = "initiative",
141 view = "show_partial",
142 params = {
143 initiative = initiative,
144 }
145 }
146 end
147 }
148 end
149 }
150 end

Impressum / About Us