liquid_feedback_frontend

annotate app/main/suggestion/_collective_rating.lua @ 1694:bca6a066d429

Fixed area without unit in single_unit mode
author bsw
date Thu Sep 23 14:29:39 2021 +0200 (2021-09-23)
parents 4188405c2425
children
rev   line source
bsw@1649 1 local suggestion = param.get("suggestion", "table")
bsw@1649 2
bsw@1649 3 local plus2 = (suggestion.plus2_unfulfilled_count or 0)
bsw@1649 4 + (suggestion.plus2_fulfilled_count or 0)
bsw@1649 5 local plus1 = (suggestion.plus1_unfulfilled_count or 0)
bsw@1649 6 local minus1 = (suggestion.minus1_unfulfilled_count or 0)
bsw@1649 7 + (suggestion.minus1_fulfilled_count or 0)
bsw@1649 8 local minus2 = (suggestion.minus2_unfulfilled_count or 0)
bsw@1649 9 + (suggestion.minus2_fulfilled_count or 0)
bsw@1649 10
bsw@1649 11 local with_opinion = plus2 + plus1 + minus1 + minus2
bsw@1649 12
bsw@1649 13 local neutral = (suggestion.initiative.supporter_count or 0)
bsw@1649 14 - with_opinion
bsw@1649 15
bsw@1649 16 local neutral2 = with_opinion
bsw@1649 17 - (suggestion.plus2_fulfilled_count or 0)
bsw@1649 18 - (suggestion.plus1_fulfilled_count or 0)
bsw@1649 19 - (suggestion.minus1_fulfilled_count or 0)
bsw@1649 20 - (suggestion.minus2_fulfilled_count or 0)
bsw@1649 21
bsw@1649 22
bsw@1649 23 if with_opinion > 0 then
bsw@1649 24 ui.container { attr = { class = "suggestion-rating" }, content = function ()
bsw@1649 25 ui.tag { content = _"collective rating:" }
bsw@1649 26 slot.put(" ")
bsw@1649 27 ui.bargraph{
bsw@1649 28 max_value = suggestion.initiative.supporter_count,
bsw@1649 29 width = 100,
bsw@1649 30 bars = {
bsw@1649 31 { color = "#0a0", value = plus2 },
bsw@1649 32 { color = "#8a8", value = plus1 },
bsw@1649 33 { color = "#eee", value = neutral },
bsw@1649 34 { color = "#a88", value = minus1 },
bsw@1649 35 { color = "#a00", value = minus2 },
bsw@1649 36 }
bsw@1649 37 }
bsw@1649 38 slot.put(" | ")
bsw@1649 39 ui.tag { content = _"implemented:" }
bsw@1649 40 slot.put ( " " )
bsw@1649 41 ui.bargraph{
bsw@1649 42 max_value = with_opinion,
bsw@1649 43 width = 100,
bsw@1649 44 bars = {
bsw@1649 45 { color = "#0a0", value = suggestion.plus2_fulfilled_count },
bsw@1649 46 { color = "#8a8", value = suggestion.plus1_fulfilled_count },
bsw@1649 47 { color = "#eee", value = neutral2 },
bsw@1649 48 { color = "#a88", value = suggestion.minus1_fulfilled_count },
bsw@1649 49 { color = "#a00", value = suggestion.minus2_fulfilled_count },
bsw@1649 50 }
bsw@1649 51 }
bsw@1649 52 end }
bsw@1649 53 end
bsw@1649 54

Impressum / About Us