rev |
line source |
bsw@297
|
1 local voting_right_unit_id
|
bsw@297
|
2
|
bsw@248
|
3 local unit = Unit:by_id(param.get("unit_id", atom.integer))
|
bsw@248
|
4 if unit then
|
bsw@297
|
5 voting_right_unit_id = unit.id
|
bsw@264
|
6 slot.put_into("title", encode.html(config.single_unit_id and _"Set global delegation" or _"Set unit delegation"))
|
bsw@248
|
7 util.help("delegation.new.unit")
|
bsw@248
|
8 end
|
bsw@248
|
9
|
bsw/jbe@0
|
10 local area = Area:by_id(param.get("area_id", atom.integer))
|
bsw/jbe@0
|
11 if area then
|
bsw@297
|
12 voting_right_unit_id = area.unit_id
|
bsw/jbe@0
|
13 slot.put_into("title", encode.html(_"Set delegation for Area '#{name}'":gsub("#{name}", area.name)))
|
bsw/jbe@4
|
14 util.help("delegation.new.area")
|
bsw/jbe@0
|
15 end
|
bsw/jbe@0
|
16
|
bsw/jbe@0
|
17 local issue = Issue:by_id(param.get("issue_id", atom.integer))
|
bsw/jbe@0
|
18 if issue then
|
bsw@297
|
19 voting_right_unit_id = issue.area.unit_id
|
bsw/jbe@0
|
20 slot.put_into("title", encode.html(_"Set delegation for Issue ##{number} in Area '#{area_name}'":gsub("#{number}", issue.id):gsub("#{area_name}", issue.area.name)))
|
bsw/jbe@4
|
21 util.help("delegation.new.issue")
|
bsw/jbe@0
|
22 end
|
bsw/jbe@0
|
23
|
poelzi@111
|
24 local initiative = Initiative:by_id(param.get("initiative_id", atom.integer))
|
poelzi@111
|
25
|
bsw/jbe@4
|
26 slot.select("actions", function()
|
bsw/jbe@4
|
27 if issue then
|
bsw/jbe@4
|
28 ui.link{
|
bsw/jbe@4
|
29 module = "issue",
|
bsw/jbe@4
|
30 view = "show",
|
bsw/jbe@4
|
31 id = issue.id,
|
bsw/jbe@4
|
32 content = function()
|
bsw/jbe@4
|
33 ui.image{ static = "icons/16/cancel.png" }
|
bsw/jbe@4
|
34 slot.put(_"Cancel")
|
bsw/jbe@4
|
35 end,
|
bsw/jbe@4
|
36 }
|
bsw/jbe@4
|
37 elseif area then
|
bsw/jbe@4
|
38 ui.link{
|
bsw/jbe@4
|
39 module = "area",
|
bsw/jbe@4
|
40 view = "show",
|
bsw/jbe@4
|
41 id = area.id,
|
bsw/jbe@4
|
42 content = function()
|
bsw/jbe@4
|
43 ui.image{ static = "icons/16/cancel.png" }
|
bsw/jbe@4
|
44 slot.put(_"Cancel")
|
bsw/jbe@4
|
45 end,
|
bsw/jbe@4
|
46 }
|
bsw/jbe@4
|
47 else
|
bsw/jbe@4
|
48 ui.link{
|
bsw/jbe@4
|
49 module = "index",
|
bsw/jbe@4
|
50 view = "index",
|
bsw/jbe@4
|
51 content = function()
|
bsw/jbe@4
|
52 ui.image{ static = "icons/16/cancel.png" }
|
bsw/jbe@4
|
53 slot.put(_"Cancel")
|
bsw/jbe@4
|
54 end,
|
bsw/jbe@4
|
55 }
|
bsw/jbe@4
|
56 end
|
bsw/jbe@4
|
57 end)
|
bsw/jbe@4
|
58
|
bsw/jbe@4
|
59
|
bsw@199
|
60 local contact_members = Member:build_selector{
|
bsw@199
|
61 is_contact_of_member_id = app.session.member_id,
|
bsw@297
|
62 voting_right_for_unit_id = voting_right_unit_id,
|
bsw@199
|
63 order = "name"
|
bsw@199
|
64 }:exec()
|
bsw/jbe@0
|
65
|
bsw/jbe@0
|
66 ui.form{
|
bsw/jbe@0
|
67 attr = { class = "vertical" },
|
bsw/jbe@0
|
68 module = "delegation",
|
bsw/jbe@0
|
69 action = "update",
|
bsw/jbe@0
|
70 params = {
|
bsw@248
|
71 unit_id = unit and unit.id or nil,
|
bsw/jbe@0
|
72 area_id = area and area.id or nil,
|
bsw/jbe@0
|
73 issue_id = issue and issue.id or nil,
|
bsw/jbe@0
|
74 },
|
bsw/jbe@0
|
75 routing = {
|
bsw/jbe@0
|
76 default = {
|
bsw/jbe@0
|
77 mode = "redirect",
|
bsw@273
|
78 module = area and "area" or issue and "issue" or "area",
|
bsw@273
|
79 view = (area or issue) and "show" or "list",
|
bsw/jbe@4
|
80 id = area and area.id or issue and issue.id or nil,
|
bsw@273
|
81 params = { unit_id = unit and unit.id or nil }
|
bsw/jbe@0
|
82 }
|
bsw/jbe@0
|
83 },
|
bsw/jbe@0
|
84 content = function()
|
bsw@180
|
85 local records
|
bsw@180
|
86
|
bsw@180
|
87 if issue then
|
bsw@183
|
88 local delegate_name = ""
|
bsw@183
|
89 local scope = "no delegation set"
|
bsw@248
|
90 local area_delegation = Delegation:by_pk(app.session.member_id, nil, issue.area_id)
|
bsw@183
|
91 if area_delegation then
|
bsw@187
|
92 delegate_name = area_delegation.trustee and area_delegation.trustee.name or _"abandoned"
|
bsw@183
|
93 scope = _"area"
|
bsw@183
|
94 else
|
bsw@248
|
95 local unit_delegation = Delegation:by_pk(app.session.member_id, issue.area.unit_id)
|
bsw@248
|
96 if unit_delegation then
|
bsw@248
|
97 delegate_name = unit_delegation.trustee.name
|
bsw@264
|
98 scope = config.single_unit_id and _"global" or _"unit"
|
bsw@248
|
99 end
|
bsw@183
|
100 end
|
bsw@264
|
101 local text_apply
|
bsw@264
|
102 local text_abandon
|
bsw@264
|
103 if config.single_unit_id then
|
bsw@264
|
104 text_apply = _("Apply global or area delegation for this issue (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope })
|
bsw@264
|
105 text_abandon = _"Abandon unit and area delegations for this issue"
|
bsw@264
|
106 else
|
bsw@264
|
107 text_apply = _("Apply unit or area delegation for this issue (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope })
|
bsw@264
|
108 text_abandon = _"Abandon unit and area delegations for this issue"
|
bsw@264
|
109 end
|
bsw@180
|
110 records = {
|
bsw@264
|
111 { id = -1, name = text_apply },
|
bsw@293
|
112 { id = 0, name = text_abandon }
|
bsw/jbe@4
|
113 }
|
bsw@180
|
114 elseif area then
|
bsw@183
|
115 local delegate_name = ""
|
bsw@183
|
116 local scope = "no delegation set"
|
bsw@248
|
117 local unit_delegation = Delegation:by_pk(app.session.member_id, area.unit_id)
|
bsw@248
|
118 if unit_delegation then
|
bsw@248
|
119 delegate_name = unit_delegation.trustee.name
|
bsw@264
|
120 scope = config.single_unit_id and _"global" or _"unit"
|
bsw@264
|
121 end
|
bsw@264
|
122 local text_apply
|
bsw@264
|
123 local text_abandon
|
bsw@264
|
124 if config.single_unit_id then
|
bsw@264
|
125 text_apply = _("Apply global delegation for this area (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope })
|
bsw@264
|
126 text_abandon = _"Abandon global delegation for this area"
|
bsw@264
|
127 else
|
bsw@264
|
128 text_apply = _("Apply unit delegation for this area (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope })
|
bsw@264
|
129 text_abandon = _"Abandon unit delegation for this area"
|
bsw@183
|
130 end
|
bsw@180
|
131 records = {
|
bsw@180
|
132 {
|
bsw@180
|
133 id = -1,
|
bsw@264
|
134 name = text_apply
|
bsw@180
|
135 },
|
bsw@180
|
136 {
|
bsw@180
|
137 id = 0,
|
bsw@264
|
138 name = text_abandon
|
bsw@180
|
139 }
|
bsw@180
|
140 }
|
bsw@180
|
141
|
bsw@180
|
142 else
|
bsw@180
|
143 records = {
|
bsw@180
|
144 {
|
bsw@180
|
145 id = -1,
|
bsw@180
|
146 name = _"No delegation"
|
bsw@180
|
147 }
|
bsw@180
|
148 }
|
bsw@180
|
149
|
bsw@180
|
150 end
|
bsw@183
|
151 -- add saved members
|
bsw@183
|
152 records[#records+1] = {id="_", name= "--- " .. _"Saved contacts" .. " ---"}
|
bsw/jbe@4
|
153 for i, record in ipairs(contact_members) do
|
bsw/jbe@4
|
154 records[#records+1] = record
|
bsw/jbe@4
|
155 end
|
poelzi@111
|
156 -- add initiative authors
|
poelzi@111
|
157 if initiative then
|
bsw@183
|
158 records[#records+1] = {id="_", name= "--- " .. _"Initiators" .. " ---"}
|
poelzi@111
|
159 for i,record in ipairs(initiative.initiators) do
|
poelzi@111
|
160 records[#records+1] = record.member
|
poelzi@111
|
161 end
|
poelzi@111
|
162 end
|
bsw/jbe@4
|
163
|
bsw@183
|
164 disabled_records = {}
|
bsw@183
|
165 disabled_records["_"] = true
|
bsw@183
|
166
|
bsw/jbe@0
|
167 ui.field.select{
|
bsw/jbe@0
|
168 label = _"Trustee",
|
bsw/jbe@0
|
169 name = "trustee_id",
|
bsw/jbe@4
|
170 foreign_records = records,
|
bsw/jbe@0
|
171 foreign_id = "id",
|
bsw/jbe@4
|
172 foreign_name = "name",
|
poelzi@111
|
173 disabled_records = disabled_records
|
bsw/jbe@0
|
174 }
|
poelzi@111
|
175
|
bsw/jbe@0
|
176 ui.submit{ text = _"Save" }
|
bsw/jbe@0
|
177 end
|
bsw/jbe@4
|
178 }
|