liquid_feedback_frontend

view app/main/initiative/_bargraph.lua @ 1858:3d1f0464a3ea

Handle missing ldap.member.allowed function
author bsw
date Tue Sep 20 17:35:29 2022 +0200 (20 months ago)
parents 32cc544d5a5b
children
line source
1 local initiative = param.get("initiative", "table")
2 local batteled_initiative = param.get("battled_initiative", "table")
4 local grey = "#eee"
6 if initiative.issue.fully_frozen and initiative.issue.closed
7 and initiative.negative_votes and initiative.positive_votes and initiative.rank ~= 1 then
8 if not batteled_initiative then
9 return
10 end
11 local battle1 = Battle:getByInitiativeIds(batteled_initiative.id, initiative.id)
12 local battle2 = Battle:getByInitiativeIds(initiative.id, batteled_initiative.id)
14 if not battle1 or not battle2 then
15 return
16 end
18 local positive_votes = battle2.count
19 local negative_votes = battle1.count
21 local max_value = initiative.issue.voter_count
22 if max_value > 0 then
23 ui.bargraph{
24 max_value = max_value * 2,
25 width = 100,
26 bars = {
27 { color = grey, value = max_value - negative_votes },
28 { color = "#a00", value = negative_votes },
29 { color = "#0a0", value = positive_votes },
30 { color = grey, value = max_value - positive_votes },
31 }
32 }
33 else
34 ui.bargraph{
35 max_value = 1,
36 width = 100,
37 bars = {
38 { color = grey, value = 1 },
39 }
40 }
41 end
42 else
43 local max_value = initiative.issue.population or 0
44 local quorum
45 if initiative.issue.accepted then
46 quorum = initiative.issue.initiative_quorum or 0
47 else
48 quorum = initiative.issue.issue_quorum or 0
49 end
50 if quorum > max_value then
51 max_value = quorum
52 end
53 ui.bargraph{
54 max_value = max_value,
55 width = 100,
56 quorum = quorum,
57 quorum_color = "#00F",
58 bars = {
59 { color = "#5a5", value = (initiative.satisfied_supporter_count or 0) },
60 { color = "#fa5", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
61 { color = grey, value = max_value - (initiative.supporter_count or 0) },
62 }
63 }
64 end

Impressum / About Us