liquid_feedback_frontend

view app/main/initiative/_list_element.lua @ 285:6c88b4bfb56c

Apply interest/support filter for member at member page
author bsw
date Fri Feb 17 15:16:02 2012 +0100 (2012-02-17)
parents 808269b7f41c
children 44f9a09ea51c
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 if initiative.is_supporter_via_delegation then
94 link_class = link_class .. " supported"
95 end
96 ui.link{
97 attr = { id = link_name, class = link_class },
98 content = function()
99 local name
100 if initiative.name_highlighted then
101 name = encode.highlight(initiative.name_highlighted)
102 else
103 name = encode.html(initiative.shortened_name)
104 end
105 ui.tag{ content = "i" .. initiative.id .. ": " }
106 slot.put(name)
107 end,
108 module = module,
109 view = view,
110 id = id,
111 params = params,
112 }
114 if initiative.is_initiator then
115 slot.put(" ")
116 local label = _"You are initiator of this initiative"
117 ui.image{
118 attr = { alt = label, title = label },
119 static = "icons/16/user_edit.png"
120 }
121 end
123 end
124 }
125 }
126 }
127 end
128 }
129 end
130 }
132 if ui.is_partial_loading_enabled() then
133 ui.container{
134 attr = {
135 id = name,
136 class = "ui_tabs_accordeon_content",
137 },
138 content = function()
139 ui.container{
140 attr = { id = name .. "_content", style = "clear: left;" },
141 content = function()
142 execute.view{
143 module = "initiative",
144 view = "show_partial",
145 params = {
146 initiative = initiative,
147 }
148 }
149 end
150 }
151 end
152 }
153 end

Impressum / About Us