liquid_feedback_frontend

annotate app/main/initiative/_bargraph.lua @ 1566:7b7406a84346

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

Impressum / About Us