liquid_feedback_frontend
diff app/main/initiative/_head.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 | c02aea493bc1 |
children | c08690678b2d |
line diff
1.1 --- a/app/main/initiative/_head.lua Thu Jun 23 03:30:57 2016 +0200 1.2 +++ b/app/main/initiative/_head.lua Sun Jul 15 14:07:29 2018 +0200 1.3 @@ -19,180 +19,166 @@ 1.4 local initiators = initiators_members_selector:exec() 1.5 1.6 1.7 -ui.sectionHead( "initiativeInfo", function () 1.8 +ui.container{ attr = { class = "mdl-card__title mdl-card--has-fab mdl-card--border" }, content = function () 1.9 + 1.10 + ui.heading { 1.11 + attr = { class = "mdl-card__title-text" }, 1.12 + level = 2, 1.13 + content = function() 1.14 + ui.tag{ content = initiative.display_name } 1.15 + end 1.16 + } 1.17 1.18 - ui.heading { 1.19 - level = 1, 1.20 - content = initiative.display_name 1.21 - } 1.22 - 1.23 - ui.container { attr = { class = "support" }, content = function () 1.24 - if initiative.supporter_count == nil then 1.25 - ui.tag { 1.26 - attr = { class = "supporterCount" }, 1.27 - content = _"[calculating]" 1.28 + if app.session.member and app.session.member:has_voting_right_for_unit_id(initiative.issue.area.unit_id) then 1.29 + if not initiative.issue.closed and not initiative.member_info.supported then 1.30 + if not initiative.issue.fully_frozen then 1.31 + ui.link { 1.32 + attr = { class = "mdl-button mdl-js-button mdl-button--fab mdl-button--colored" , 1.33 + style = "position: absolute; right: 20px; bottom: -27px;" 1.34 + }, 1.35 + module = "initiative", action = "add_support", 1.36 + routing = { default = { 1.37 + mode = "redirect", module = "initiative", view = "show", id = initiative.id 1.38 + } }, 1.39 + id = initiative.id, 1.40 + content = function() 1.41 + ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "thumb_up" } 1.42 + end 1.43 } 1.44 - elseif initiative.issue.closed == nil then 1.45 - ui.tag { 1.46 - attr = { class = "satisfiedSupporterCount" }, 1.47 - content = _("#{count} supporter", { count = initiative.satisfied_supporter_count }) 1.48 - } 1.49 - if initiative.potential_supporter_count and 1.50 - initiative.potential_supporter_count > 0 1.51 - then 1.52 - slot.put ( " " ) 1.53 - ui.tag { 1.54 - attr = { class = "potentialSupporterCount" }, 1.55 - content = _("(+ #{count} potential)", { count = initiative.potential_supporter_count }) 1.56 + end 1.57 + end 1.58 + if initiative.issue.fully_frozen and not initiative.issue.closed and not initiative.issue.member_info.direct_voted then 1.59 + ui.link { 1.60 + attr = { class = "mdl-button mdl-js-button mdl-button--fab mdl-button--colored" , 1.61 + style = "position: absolute; right: 20px; bottom: -27px;" 1.62 + }, 1.63 + module = "vote", view = "list", 1.64 + params = { issue_id = initiative.issue_id }, 1.65 + content = function() 1.66 + ui.tag{ tag = "i", attr = { class = "material-icons" }, content = config.voting_icon or "mail_outline" } 1.67 + end 1.68 + } 1.69 + end 1.70 + end 1.71 +end } 1.72 + 1.73 +ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function () 1.74 + 1.75 + if not config.voting_only and app.session:has_access("authors_pseudonymous") then 1.76 + for i, member in ipairs(initiators) do 1.77 + if i > 1 then 1.78 + slot.put(" ") 1.79 + end 1.80 + util.micro_avatar( member ) 1.81 + end -- for i, member 1.82 + end 1.83 + 1.84 + if member then 1.85 + ui.container { attr = { class = "mySupport float-right right" }, content = function () 1.86 + if initiative.issue.fully_frozen then 1.87 + slot.put("<br />") 1.88 + if initiative.issue.member_info.direct_voted then 1.89 + ui.tag { content = _"You have voted" } 1.90 + slot.put("<br />") 1.91 + if not initiative.issue.closed then 1.92 + ui.link { 1.93 + module = "vote", view = "list", 1.94 + params = { issue_id = initiative.issue.id }, 1.95 + text = _"change vote" 1.96 + } 1.97 + else 1.98 + ui.link { 1.99 + module = "vote", view = "list", 1.100 + params = { issue_id = initiative.issue.id }, 1.101 + text = _"show vote" 1.102 + } 1.103 + end 1.104 + slot.put(" ") 1.105 + elseif active_trustee_id then 1.106 + ui.tag { content = _"You have voted via delegation" } 1.107 + ui.link { 1.108 + content = _"Show voting ballot", 1.109 + module = "vote", view = "list", params = { 1.110 + issue_id = initiative.issue.id, member_id = active_trustee_id 1.111 + } 1.112 + } 1.113 + elseif not initiative.issue.closed then 1.114 + ui.link { 1.115 + attr = { class = "btn btn-default" }, 1.116 + module = "vote", view = "list", 1.117 + params = { issue_id = initiative.issue.id }, 1.118 + text = _"vote now" 1.119 } 1.120 end 1.121 - 1.122 - end 1.123 - 1.124 - slot.put ( "<br />" ) 1.125 - 1.126 + elseif initiative.member_info.supported then 1.127 + ui.container{ content = function() 1.128 + ui.tag{ content = _"You are supporter" } 1.129 + slot.put(" ") 1.130 + if initiative.member_info.satisfied then 1.131 + ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "thumb_up" } 1.132 + else 1.133 + ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "thumb_up" } 1.134 + end 1.135 + end } 1.136 + if initiative.issue.member_info.own_participation then 1.137 + ui.link { 1.138 + attr = { class = "btn-link" }, 1.139 + module = "initiative", action = "remove_support", 1.140 + routing = { default = { 1.141 + mode = "redirect", module = "initiative", view = "show", id = initiative.id 1.142 + } }, 1.143 + id = initiative.id, 1.144 + text = _"remove my support" 1.145 + } 1.146 + 1.147 + else 1.148 + 1.149 + ui.link { 1.150 + module = "delegation", view = "show", params = { 1.151 + issue_id = initiative.issue_id, 1.152 + initiative_id = initiative.id 1.153 + }, 1.154 + content = _"via delegation" 1.155 + } 1.156 + 1.157 + end 1.158 + 1.159 + slot.put(" ") 1.160 + 1.161 + end 1.162 + end } 1.163 + 1.164 + end 1.165 + 1.166 + if config.initiative_abstract then 1.167 + local abstract = string.match(initiative.current_draft.content, "(.+)<!%--END_OF_ABSTRACT%-->") 1.168 + if abstract then 1.169 + ui.container{ 1.170 + attr = { class = "abstract", style = "padding-right: 140px;" }, 1.171 + content = function() slot.put(abstract) end 1.172 + } 1.173 + end 1.174 + end 1.175 + 1.176 + ui.container { attr = { class = "support" }, content = function () 1.177 + 1.178 + if not config.voting_only then 1.179 execute.view { 1.180 module = "initiative", view = "_bargraph", params = { 1.181 initiative = initiative 1.182 } 1.183 } 1.184 - end } 1.185 - 1.186 - if member then 1.187 - ui.container { attr = { class = "mySupport right" }, content = function () 1.188 - if initiative.issue.fully_frozen then 1.189 - if initiative.issue.member_info.direct_voted then 1.190 - --ui.image { attr = { class = "icon48 right" }, static = "icons/48/voted_ok.png" } 1.191 - ui.tag { content = _"You have voted" } 1.192 - slot.put("<br />") 1.193 - if not initiative.issue.closed then 1.194 - ui.link { 1.195 - module = "vote", view = "list", 1.196 - params = { issue_id = initiative.issue.id }, 1.197 - text = _"change vote" 1.198 - } 1.199 - else 1.200 - ui.link { 1.201 - module = "vote", view = "list", 1.202 - params = { issue_id = initiative.issue.id }, 1.203 - text = _"show vote" 1.204 - } 1.205 - end 1.206 - slot.put(" ") 1.207 - elseif active_trustee_id then 1.208 - ui.tag { content = _"You have voted via delegation" } 1.209 - ui.link { 1.210 - content = _"Show voting ballot", 1.211 - module = "vote", view = "list", params = { 1.212 - issue_id = initiative.issue.id, member_id = active_trustee_id 1.213 - } 1.214 - } 1.215 - elseif not initiative.issue.closed then 1.216 - ui.link { 1.217 - attr = { class = "btn btn-default" }, 1.218 - module = "vote", view = "list", 1.219 - params = { issue_id = initiative.issue.id }, 1.220 - text = _"vote now" 1.221 - } 1.222 - end 1.223 - elseif initiative.member_info.supported then 1.224 - if initiative.member_info.satisfied then 1.225 - ui.image { attr = { class = "icon48 right" }, static = "icons/32/support_satisfied.png" } 1.226 - else 1.227 - ui.image { attr = { class = "icon48 right" }, static = "icons/32/support_unsatisfied.png" } 1.228 - end 1.229 - ui.container { content = _"You are supporter" } 1.230 + slot.put(" ") 1.231 1.232 - if initiative.issue.member_info.own_participation then 1.233 - ui.link { 1.234 - attr = { class = "btn-link" }, 1.235 - module = "initiative", action = "remove_support", 1.236 - routing = { default = { 1.237 - mode = "redirect", module = "initiative", view = "show", id = initiative.id 1.238 - } }, 1.239 - id = initiative.id, 1.240 - text = _"remove my support" 1.241 - } 1.242 - 1.243 - else 1.244 - 1.245 - ui.link { 1.246 - module = "delegation", view = "show", params = { 1.247 - issue_id = initiative.issue_id, 1.248 - initiative_id = initiative.id 1.249 - }, 1.250 - content = _"via delegation" 1.251 - } 1.252 - 1.253 - end 1.254 - 1.255 - slot.put(" ") 1.256 - 1.257 - 1.258 - elseif not initiative.issue.closed then 1.259 - ui.link { 1.260 - attr = { class = "btn btn-default" }, 1.261 - module = "initiative", action = "add_support", 1.262 - routing = { default = { 1.263 - mode = "redirect", module = "initiative", view = "show", id = initiative.id 1.264 - } }, 1.265 - id = initiative.id, 1.266 - text = _"add my support" 1.267 - } 1.268 - 1.269 - end 1.270 - end } 1.271 - 1.272 + ui.supporter_count(initiative) 1.273 end 1.274 1.275 - slot.put("<br style='clear: both;'/>") 1.276 - 1.277 - ui.container { 1.278 - attr = { class = "initiators" }, 1.279 - content = function () 1.280 - 1.281 - if app.session:has_access("authors_pseudonymous") then 1.282 - for i, member in ipairs(initiators) do 1.283 - if i > 1 then 1.284 - slot.put(" ") 1.285 - end 1.286 - util.micro_avatar(member) 1.287 - if member.accepted == nil then 1.288 - slot.put ( " " ) 1.289 - ui.tag { content = _"(invited)" } 1.290 - end 1.291 - end -- for i, member 1.292 - 1.293 - end 1.294 - 1.295 - end 1.296 - } -- ui.container "initiators" 1.297 + end } 1.298 + 1.299 +end } 1.300 1.301 - ui.container { 1.302 - attr = { class = "links" }, 1.303 - content = function () 1.304 - 1.305 - local drafts_count = initiative:get_reference_selector("drafts"):count() 1.306 - ui.link { 1.307 - content = _("suggestions (#{count}) ↓", { 1.308 - count = # ( initiative.suggestions ) 1.309 - }), 1.310 - external = "#suggestions" 1.311 - } 1.312 +execute.view { 1.313 + module = "initiative", view = "_sidebar_state", 1.314 + params = { initiative = initiative } 1.315 +} 1.316 1.317 - slot.put ( " | " ) 1.318 - 1.319 - ui.link{ 1.320 - module = "initiative", view = "history", id = initiative.id, 1.321 - content = _("draft history (#{count})", { count = drafts_count }) 1.322 - } 1.323 - 1.324 - end 1.325 - } -- ui.containers "links" 1.326 - end ) 1.327 - 1.328 - execute.view { 1.329 - module = "initiative", view = "_sidebar_state", 1.330 - params = { initiative = initiative } 1.331 - } 1.332 -