liquid_feedback_frontend
diff app/main/delegation/_show_box.lua @ 248:e3613831cd1e
Migrate global delegation to unit level
author | bsw |
---|---|
date | Fri Dec 30 03:13:10 2011 +0100 (2011-12-30) |
parents | 6efacc81ce81 |
children | cb2380e08bb5 |
line diff
1.1 --- a/app/main/delegation/_show_box.lua Fri Dec 30 03:11:57 2011 +0100 1.2 +++ b/app/main/delegation/_show_box.lua Fri Dec 30 03:13:10 2011 +0100 1.3 @@ -1,12 +1,12 @@ 1.4 -function change_delegation(scope, area_id, issue, delegation, initiative_id) 1.5 +function change_delegation(scope, unit_id, area_id, issue, delegation, initiative_id) 1.6 local image 1.7 local text 1.8 - if scope == "global" and delegation then 1.9 + if scope == "unit" and delegation and delegation.unit_id then 1.10 image = { static = "icons/16/table_go.png" } 1.11 - text = _"Change global delegation" 1.12 - elseif scope == "global" and not delegation then 1.13 + text = _"Change unit delegation" 1.14 + elseif scope == "unit" and not (delegation and delegation.unit_id) then 1.15 image = { static = "icons/16/table_go.png" } 1.16 - text = _"Set global delegation" 1.17 + text = _"Set unit delegation" 1.18 elseif scope == "area" and delegation and delegation.area_id then 1.19 image = { static = "icons/16/table_go.png" } 1.20 text = _"Change area delegation" 1.21 @@ -35,7 +35,8 @@ 1.22 params = { 1.23 issue_id = issue and issue.id or nil, 1.24 initiative_id = initiative_id or nil, 1.25 - area_id = area_id 1.26 + area_id = area_id, 1.27 + unit_id = unit_id 1.28 }, 1.29 } 1.30 if delegation then 1.31 @@ -44,7 +45,7 @@ 1.32 text = _"Revoke", 1.33 module = "delegation", 1.34 action = "update", 1.35 - params = { issue_id = delegation.issue_id, area_id = delegation.area_id, delete = true }, 1.36 + params = { issue_id = delegation.issue_id, area_id = delegation.area_id, unit_id = delegation.unit_id, delete = true }, 1.37 routing = { 1.38 default = { 1.39 mode = "redirect", 1.40 @@ -61,11 +62,14 @@ 1.41 end 1.42 1.43 local delegation 1.44 +local unit_id 1.45 local area_id 1.46 local issue_id 1.47 local initiative_id 1.48 1.49 -local scope = "global" 1.50 +local scope = "unit" 1.51 + 1.52 +unit_id = param.get("unit_id", atom.integer) 1.53 1.54 if param.get("initiative_id", atom.integer) then 1.55 initiative_id = param.get("initiative_id", atom.integer) 1.56 @@ -90,16 +94,16 @@ 1.57 1.58 if issue_id then 1.59 issue = Issue:by_id(issue_id) 1.60 - delegation = Delegation:by_pk(app.session.member.id, nil, issue_id) 1.61 + delegation = Delegation:by_pk(app.session.member.id, nil, nil, issue_id) 1.62 if not delegation then 1.63 - delegation = Delegation:by_pk(app.session.member.id, issue.area_id) 1.64 + delegation = Delegation:by_pk(app.session.member.id, nil, issue.area_id) 1.65 end 1.66 elseif area_id then 1.67 - delegation = Delegation:by_pk(app.session.member.id, area_id) 1.68 + delegation = Delegation:by_pk(app.session.member.id, nil, area_id) 1.69 end 1.70 1.71 if not delegation then 1.72 - delegation = Delegation:by_pk(app.session.member.id) 1.73 + delegation = Delegation:by_pk(app.session.member.id, unit_id) 1.74 end 1.75 1.76 1.77 @@ -126,7 +130,7 @@ 1.78 elseif delegation.area_id then 1.79 slot.put(_"Area delegation active") 1.80 else 1.81 - slot.put(_"Global delegation active") 1.82 + slot.put(_"Unit delegation active") 1.83 end 1.84 else 1.85 ui.image{ 1.86 @@ -164,7 +168,7 @@ 1.87 :exec() 1.88 1.89 if not issue or (issue.state ~= "finished" and issue.state ~= "cancelled") then 1.90 - change_delegation(scope, area_id, issue, delegation, initiative_id) 1.91 + change_delegation(scope, unit_id, area_id, issue, delegation, initiative_id) 1.92 end 1.93 1.94 for i, record in ipairs(delegation_chain) do 1.95 @@ -188,8 +192,8 @@ 1.96 ui.container{ 1.97 attr = { class = "delegation_scope" .. (overridden and " delegation_scope_overridden" or "") }, 1.98 content = function() 1.99 - if record.scope_in == "global" then 1.100 - slot.put(_"Global delegation") 1.101 + if record.scope_in == "unit" then 1.102 + slot.put(_"Unit delegation") 1.103 elseif record.scope_in == "area" then 1.104 slot.put(_"Area delegation") 1.105 elseif record.scope_in == "issue" then 1.106 @@ -225,6 +229,6 @@ 1.107 end 1.108 } 1.109 else 1.110 - change_delegation(scope, area_id, issue, nil, initiative_id) 1.111 + change_delegation(scope, unit_id, area_id, issue, nil, initiative_id) 1.112 end 1.113 end)