liquid_feedback_frontend
diff app/main/suggestion/_collective_rating.lua @ 1649:4188405c2425
Rework of suggestion views
author | bsw |
---|---|
date | Thu Feb 11 15:48:02 2021 +0100 (2021-02-11) |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/app/main/suggestion/_collective_rating.lua Thu Feb 11 15:48:02 2021 +0100 1.3 @@ -0,0 +1,54 @@ 1.4 +local suggestion = param.get("suggestion", "table") 1.5 + 1.6 +local plus2 = (suggestion.plus2_unfulfilled_count or 0) 1.7 + + (suggestion.plus2_fulfilled_count or 0) 1.8 +local plus1 = (suggestion.plus1_unfulfilled_count or 0) 1.9 +local minus1 = (suggestion.minus1_unfulfilled_count or 0) 1.10 + + (suggestion.minus1_fulfilled_count or 0) 1.11 +local minus2 = (suggestion.minus2_unfulfilled_count or 0) 1.12 + + (suggestion.minus2_fulfilled_count or 0) 1.13 + 1.14 +local with_opinion = plus2 + plus1 + minus1 + minus2 1.15 + 1.16 +local neutral = (suggestion.initiative.supporter_count or 0) 1.17 + - with_opinion 1.18 + 1.19 +local neutral2 = with_opinion 1.20 + - (suggestion.plus2_fulfilled_count or 0) 1.21 + - (suggestion.plus1_fulfilled_count or 0) 1.22 + - (suggestion.minus1_fulfilled_count or 0) 1.23 + - (suggestion.minus2_fulfilled_count or 0) 1.24 + 1.25 + 1.26 +if with_opinion > 0 then 1.27 + ui.container { attr = { class = "suggestion-rating" }, content = function () 1.28 + ui.tag { content = _"collective rating:" } 1.29 + slot.put(" ") 1.30 + ui.bargraph{ 1.31 + max_value = suggestion.initiative.supporter_count, 1.32 + width = 100, 1.33 + bars = { 1.34 + { color = "#0a0", value = plus2 }, 1.35 + { color = "#8a8", value = plus1 }, 1.36 + { color = "#eee", value = neutral }, 1.37 + { color = "#a88", value = minus1 }, 1.38 + { color = "#a00", value = minus2 }, 1.39 + } 1.40 + } 1.41 + slot.put(" | ") 1.42 + ui.tag { content = _"implemented:" } 1.43 + slot.put ( " " ) 1.44 + ui.bargraph{ 1.45 + max_value = with_opinion, 1.46 + width = 100, 1.47 + bars = { 1.48 + { color = "#0a0", value = suggestion.plus2_fulfilled_count }, 1.49 + { color = "#8a8", value = suggestion.plus1_fulfilled_count }, 1.50 + { color = "#eee", value = neutral2 }, 1.51 + { color = "#a88", value = suggestion.minus1_fulfilled_count }, 1.52 + { color = "#a00", value = suggestion.minus2_fulfilled_count }, 1.53 + } 1.54 + } 1.55 + end } 1.56 +end 1.57 +