liquid_feedback_frontend
diff app/main/initiative/_suggestions.lua @ 1792:fe28be5403e2
Better handling of combined sentence on suggestion rating
| author | bsw | 
|---|---|
| date | Wed Oct 20 16:21:32 2021 +0200 (2021-10-20) | 
| parents | 048d6bae2855 | 
| children | 080f4112b8a9 | 
   line diff
1.1 --- a/app/main/initiative/_suggestions.lua Wed Oct 20 16:04:30 2021 +0200 1.2 +++ b/app/main/initiative/_suggestions.lua Wed Oct 20 16:21:32 2021 +0200 1.3 @@ -251,37 +251,38 @@ 1.4 if direct_supporter then 1.5 ui.container{ attr = { class = "suggestion_rating_info" }, content = function() 1.6 ui.tag{ attr = { id = "s" .. suggestion.id .. "_rating_text" }, content = function() 1.7 - local text = "" 1.8 + local text_opinion = "" 1.9 if opinion then 1.10 - if opinion.degree == 2 then 1.11 - text = _"must" 1.12 - elseif opinion.degree == 1 then 1.13 - text = _"should" 1.14 - elseif opinion.degree == 0 then 1.15 - text = _"neutral" 1.16 - elseif opinion.degree == -1 then 1.17 - text = _"should not" 1.18 - elseif opinion.degree == -2 then 1.19 - text = _"must not" 1.20 - end 1.21 - ui.tag { content = text } 1.22 - slot.put ( " " ) 1.23 + local text_template 1.24 if 1.25 (opinion.degree > 0 and not opinion.fulfilled) 1.26 or (opinion.degree < 0 and opinion.fulfilled) 1.27 then 1.28 - ui.tag{ content = _"but" } 1.29 + text_template = _"#{opinion} but #{implemented}" 1.30 else 1.31 - ui.tag{ content = _"and" } 1.32 + text_template = _"#{opinion} and #{implemented}" 1.33 end 1.34 - slot.put ( " " ) 1.35 - local text = "" 1.36 + if opinion.degree == 2 then 1.37 + text_opinion = _"must" 1.38 + elseif opinion.degree == 1 then 1.39 + text_opinion = _"should" 1.40 + elseif opinion.degree == 0 then 1.41 + text_opinion = _"neutral" 1.42 + elseif opinion.degree == -1 then 1.43 + text_opinion = _"should not" 1.44 + elseif opinion.degree == -2 then 1.45 + text_opinion = _"must not" 1.46 + end 1.47 + local text_implemented = "" 1.48 if opinion.fulfilled then 1.49 - text = _"is implemented" 1.50 + text_implemented = _"is implemented" 1.51 else 1.52 - text = _"is not implemented" 1.53 + text_implemented = _"is not implemented" 1.54 end 1.55 - ui.tag { content = text } 1.56 + ui.tag { content = _(text_template, { 1.57 + opinion = text_opinion, 1.58 + implemented = text_implemented 1.59 + }) } 1.60 end 1.61 end } 1.62 local id = "s" .. suggestion.id .. "_rating_icon" 1.63 @@ -332,14 +333,14 @@ 1.64 ui.script{ script = [[ 1.65 var rateSuggestionRateText = "]] .. _"rate suggestion" .. [["; 1.66 var rateSuggestionUpdateRatingText = "]] .. _"update rating" .. [["; 1.67 + var rateSuggestionAndText = "]] .. _"#{opinion} and #{implemented}" .. [["; 1.68 + var rateSuggestionButText = "]] .. _"#{opinion} but #{implemented}" .. [["; 1.69 var rateSuggestionDegreeTexts = { 1.70 "-2": "]] .. _"must not" .. [[", 1.71 "-1": "]] .. _"should not" .. [[", 1.72 "1": "]] .. _"should" .. [[", 1.73 "2": "]] .. _"must" .. [[" 1.74 } 1.75 - var rateSuggestionAndText = "]] .. _"and" .. [["; 1.76 - var rateSuggestionButText = "]] .. _"but" .. [["; 1.77 var rateSuggestionFulfilledText = "]] .. _"is implemented" .. [["; 1.78 var rateSuggestionNotFulfilledText = "]] .. _"is not implemented" .. [["; 1.79 window.addEventListener("load", function() {