liquid_feedback_frontend
diff app/main/initiative/_list_element.lua @ 1309:32cc544d5a5b
Cumulative patch for upcoming frontend version 4
author | bsw/jbe |
---|---|
date | Sun Jul 15 14:07:29 2018 +0200 (2018-07-15) |
parents | 7e48d429389f |
children | 97dfef4eb2d7 |
line diff
1.1 --- a/app/main/initiative/_list_element.lua Thu Jun 23 03:30:57 2016 +0200 1.2 +++ b/app/main/initiative/_list_element.lua Sun Jul 15 14:07:29 2018 +0200 1.3 @@ -1,14 +1,28 @@ 1.4 local initiative = param.get("initiative", "table") 1.5 local for_event = param.get("for_event", atom.boolean) 1.6 +local for_member = param.get("for_member", "table") 1.7 1.8 local issue = initiative.issue 1.9 1.10 -local class = "initiative" 1.11 +if initiative.vote_grade ~= nil then 1.12 + if initiative.vote_grade > 0 then 1.13 + local text = _"voted yes" 1.14 + ui.container{ attr = { class = "mdl-list__item-avatar positive" }, content = function() 1.15 + ui.tag{ tag = "i", attr = { class = "material-icons", title = text }, content = "thumb_up" } 1.16 + end } 1.17 + elseif initiative.vote_grade == 0 then 1.18 + elseif initiative.vote_grade < 0 then 1.19 + local text = _"voted no" 1.20 + ui.container{ attr = { class = "mdl-list__item-avatar negative" }, content = function() 1.21 + ui.tag{ tag = "i", attr = { class = "material-icons", title = text }, content = "thumb_down" } 1.22 + end } 1.23 + end 1.24 +end 1.25 1.26 +local class = "initiative mdl-list__item-primary-content" 1.27 if initiative.rank == 1 then 1.28 class = class .. " rank1" 1.29 end 1.30 - 1.31 if initiative.revoked then 1.32 class = class .. " revoked" 1.33 end 1.34 @@ -16,88 +30,112 @@ 1.35 ui.container{ 1.36 attr = { class = class }, 1.37 content = function () 1.38 - if initiative.rank ~= 1 and not for_event then 1.39 - execute.view { 1.40 - module = "initiative", view = "_bargraph", params = { 1.41 - initiative = initiative, 1.42 - battled_initiative = issue.initiatives[1] 1.43 - } 1.44 - } 1.45 - slot.put(" ") 1.46 - end 1.47 - ui.tag { 1.48 + ui.container { 1.49 attr = { class = "initiative_name" }, 1.50 content = function() 1.51 + if not for_member and app.session.member then 1.52 + if initiative.member_info.supported then 1.53 + if initiative.member_info.satisfied then 1.54 + ui.tag{ tag = "i", attr = { id = "lf-initiative__support-" .. initiative.id, class = "material-icons material-icons-small" }, content = "thumb_up" } 1.55 + --ui.container { attr = { class = "mdl-tooltip", ["for"] = "lf-initiative__support-" .. initiative.id }, content = _"You are supporter of this initiative" } 1.56 + else 1.57 + ui.tag{ tag = "i", attr = { id = "lf-initiative__support-" .. initiative.id, class = "material-icons material-icons-small mdl-color-text--orange-500" }, content = "thumb_up" } 1.58 + --ui.container { attr = { class = "mdl-tooltip", ["for"] = "lf-initiative__support-" .. initiative.id }, content = _"supporter with restricting suggestions" } 1.59 + end 1.60 + slot.put(" ") 1.61 + end 1.62 + end 1.63 ui.link { 1.64 text = initiative.display_name, 1.65 module = "initiative", view = "show", id = initiative.id 1.66 } 1.67 - slot.put(" ") 1.68 - if initiative.vote_grade ~= nil then 1.69 - if initiative.vote_grade > 0 then 1.70 - local text = _"voted yes" 1.71 - ui.image { attr = { class = "icon16", title = text, alt = text }, static = "icons/32/support_satisfied.png" } 1.72 - elseif initiative.vote_grade == 0 then 1.73 - elseif initiative.vote_grade < 0 then 1.74 - local text = _"voted no" 1.75 - ui.image { attr = { class = "icon16", title = text, alt = text }, static = "icons/32/voted_no.png" } 1.76 + end 1.77 + } 1.78 + ui.container{ attr = { class = "mdl-list__item-text-body" }, content = function() 1.79 + local draft_content = initiative.current_draft.content 1.80 + if config.initiative_abstract then 1.81 + local abstract = string.match(draft_content, "(.+)<!%--END_OF_ABSTRACT%-->") 1.82 + if abstract then 1.83 + slot.put(abstract) 1.84 + end 1.85 + end 1.86 + if not config.voting_only then 1.87 + if app.session:has_access("authors_pseudonymous") then 1.88 + local initiator_members = initiative:get_reference_selector("initiating_members") 1.89 + :add_field("initiator.accepted", "accepted") 1.90 + :add_order_by("member.name") 1.91 + :add_where("initiator.accepted") 1.92 + :exec() 1.93 + 1.94 + local initiators = {} 1.95 + for i, member in ipairs(initiator_members) do 1.96 + if member.accepted then 1.97 + initiators[#initiators+1] = member.name 1.98 + end 1.99 end 1.100 - elseif app.session.member then 1.101 - if initiative.member_info.supported then 1.102 - if initiative.member_info.satisfied then 1.103 - local text = _"supporter" 1.104 - ui.image { attr = { class = "icon16", title = text, alt = text }, static = "icons/32/support_satisfied.png" } 1.105 - else 1.106 - local text = _"supporter with restricting suggestions" 1.107 - ui.image { attr = { class = "icon16", title = text, alt = text }, static = "icons/32/support_unsatisfied.png" } 1.108 - end 1.109 - end 1.110 + ui.tag{ content = _"by" } 1.111 + slot.put(" ") 1.112 + ui.tag{ content = table.concat(initiators, ", ") } 1.113 + slot.put("<br />") 1.114 end 1.115 end 1.116 - } 1.117 + if initiative.rank ~= 1 and (issue.voter_count == nil or issue.voter_count > 0) and not for_event then 1.118 + if not config.voting_only or issue.closed then 1.119 + execute.view { 1.120 + module = "initiative", view = "_bargraph", params = { 1.121 + initiative = initiative, 1.122 + battled_initiative = issue.initiatives[1] 1.123 + } 1.124 + } 1.125 + 1.126 + slot.put(" ") 1.127 + 1.128 + ui.supporter_count(initiative) 1.129 + end 1.130 + end 1.131 + 1.132 + if initiative.positive_votes ~= nil then 1.133 + 1.134 + local result_text 1.135 + 1.136 + if issue.voter_count == 0 then 1.137 + result_text = _("No votes (0)", { result = result }) 1.138 + 1.139 + elseif initiative.rank == 1 and not for_event then 1.140 + local result = "" 1.141 + if initiative.eligible then 1.142 + result = _("Reached #{sign}#{num}/#{den}", { 1.143 + sign = issue.policy.direct_majority_strict and ">" or "≥", 1.144 + num = issue.policy.direct_majority_num, 1.145 + den = issue.policy.direct_majority_den 1.146 + }) 1.147 + else 1.148 + result = _("Failed #{sign}#{num}/#{den}", { 1.149 + sign = issue.policy.direct_majority_strict and ">" or "≥", 1.150 + num = issue.policy.direct_majority_num, 1.151 + den = issue.policy.direct_majority_den 1.152 + }) 1.153 + end 1.154 + local neutral_count = issue.voter_count - initiative.positive_votes - initiative.negative_votes 1.155 + 1.156 + result_text = _("#{result}: #{yes_count} Yes (#{yes_percent}), #{no_count} No (#{no_percent}), #{neutral_count} Abstention (#{neutral_percent})", { 1.157 + result = result, 1.158 + yes_count = initiative.positive_votes, 1.159 + yes_percent = format.percent_floor(initiative.positive_votes, issue.voter_count), 1.160 + neutral_count = neutral_count, 1.161 + neutral_percent = format.percent_floor(neutral_count, issue.voter_count), 1.162 + no_count = initiative.negative_votes, 1.163 + no_percent = format.percent_floor(initiative.negative_votes, issue.voter_count) 1.164 + }) 1.165 + 1.166 + end 1.167 + 1.168 + ui.container { attr = { class = "result" }, content = result_text } 1.169 + 1.170 + end 1.171 + 1.172 + end } 1.173 1.174 end 1.175 } 1.176 1.177 -if initiative.rank == 1 1.178 - and issue.voter_count 1.179 - and initiative.positive_votes ~= nil 1.180 - and initiative.negative_votes ~= nil 1.181 - and not for_event 1.182 -then 1.183 - local result = "" 1.184 - if initiative.eligible then 1.185 - result = _("Reached #{sign}#{num}/#{den}", { 1.186 - sign = issue.policy.direct_majority_strict and ">" or "≥", 1.187 - num = issue.policy.direct_majority_num, 1.188 - den = issue.policy.direct_majority_den 1.189 - }) 1.190 - else 1.191 - result = _("Failed #{sign}#{num}/#{den}", { 1.192 - sign = issue.policy.direct_majority_strict and ">" or "≥", 1.193 - num = issue.policy.direct_majority_num, 1.194 - den = issue.policy.direct_majority_den 1.195 - }) 1.196 - end 1.197 - local neutral_count = issue.voter_count - initiative.positive_votes - initiative.negative_votes 1.198 - 1.199 - local result_text 1.200 - 1.201 - if issue.voter_count > 0 then 1.202 - result_text = _("#{result}: #{yes_count} Yes (#{yes_percent}), #{no_count} No (#{no_percent}), #{neutral_count} Abstention (#{neutral_percent})", { 1.203 - result = result, 1.204 - yes_count = initiative.positive_votes, 1.205 - yes_percent = format.percent_floor(initiative.positive_votes, issue.voter_count), 1.206 - neutral_count = neutral_count, 1.207 - neutral_percent = format.percent_floor(neutral_count, issue.voter_count), 1.208 - no_count = initiative.negative_votes, 1.209 - no_percent = format.percent_floor(initiative.negative_votes, issue.voter_count) 1.210 - }) 1.211 - else 1.212 - result_text = _("#{result}: No votes (0)", { result = result }) 1.213 - end 1.214 - 1.215 - ui.container { attr = { class = "result" }, content = result_text } 1.216 - 1.217 -end 1.218 -