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