liquid_feedback_frontend
changeset 1724:c33916811ca7
Added new suggestions button on top of suggestion list
author | bsw |
---|---|
date | Tue Sep 28 09:29:34 2021 +0200 (2021-09-28) |
parents | 0b43b2485930 |
children | 4a5a79a37db1 |
files | app/main/initiative/_suggestions.lua |
line diff
1.1 --- a/app/main/initiative/_suggestions.lua Tue Sep 28 09:16:01 2021 +0200 1.2 +++ b/app/main/initiative/_suggestions.lua Tue Sep 28 09:29:34 2021 +0200 1.3 @@ -133,214 +133,226 @@ 1.4 attr = { class = "section suggestions" }, 1.5 content = function () 1.6 1.7 - if # ( initiative.suggestions ) > 0 then 1.8 - 1.9 - ui.heading { 1.10 - level = 1, 1.11 - content = _("Suggestions for improvement (#{count})", { count = # ( initiative.suggestions ) } ) 1.12 + ui.heading { 1.13 + level = 1, 1.14 + content = _("Suggestions for improvement (#{count})", { count = # ( initiative.suggestions ) } ) 1.15 + } 1.16 + 1.17 + ui.container { content = _"written and rated by the supportes of this initiative to improve the proposal and its reasons" } 1.18 + 1.19 + if initiative.member_info.supported and not active_trustee_id then 1.20 + ui.link { 1.21 + attr = { 1.22 + style = "margin-top: 1ex;", 1.23 + class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored", 1.24 + }, 1.25 + module = "suggestion", view = "new", params = { 1.26 + initiative_id = initiative.id 1.27 + }, 1.28 + content = _"write a new suggestion" 1.29 } 1.30 - ui.container { content = _"written and rated by the supportes of this initiative to improve the proposal and its reasons" } 1.31 - slot.put("<br />") 1.32 - 1.33 - for i, suggestion in ipairs(initiative.suggestions) do 1.34 - 1.35 - local opinion = Opinion:by_pk(app.session.member_id, suggestion.id) 1.36 + end 1.37 + 1.38 + slot.put("<br /><br />") 1.39 + 1.40 + for i, suggestion in ipairs(initiative.suggestions) do 1.41 + 1.42 + local opinion = Opinion:by_pk(app.session.member_id, suggestion.id) 1.43 1.44 - local class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp not-folded" 1.45 - if suggestion.id == param.get("suggestion_id", atom.number) then 1.46 - class = class .. " highlighted" 1.47 - end 1.48 - if member and not initiative.issue.fully_frozen and not initiative.issue.closed and initiative.member_info.supported then 1.49 - class = class .. " rateable" 1.50 - end 1.51 + local class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp not-folded" 1.52 + if suggestion.id == param.get("suggestion_id", atom.number) then 1.53 + class = class .. " highlighted" 1.54 + end 1.55 + if member and not initiative.issue.fully_frozen and not initiative.issue.closed and initiative.member_info.supported then 1.56 + class = class .. " rateable" 1.57 + end 1.58 + 1.59 + ui.link { attr = { name = "s" .. suggestion.id }, text = "" } 1.60 + ui.tag { tag = "div", attr = { class = class, id = "s" .. suggestion.id }, content = function () 1.61 + ui.tag{ attr = { class = "mdl-card__title mdl-card--border" }, content = function() 1.62 + ui.heading { level = 2, 1.63 + attr = { class = "mdl-card__title-text" }, 1.64 + content = function() 1.65 + ui.tag{ content = format.string(suggestion.name, { 1.66 + truncate_at = 160, truncate_suffix = true }) 1.67 + } 1.68 + end 1.69 + } 1.70 + end } 1.71 + 1.72 + 1.73 + 1.74 + ui.container{ attr = { class = "suggestion-content" }, content = function() 1.75 1.76 - ui.link { attr = { name = "s" .. suggestion.id }, text = "" } 1.77 - ui.tag { tag = "div", attr = { class = class, id = "s" .. suggestion.id }, content = function () 1.78 - ui.tag{ attr = { class = "mdl-card__title mdl-card--border" }, content = function() 1.79 - ui.heading { level = 2, 1.80 - attr = { class = "mdl-card__title-text" }, 1.81 - content = function() 1.82 - ui.tag{ content = format.string(suggestion.name, { 1.83 - truncate_at = 160, truncate_suffix = true }) 1.84 + ui.container { 1.85 + attr = { class = "mdl-card__content mdl-card--border suggestionInfo" }, 1.86 + content = function () 1.87 + 1.88 + if app.session:has_access("authors_pseudonymous") then 1.89 + ui.tag{ content = _"by" } 1.90 + slot.put(" ") 1.91 + ui.link{ 1.92 + module = "member", view = "show", id = suggestion.author_id, 1.93 + content = suggestion.author.name 1.94 } 1.95 end 1.96 - } 1.97 - end } 1.98 + 1.99 + execute.view{ 1.100 + module = "suggestion", view = "_collective_rating", params = { 1.101 + suggestion = suggestion 1.102 + } 1.103 + } 1.104 1.105 - 1.106 - 1.107 - ui.container{ attr = { class = "suggestion-content" }, content = function() 1.108 - 1.109 - ui.container { 1.110 - attr = { class = "mdl-card__content mdl-card--border suggestionInfo" }, 1.111 - content = function () 1.112 + end 1.113 + } 1.114 1.115 - if app.session:has_access("authors_pseudonymous") then 1.116 - ui.tag{ content = _"by" } 1.117 - slot.put(" ") 1.118 - ui.link{ 1.119 - module = "member", view = "show", id = suggestion.author_id, 1.120 - content = suggestion.author.name 1.121 - } 1.122 - end 1.123 - 1.124 - execute.view{ 1.125 - module = "suggestion", view = "_collective_rating", params = { 1.126 - suggestion = suggestion 1.127 - } 1.128 + ui.container { 1.129 + attr = { class = "mdl-card__content suggestion-text draft" }, 1.130 + content = function () 1.131 + slot.put ( suggestion:get_content( "html" ) ) 1.132 + 1.133 + ui.container { attr = { class = "floatx-right" }, content = function() 1.134 + 1.135 + ui.link { 1.136 + attr = { 1.137 + class = "mdl-button mdl-js-button mdl-button--icon suggestion-more", 1.138 + onclick = "document.querySelector('#s" .. suggestion.id .. "').classList.remove('folded');document.querySelector('#s" .. suggestion.id .. "').classList.add('unfolded'); return false;" 1.139 + }, 1.140 + content = function() 1.141 + ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "expand_more" } 1.142 + end 1.143 } 1.144 - 1.145 - end 1.146 - } 1.147 1.148 - ui.container { 1.149 - attr = { class = "mdl-card__content suggestion-text draft" }, 1.150 - content = function () 1.151 - slot.put ( suggestion:get_content( "html" ) ) 1.152 + ui.link { 1.153 + attr = { 1.154 + class = "mdl-button mdl-js-button mdl-button--icon suggestion-less", 1.155 + onclick = "document.querySelector('#s" .. suggestion.id .. "').classList.add('folded');document.querySelector('#s" .. suggestion.id .. "').classList.remove('unfolded'); return false;" 1.156 + }, 1.157 + content = function() 1.158 + ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "expand_less" } 1.159 + end 1.160 + } 1.161 + --[[ 1.162 + ui.link{ 1.163 + attr = { class = "mdl-button" }, 1.164 + content = _"Details", 1.165 + module = "suggestion", view = "show", id = suggestion.id 1.166 + } 1.167 + --]] 1.168 + end } 1.169 + 1.170 + end 1.171 + } 1.172 + 1.173 + end } 1.174 + 1.175 + ui.container { attr = { class = "mdl-card__actions mdl-card--border" }, content = function() 1.176 1.177 - ui.container { attr = { class = "floatx-right" }, content = function() 1.178 - 1.179 - ui.link { 1.180 - attr = { 1.181 - class = "mdl-button mdl-js-button mdl-button--icon suggestion-more", 1.182 - onclick = "document.querySelector('#s" .. suggestion.id .. "').classList.remove('folded');document.querySelector('#s" .. suggestion.id .. "').classList.add('unfolded'); return false;" 1.183 - }, 1.184 - content = function() 1.185 - ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "expand_more" } 1.186 - end 1.187 - } 1.188 - 1.189 - ui.link { 1.190 - attr = { 1.191 - class = "mdl-button mdl-js-button mdl-button--icon suggestion-less", 1.192 - onclick = "document.querySelector('#s" .. suggestion.id .. "').classList.add('folded');document.querySelector('#s" .. suggestion.id .. "').classList.remove('unfolded'); return false;" 1.193 - }, 1.194 - content = function() 1.195 - ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "expand_less" } 1.196 - end 1.197 - } 1.198 - --[[ 1.199 - ui.link{ 1.200 - attr = { class = "mdl-button" }, 1.201 - content = _"Details", 1.202 - module = "suggestion", view = "show", id = suggestion.id 1.203 - } 1.204 - --]] 1.205 - end } 1.206 - 1.207 + if direct_supporter then 1.208 + ui.container{ attr = { class = "suggestion_rating_info" }, content = function() 1.209 + ui.tag{ attr = { id = "s" .. suggestion.id .. "_rating_text" }, content = function() 1.210 + local text = "" 1.211 + if opinion then 1.212 + if opinion.degree == 2 then 1.213 + text = _"must" 1.214 + elseif opinion.degree == 1 then 1.215 + text = _"should" 1.216 + elseif opinion.degree == 0 then 1.217 + text = _"neutral" 1.218 + elseif opinion.degree == -1 then 1.219 + text = _"should not" 1.220 + elseif opinion.degree == -2 then 1.221 + text = _"must not" 1.222 + end 1.223 + ui.tag { content = text } 1.224 + slot.put ( " " ) 1.225 + if 1.226 + (opinion.degree > 0 and not opinion.fulfilled) 1.227 + or (opinion.degree < 0 and opinion.fulfilled) 1.228 + then 1.229 + ui.tag{ content = _"but" } 1.230 + else 1.231 + ui.tag{ content = _"and" } 1.232 + end 1.233 + slot.put ( " " ) 1.234 + local text = "" 1.235 + if opinion.fulfilled then 1.236 + text = _"is implemented" 1.237 + else 1.238 + text = _"is not implemented" 1.239 + end 1.240 + ui.tag { content = text } 1.241 + end 1.242 + end } 1.243 + local id = "s" .. suggestion.id .. "_rating_icon" 1.244 + if opinion and ( 1.245 + (opinion.degree > 0 and not opinion.fulfilled) 1.246 + or (opinion.degree < 0 and opinion.fulfilled) 1.247 + ) 1.248 + then 1.249 + slot.put(" ") 1.250 + if math.abs(opinion.degree) > 1 then 1.251 + ui.icon("warning", "red", id) 1.252 + else 1.253 + ui.icon("warning", nil, id) 1.254 + end 1.255 + elseif opinion then 1.256 + slot.put(" ") 1.257 + ui.icon("done", nil, id) 1.258 + else 1.259 + slot.put(" ") 1.260 + ui.icon("blank", nil, id) 1.261 + end 1.262 + end } 1.263 + 1.264 + ui.link{ 1.265 + attr = { 1.266 + id = "s" .. suggestion.id .. "_rate_button", 1.267 + class = "mdl-button", 1.268 + onclick = "rateSuggestion(" .. suggestion.id .. ", " .. (opinion and opinion.degree or 0) .. ", " .. (opinion and (opinion.fulfilled and "true" or "false") or "null") .. ");return false;" 1.269 + }, 1.270 + content = function() 1.271 + if opinion then 1.272 + ui.tag { content = _"update rating" } 1.273 + else 1.274 + ui.tag { content = _"rate suggestion" } 1.275 + end 1.276 end 1.277 } 1.278 - 1.279 - end } 1.280 - 1.281 - ui.container { attr = { class = "mdl-card__actions mdl-card--border" }, content = function() 1.282 + end 1.283 + 1.284 + ui.link{ 1.285 + attr = { class = "mdl-button" }, 1.286 + content = _"Details", 1.287 + module = "suggestion", view = "show", id = suggestion.id 1.288 + } 1.289 1.290 - if direct_supporter then 1.291 - ui.container{ attr = { class = "suggestion_rating_info" }, content = function() 1.292 - ui.tag{ attr = { id = "s" .. suggestion.id .. "_rating_text" }, content = function() 1.293 - local text = "" 1.294 - if opinion then 1.295 - if opinion.degree == 2 then 1.296 - text = _"must" 1.297 - elseif opinion.degree == 1 then 1.298 - text = _"should" 1.299 - elseif opinion.degree == 0 then 1.300 - text = _"neutral" 1.301 - elseif opinion.degree == -1 then 1.302 - text = _"should not" 1.303 - elseif opinion.degree == -2 then 1.304 - text = _"must not" 1.305 - end 1.306 - ui.tag { content = text } 1.307 - slot.put ( " " ) 1.308 - if 1.309 - (opinion.degree > 0 and not opinion.fulfilled) 1.310 - or (opinion.degree < 0 and opinion.fulfilled) 1.311 - then 1.312 - ui.tag{ content = _"but" } 1.313 - else 1.314 - ui.tag{ content = _"and" } 1.315 - end 1.316 - slot.put ( " " ) 1.317 - local text = "" 1.318 - if opinion.fulfilled then 1.319 - text = _"is implemented" 1.320 - else 1.321 - text = _"is not implemented" 1.322 - end 1.323 - ui.tag { content = text } 1.324 - end 1.325 - end } 1.326 - local id = "s" .. suggestion.id .. "_rating_icon" 1.327 - if opinion and ( 1.328 - (opinion.degree > 0 and not opinion.fulfilled) 1.329 - or (opinion.degree < 0 and opinion.fulfilled) 1.330 - ) 1.331 - then 1.332 - slot.put(" ") 1.333 - if math.abs(opinion.degree) > 1 then 1.334 - ui.icon("warning", "red", id) 1.335 - else 1.336 - ui.icon("warning", nil, id) 1.337 - end 1.338 - elseif opinion then 1.339 - slot.put(" ") 1.340 - ui.icon("done", nil, id) 1.341 - else 1.342 - slot.put(" ") 1.343 - ui.icon("blank", nil, id) 1.344 - end 1.345 - end } 1.346 - 1.347 - ui.link{ 1.348 - attr = { 1.349 - id = "s" .. suggestion.id .. "_rate_button", 1.350 - class = "mdl-button", 1.351 - onclick = "rateSuggestion(" .. suggestion.id .. ", " .. (opinion and opinion.degree or 0) .. ", " .. (opinion and (opinion.fulfilled and "true" or "false") or "null") .. ");return false;" 1.352 - }, 1.353 - content = function() 1.354 - if opinion then 1.355 - ui.tag { content = _"update rating" } 1.356 - else 1.357 - ui.tag { content = _"rate suggestion" } 1.358 - end 1.359 - end 1.360 - } 1.361 - end 1.362 - 1.363 - ui.link{ 1.364 - attr = { class = "mdl-button" }, 1.365 - content = _"Details", 1.366 - module = "suggestion", view = "show", id = suggestion.id 1.367 + end } 1.368 + ui.script{ script = [[ 1.369 + var rateSuggestionRateText = "]] .. _"rate suggestion" .. [["; 1.370 + var rateSuggestionUpdateRatingText = "]] .. _"update rating" .. [["; 1.371 + var rateSuggestionDegreeTexts = { 1.372 + "-2": "]] .. _"must not" .. [[", 1.373 + "-1": "]] .. _"should not" .. [[", 1.374 + "1": "]] .. _"should" .. [[", 1.375 + "2": "]] .. _"must" .. [[" 1.376 + } 1.377 + var rateSuggestionAndText = "]] .. _"and" .. [["; 1.378 + var rateSuggestionButText = "]] .. _"but" .. [["; 1.379 + var rateSuggestionFulfilledText = "]] .. _"is implemented" .. [["; 1.380 + var rateSuggestionNotFulfilledText = "]] .. _"is not implemented" .. [["; 1.381 + window.addEventListener("load", function() { 1.382 + var textEl = document.querySelector('#s]] .. suggestion.id .. [[ .suggestion-content'); 1.383 + var height = textEl.clientHeight; 1.384 + if (height > 250) { 1.385 + document.querySelector('#s]] .. suggestion.id .. [[').classList.add('folded'); 1.386 } 1.387 + }); 1.388 + ]] } 1.389 + 1.390 + end } 1.391 1.392 - end } 1.393 - ui.script{ script = [[ 1.394 - var rateSuggestionRateText = "]] .. _"rate suggestion" .. [["; 1.395 - var rateSuggestionUpdateRatingText = "]] .. _"update rating" .. [["; 1.396 - var rateSuggestionDegreeTexts = { 1.397 - "-2": "]] .. _"must not" .. [[", 1.398 - "-1": "]] .. _"should not" .. [[", 1.399 - "1": "]] .. _"should" .. [[", 1.400 - "2": "]] .. _"must" .. [[" 1.401 - } 1.402 - var rateSuggestionAndText = "]] .. _"and" .. [["; 1.403 - var rateSuggestionButText = "]] .. _"but" .. [["; 1.404 - var rateSuggestionFulfilledText = "]] .. _"is implemented" .. [["; 1.405 - var rateSuggestionNotFulfilledText = "]] .. _"is not implemented" .. [["; 1.406 - window.addEventListener("load", function() { 1.407 - var textEl = document.querySelector('#s]] .. suggestion.id .. [[ .suggestion-content'); 1.408 - var height = textEl.clientHeight; 1.409 - if (height > 250) { 1.410 - document.querySelector('#s]] .. suggestion.id .. [[').classList.add('folded'); 1.411 - } 1.412 - }); 1.413 - ]] } 1.414 - 1.415 - end } 1.416 - 1.417 - end -- for i, suggestion 1.418 - 1.419 - end -- if #initiative.suggestions > 0 1.420 + end -- for i, suggestion 1.421 + 1.422 end 1.423 }