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