liquid_feedback_frontend
diff app/main/delegation/show.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 | 904f6807f7fa |
children | 8c9f7f9152ce |
line diff
1.1 --- a/app/main/delegation/show.lua Thu Jun 23 03:30:57 2016 +0200 1.2 +++ b/app/main/delegation/show.lua Sun Jul 15 14:07:29 2018 +0200 1.3 @@ -113,283 +113,303 @@ 1.4 ui.script{ static = "js/update_delegation_info.js" } 1.5 1.6 1.7 -ui.section( function () 1.8 - 1.9 - ui.sectionHead( function () 1.10 - ui.heading{ level = 1, content = head_text } 1.11 - end ) 1.12 - 1.13 - ui.sectionRow( function () 1.14 +ui.container{ attr = { class = "mdl-grid" }, content = function() 1.15 + ui.container{ attr = { class = "mdl-cell mdl-cell--8-col" }, content = function() 1.16 + ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function() 1.17 + ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function() 1.18 + ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = head_text } 1.19 + end } 1.20 + 1.21 + ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function() 1.22 + 1.23 + 1.24 + ui.form{ 1.25 + attr = { class = "wide section", id = "delegationForm" }, 1.26 + module = "delegation", 1.27 + action = "update", 1.28 + params = { 1.29 + unit_id = unit and unit.id or nil, 1.30 + area_id = area and area.id or nil, 1.31 + issue_id = issue and issue.id or nil, 1.32 + initiative_id = initiative_id 1.33 + }, 1.34 + routing = { 1.35 + default = { 1.36 + mode = "redirect", 1.37 + module = area and "area" or initiative and "initiative" or issue and "issue" or "unit", 1.38 + view = "show", 1.39 + id = area and area.id or initiative and initiative.id or issue and issue.id or unit.id, 1.40 + } 1.41 + }, 1.42 + content = function() 1.43 + local records 1.44 + if issue then 1.45 + local delegate_name = "" 1.46 + local scope = _"no delegation set" 1.47 + local area_delegation = Delegation:by_pk(app.session.member_id, nil, issue.area_id) 1.48 + if area_delegation then 1.49 + delegate_name = area_delegation.trustee and area_delegation.trustee.name or _"abandoned" 1.50 + scope = _"area" 1.51 + else 1.52 + local unit_delegation = Delegation:by_pk(app.session.member_id, issue.area.unit_id) 1.53 + if unit_delegation then 1.54 + delegate_name = unit_delegation.trustee.name 1.55 + scope = config.single_unit_id and _"global" or _"unit" 1.56 + end 1.57 + end 1.58 + local text_apply 1.59 + local text_abandon 1.60 + if config.single_unit_id then 1.61 + text_apply = _("Apply global or area delegation for this issue (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope }) 1.62 + text_abandon = _"Abandon unit and area delegations for this issue" 1.63 + else 1.64 + text_apply = _("Apply unit or area delegation for this issue (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope }) 1.65 + text_abandon = _"Abandon unit and area delegations for this issue" 1.66 + end 1.67 + 1.68 + records = { 1.69 + { id = -1, name = text_apply }, 1.70 + { id = 0, name = text_abandon } 1.71 + } 1.72 + elseif area then 1.73 + local delegate_name = "" 1.74 + local scope = _"no delegation set" 1.75 + local unit_delegation = Delegation:by_pk(app.session.member_id, area.unit_id) 1.76 + if unit_delegation then 1.77 + delegate_name = unit_delegation.trustee.name 1.78 + scope = config.single_unit_id and _"global" or _"unit" 1.79 + end 1.80 + local text_apply 1.81 + local text_abandon 1.82 + if config.single_unit_id then 1.83 + text_apply = _("Apply global delegation for this area (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope }) 1.84 + text_abandon = _"Abandon global delegation for this area" 1.85 + else 1.86 + text_apply = _("Apply unit delegation for this area (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope }) 1.87 + text_abandon = _"Abandon unit delegation for this area" 1.88 + end 1.89 + records = { 1.90 + { 1.91 + id = -1, 1.92 + name = text_apply 1.93 + }, 1.94 + { 1.95 + id = 0, 1.96 + name = text_abandon 1.97 + } 1.98 + } 1.99 + 1.100 + else 1.101 + records = { 1.102 + { 1.103 + id = -1, 1.104 + name = _"No delegation" 1.105 + } 1.106 + } 1.107 1.108 - ui.form{ 1.109 - attr = { class = "wide section", id = "delegationForm" }, 1.110 - module = "delegation", 1.111 - action = "update", 1.112 - params = { 1.113 - unit_id = unit and unit.id or nil, 1.114 - area_id = area and area.id or nil, 1.115 - issue_id = issue and issue.id or nil, 1.116 - initiative_id = initiative_id 1.117 - }, 1.118 - routing = { 1.119 - default = { 1.120 - mode = "redirect", 1.121 - module = area and "area" or initiative and "initiative" or issue and "issue" or "unit", 1.122 - view = "show", 1.123 - id = area and area.id or initiative and initiative.id or issue and issue.id or unit.id, 1.124 - } 1.125 - }, 1.126 - content = function() 1.127 - local records 1.128 - if issue then 1.129 - local delegate_name = "" 1.130 - local scope = _"no delegation set" 1.131 - local area_delegation = Delegation:by_pk(app.session.member_id, nil, issue.area_id) 1.132 - if area_delegation then 1.133 - delegate_name = area_delegation.trustee and area_delegation.trustee.name or _"abandoned" 1.134 - scope = _"area" 1.135 - else 1.136 - local unit_delegation = Delegation:by_pk(app.session.member_id, issue.area.unit_id) 1.137 - if unit_delegation then 1.138 - delegate_name = unit_delegation.trustee.name 1.139 - scope = config.single_unit_id and _"global" or _"unit" 1.140 + end 1.141 + -- add current trustee 1.142 + if current_trustee_id then 1.143 + records[#records+1] = {id="_", name= "--- " .. _"Current delegatee" .. " ---"} 1.144 + records[#records+1] = { id = current_trustee_id, name = current_trustee_name } 1.145 + end 1.146 + -- add initiative authors 1.147 + if initiative then 1.148 + records[#records+1] = {id="_", name= "--- " .. _"Initiators" .. " ---"} 1.149 + for i,record in ipairs(initiative.initiators) do 1.150 + records[#records+1] = record.member 1.151 + end 1.152 + end 1.153 + -- add saved members 1.154 + if #contact_members > 0 then 1.155 + records[#records+1] = {id="_", name= "--- " .. _"Saved contacts" .. " ---"} 1.156 + for i, record in ipairs(contact_members) do 1.157 + records[#records+1] = record 1.158 + end 1.159 + end 1.160 + 1.161 + local disabled_records = {} 1.162 + disabled_records["_"] = true 1.163 + disabled_records[app.session.member_id] = true 1.164 + 1.165 + local value = current_trustee_id 1.166 + if preview_trustee_id then 1.167 + value = preview_trustee_id 1.168 + end 1.169 + if preview_trustee_id == nil and delegation and not delegation.trustee_id then 1.170 + value = 0 1.171 + end 1.172 + 1.173 + ui.tag{ content = _"Choose your delegatee" } 1.174 + 1.175 + ui.field.select{ 1.176 + attr = { onchange = "updateDelegationInfo();" }, 1.177 + name = "trustee_id", 1.178 + foreign_records = records, 1.179 + foreign_id = "id", 1.180 + foreign_name = "name", 1.181 + disabled_records = disabled_records, 1.182 + value = value 1.183 + } 1.184 + slot.put("<br />") 1.185 + 1.186 + ui.container{ content = _"You can choose only members which you have been saved as contact before." } 1.187 + 1.188 + ui.field.hidden{ name = "preview" } 1.189 + 1.190 + slot.put("<br />") 1.191 + ui.tag { tag = "input", content = "", attr = { 1.192 + type = "submit", 1.193 + value = _"Save", 1.194 + class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored", 1.195 + } } 1.196 + 1.197 + slot.put(" ") 1.198 + if initiative then 1.199 + ui.link{ 1.200 + module = "initiative", 1.201 + view = "show", 1.202 + id = initiative.id, 1.203 + attr = { class = "mdl-button mdl-js-button mdl-button--underlined" }, 1.204 + content = function() 1.205 + slot.put(_"Cancel") 1.206 + end, 1.207 + } 1.208 + elseif issue then 1.209 + ui.link{ 1.210 + module = "issue", 1.211 + view = "show", 1.212 + id = issue.id, 1.213 + attr = { class = "mdl-button mdl-js-button mdl-button--underlined" }, 1.214 + content = function() 1.215 + slot.put(_"Cancel") 1.216 + end, 1.217 + } 1.218 + elseif area then 1.219 + ui.link{ 1.220 + module = "index", 1.221 + view = "index", 1.222 + params = { unit = area.unit_id, area = area.id }, 1.223 + attr = { class = "mdl-button mdl-js-button mdl-button--underlined" }, 1.224 + content = function() 1.225 + slot.put(_"Cancel") 1.226 + end, 1.227 + } 1.228 + else 1.229 + ui.link{ 1.230 + module = "index", 1.231 + view = "index", 1.232 + attr = { class = "mdl-button mdl-js-button mdl-button--underlined" }, 1.233 + content = function() 1.234 + slot.put(_"Cancel") 1.235 + end, 1.236 + } 1.237 + end 1.238 + 1.239 end 1.240 - end 1.241 - local text_apply 1.242 - local text_abandon 1.243 - if config.single_unit_id then 1.244 - text_apply = _("Apply global or area delegation for this issue (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope }) 1.245 - text_abandon = _"Abandon unit and area delegations for this issue" 1.246 - else 1.247 - text_apply = _("Apply unit or area delegation for this issue (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope }) 1.248 - text_abandon = _"Abandon unit and area delegations for this issue" 1.249 - end 1.250 - 1.251 - records = { 1.252 - { id = -1, name = text_apply }, 1.253 - { id = 0, name = text_abandon } 1.254 - } 1.255 - elseif area then 1.256 - local delegate_name = "" 1.257 - local scope = _"no delegation set" 1.258 - local unit_delegation = Delegation:by_pk(app.session.member_id, area.unit_id) 1.259 - if unit_delegation then 1.260 - delegate_name = unit_delegation.trustee.name 1.261 - scope = config.single_unit_id and _"global" or _"unit" 1.262 - end 1.263 - local text_apply 1.264 - local text_abandon 1.265 - if config.single_unit_id then 1.266 - text_apply = _("Apply global delegation for this area (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope }) 1.267 - text_abandon = _"Abandon global delegation for this area" 1.268 - else 1.269 - text_apply = _("Apply unit delegation for this area (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope }) 1.270 - text_abandon = _"Abandon unit delegation for this area" 1.271 - end 1.272 - records = { 1.273 - { 1.274 - id = -1, 1.275 - name = text_apply 1.276 - }, 1.277 - { 1.278 - id = 0, 1.279 - name = text_abandon 1.280 - } 1.281 - } 1.282 - 1.283 - else 1.284 - records = { 1.285 - { 1.286 - id = -1, 1.287 - name = _"No delegation" 1.288 - } 1.289 } 1.290 1.291 - end 1.292 - -- add current trustee 1.293 - if current_trustee_id then 1.294 - records[#records+1] = {id="_", name= "--- " .. _"Current delegatee" .. " ---"} 1.295 - records[#records+1] = { id = current_trustee_id, name = current_trustee_name } 1.296 - end 1.297 - -- add initiative authors 1.298 - if initiative then 1.299 - records[#records+1] = {id="_", name= "--- " .. _"Initiators" .. " ---"} 1.300 - for i,record in ipairs(initiative.initiators) do 1.301 - records[#records+1] = record.member 1.302 - end 1.303 - end 1.304 - -- add saved members 1.305 - if #contact_members > 0 then 1.306 - records[#records+1] = {id="_", name= "--- " .. _"Saved contacts" .. " ---"} 1.307 - for i, record in ipairs(contact_members) do 1.308 - records[#records+1] = record 1.309 - end 1.310 - end 1.311 - 1.312 - local disabled_records = {} 1.313 - disabled_records["_"] = true 1.314 - disabled_records[app.session.member_id] = true 1.315 - 1.316 - local value = current_trustee_id 1.317 - if preview_trustee_id then 1.318 - value = preview_trustee_id 1.319 - end 1.320 - if preview_trustee_id == nil and delegation and not delegation.trustee_id then 1.321 - value = 0 1.322 - end 1.323 + end } 1.324 + end } 1.325 + end } 1.326 + -- ------------------------ 1.327 1.328 - ui.heading{ level = 2, content = _"Choose your delegatee" } 1.329 - 1.330 - ui.field.select{ 1.331 - attr = { onchange = "updateDelegationInfo();" }, 1.332 - name = "trustee_id", 1.333 - foreign_records = records, 1.334 - foreign_id = "id", 1.335 - foreign_name = "name", 1.336 - disabled_records = disabled_records, 1.337 - value = value 1.338 - } 1.339 - 1.340 - ui.container{ content = _"You can choose only members which you have been saved as contact before." } 1.341 + ui.container{ attr = { class = "mdl-cell mdl-cell--12-col mdl-cell--4-col-desktop" }, content = function() 1.342 + ui.container{ attr = { class = "mdl-card mdl-shadow--2dp mdl-card__fullwidth" }, content = function() 1.343 1.344 - ui.field.hidden{ name = "preview" } 1.345 - 1.346 - slot.put("<br />") 1.347 - ui.tag { tag = "input", content = "", attr = { 1.348 - type = "submit", 1.349 - value = _"Save", 1.350 - class = "btn btn-default", 1.351 - } } 1.352 - 1.353 - slot.put("<br /><br /><br />") 1.354 - if initiative then 1.355 - ui.link{ 1.356 - module = "initiative", 1.357 - view = "show", 1.358 - id = initiative.id, 1.359 - content = function() 1.360 - slot.put(_"Cancel") 1.361 - end, 1.362 + ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function() 1.363 + ui.container{ 1.364 + attr = { class = "mdl-card__title-text" }, 1.365 + content = _"Preview of delegation" 1.366 } 1.367 - elseif issue then 1.368 - ui.link{ 1.369 - module = "issue", 1.370 - view = "show", 1.371 - id = issue.id, 1.372 - content = function() 1.373 - slot.put(_"Cancel") 1.374 - end, 1.375 - } 1.376 - elseif area then 1.377 - ui.link{ 1.378 - module = "area", 1.379 - view = "show", 1.380 - id = area.id, 1.381 - content = function() 1.382 - slot.put(_"Cancel") 1.383 - end, 1.384 - } 1.385 - else 1.386 - ui.link{ 1.387 - module = "index", 1.388 - view = "index", 1.389 - content = function() 1.390 - slot.put(_"Cancel") 1.391 - end, 1.392 - } 1.393 - end 1.394 + end } 1.395 1.396 - end 1.397 - } 1.398 - 1.399 -end ) end ) 1.400 --- ------------------------ 1.401 - 1.402 -ui.sidebar( "tab-members", function () 1.403 - 1.404 -ui.sidebarHead( function () 1.405 - ui.heading { level = 1, content = _"Preview of delegation" } 1.406 -end ) 1.407 + ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function() 1.408 + local preview_inherit = false 1.409 + local tmp_preview_trustee_id = preview_trustee_id 1.410 + if preview_trustee_id == -1 then 1.411 + preview_inherit = true 1.412 + tmp_preview_trustee_id = nil 1.413 + end 1.414 + local delegation_chain = Member:new_selector() 1.415 + :add_field("delegation_chain.*") 1.416 + :join({ "delegation_chain(?,?,?,?,?,?)", app.session.member.id, unit_id, area_id, issue_id, tmp_preview_trustee_id, preview_inherit }, "delegation_chain", "member.id = delegation_chain.member_id") 1.417 + :add_order_by("index") 1.418 + :exec() 1.419 1.420 -local preview_inherit = false 1.421 -local tmp_preview_trustee_id = preview_trustee_id 1.422 -if preview_trustee_id == -1 then 1.423 - preview_inherit = true 1.424 - tmp_preview_trustee_id = nil 1.425 -end 1.426 -local delegation_chain = Member:new_selector() 1.427 - :add_field("delegation_chain.*") 1.428 - :join({ "delegation_chain(?,?,?,?,?,?)", app.session.member.id, unit_id, area_id, issue_id, tmp_preview_trustee_id, preview_inherit }, "delegation_chain", "member.id = delegation_chain.member_id") 1.429 - :add_order_by("index") 1.430 - :exec() 1.431 + for i, record in ipairs(delegation_chain) do 1.432 + local style 1.433 + local overridden = (not issue or issue.state ~= 'voting') and record.overridden 1.434 + ui.sidebarSection( function () 1.435 + if record.scope_in then 1.436 + if not overridden then 1.437 + local text = _"delegated to" 1.438 + ui.image{ 1.439 + attr = { class = "delegation_arrow", alt = text, title = text }, 1.440 + static = "delegation_arrow_24_vertical.png" 1.441 + } 1.442 + else 1.443 + local text = _"delegated to" 1.444 + ui.image{ 1.445 + attr = { class = "delegation_arrow delegation_arrow_overridden", alt = text, title = text }, 1.446 + static = "delegation_arrow_24_vertical.png" 1.447 + } 1.448 + end 1.449 + ui.tag{ 1.450 + attr = { class = "delegation_scope" .. (overridden and " delegation_scope_overridden" or "") }, 1.451 + content = function() 1.452 + if record.scope_in == "unit" then 1.453 + slot.put(config.single_object_mode and _"Global delegation" or _"Unit delegation") 1.454 + elseif record.scope_in == "area" then 1.455 + slot.put(_"Area delegation") 1.456 + elseif record.scope_in == "issue" then 1.457 + slot.put(_"Issue delegation") 1.458 + end 1.459 + end 1.460 + } 1.461 + end 1.462 + ui.container{ 1.463 + attr = { class = overridden and "delegation_overridden" or "" }, 1.464 + content = function() 1.465 + execute.view{ 1.466 + module = "member", 1.467 + view = "_show_thumb", 1.468 + params = { member = record } 1.469 + } 1.470 + end 1.471 + } 1.472 + if issue and issue.state ~= 'voting' and record.participation and not record.overridden then 1.473 + ui.container{ 1.474 + attr = { class = "delegation_participation" }, 1.475 + content = function() 1.476 + if i == #delegation_chain then 1.477 + ui.tag{ content = _"This member is currently participating in this issue." } 1.478 + else 1.479 + ui.tag{ content = _"This member is participating, the remaining delegation chain is suspended during discussing." } 1.480 + end 1.481 + end 1.482 + } 1.483 + end 1.484 + slot.put("<br style='clear: left'/>") 1.485 + end ) 1.486 + end 1.487 1.488 -for i, record in ipairs(delegation_chain) do 1.489 - local style 1.490 - local overridden = (not issue or issue.state ~= 'voting') and record.overridden 1.491 - ui.sidebarSection( function () 1.492 - if record.scope_in then 1.493 - if not overridden then 1.494 - local text = _"delegated to" 1.495 - ui.image{ 1.496 - attr = { class = "delegation_arrow", alt = text, title = text }, 1.497 - static = "delegation_arrow_24_vertical.png" 1.498 - } 1.499 - else 1.500 - local text = _"delegated to" 1.501 - ui.image{ 1.502 - attr = { class = "delegation_arrow delegation_arrow_overridden", alt = text, title = text }, 1.503 - static = "delegation_arrow_24_vertical.png" 1.504 - } 1.505 - end 1.506 - ui.tag{ 1.507 - attr = { class = "delegation_scope" .. (overridden and " delegation_scope_overridden" or "") }, 1.508 - content = function() 1.509 - if record.scope_in == "unit" then 1.510 - slot.put(config.single_object_mode and _"Global delegation" or _"Unit delegation") 1.511 - elseif record.scope_in == "area" then 1.512 - slot.put(_"Area delegation") 1.513 - elseif record.scope_in == "issue" then 1.514 - slot.put(_"Issue delegation") 1.515 + if preview_trustee_id == 0 or not preview_trustee_id == null and delegation and not delegation.trustee_id then 1.516 + ui.image{ 1.517 + static = "icons/16/table_go_crossed.png" 1.518 + } 1.519 + if issue_id then 1.520 + slot.put(_"Delegation turned off for issue") 1.521 + elseif area_id then 1.522 + slot.put(_"Delegation turned off for area") 1.523 end 1.524 end 1.525 - } 1.526 - end 1.527 - ui.container{ 1.528 - attr = { class = overridden and "delegation_overridden" or "" }, 1.529 - content = function() 1.530 - execute.view{ 1.531 - module = "member", 1.532 - view = "_show_thumb", 1.533 - params = { member = record } 1.534 - } 1.535 - end 1.536 - } 1.537 - if issue and issue.state ~= 'voting' and record.participation and not record.overridden then 1.538 - ui.container{ 1.539 - attr = { class = "delegation_participation" }, 1.540 - content = function() 1.541 - if i == #delegation_chain then 1.542 - ui.tag{ content = _"This member is currently participating in this issue." } 1.543 - else 1.544 - ui.tag{ content = _"This member is participating, the remaining delegation chain is suspended during discussing." } 1.545 - end 1.546 - end 1.547 - } 1.548 - end 1.549 - slot.put("<br style='clear: left'/>") 1.550 - end ) 1.551 -end 1.552 - 1.553 -if preview_trustee_id == 0 or not preview_trustee_id == null and delegation and not delegation.trustee_id then 1.554 - ui.image{ 1.555 - static = "icons/16/table_go_crossed.png" 1.556 - } 1.557 - if issue_id then 1.558 - slot.put(_"Delegation turned off for issue") 1.559 - elseif area_id then 1.560 - slot.put(_"Delegation turned off for area") 1.561 - end 1.562 -end 1.563 + 1.564 + end } 1.565 + 1.566 + end } 1.567 + 1.568 + end } 1.569 1.570 1.571 -end ) 1.572 \ No newline at end of file 1.573 +end }