rev |
line source |
bsw@217
|
1 local unit = param.get("unit", "table")
|
bsw@217
|
2
|
bsw@215
|
3 local current_area_id = param.get("current_area_id", atom.integer)
|
bsw@215
|
4 local current_phase = param.get_all_cgi()["phase"]
|
bsw@215
|
5
|
bsw@217
|
6 local records = {
|
bsw@217
|
7 { id = 0, name = _"All units" },
|
bsw@217
|
8 { id = "disabled", name = "" },
|
bsw@217
|
9 { id = "disabled", name = _"Units, you are member of:" },
|
bsw@215
|
10 }
|
bsw@215
|
11
|
bsw@217
|
12
|
bsw@217
|
13 for i, unit in ipairs(Unit:get_flattened_tree()) do
|
bsw@217
|
14 records[#records+1] = { id = unit.id, name = unit.flattened_tree_name }
|
bsw@215
|
15 end
|
bsw@215
|
16
|
bsw@217
|
17 records[#records+1] = { id = "disabled", name = "" }
|
bsw@217
|
18 records[#records+1] = { id = -1, name = _"Other units..." }
|
bsw@217
|
19
|
bsw@217
|
20 ui.box{ content = function()
|
bsw@212
|
21 ui.box_row{ class = "head", content = function()
|
bsw@217
|
22 ui.box_col{ class = "head", content = function()
|
bsw@217
|
23 ui.form{
|
bsw@217
|
24 method = "GET",
|
bsw@217
|
25 module = "lf2", view = "index",
|
bsw@217
|
26 content = function()
|
bsw@217
|
27 ui.field.select{
|
bsw@217
|
28 attr = { onchange = "this.form.submit();" },
|
bsw@217
|
29 name = "_webmcp_id",
|
bsw@217
|
30 foreign_records = records,
|
bsw@217
|
31 foreign_id = "id",
|
bsw@217
|
32 foreign_name = "name",
|
bsw@217
|
33 disabled_records = { disabled = true },
|
bsw@217
|
34 value = unit and unit.id or 0
|
bsw@217
|
35 }
|
bsw@217
|
36 end
|
bsw@217
|
37 }
|
bsw@217
|
38 end }
|
bsw@212
|
39 end }
|
bsw@217
|
40
|
bsw@217
|
41 if unit then
|
bsw@217
|
42 local trustees = Member:new_selector()
|
bsw@217
|
43 :add_field("delegation_chain.*")
|
bsw@217
|
44 :join({ "delegation_chain(?, ?, NULL, NULL)", app.session.member.id, unit.id }, "delegation_chain", "member.id = delegation_chain.member_id")
|
bsw@217
|
45 :add_order_by("index")
|
bsw@217
|
46 :exec()
|
bsw@217
|
47
|
bsw@217
|
48 if #trustees > 1 then
|
bsw@217
|
49 ui.box_row{ content = function() ui.box_col{ content = function()
|
bsw@217
|
50 execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small" } }
|
bsw@217
|
51 end } end }
|
bsw@217
|
52 end
|
bsw@217
|
53
|
bsw@212
|
54 ui.box_row{ content = function() ui.box_col{ content = function()
|
bsw@217
|
55 if trustees[1].scope_out == "global" then
|
bsw@217
|
56 text = _"Change or revoke unit delegation"
|
bsw@217
|
57 else
|
bsw@217
|
58 text = _"Set unit delegation"
|
bsw@217
|
59 end
|
bsw@217
|
60 ui.link{
|
bsw@217
|
61 text = text,
|
bsw@217
|
62 module = "lf2", view = "delegation", params = { unit_id = unit.id }
|
bsw@217
|
63 }
|
bsw@212
|
64 end } end }
|
bsw@212
|
65 end
|
bsw@217
|
66
|
bsw@217
|
67 end }
|
bsw@217
|
68
|
bsw@217
|
69 if unit then
|
bsw@217
|
70 local member_areas_selector = Area:build_selector{
|
bsw@217
|
71 unit_id = unit.id,
|
bsw@217
|
72 member_id = app.session.member_id,
|
bsw@217
|
73 order = "name"
|
bsw@217
|
74 }
|
bsw@217
|
75 local other_areas_selector = Area:build_selector{
|
bsw@217
|
76 unit_id = unit.id,
|
bsw@217
|
77 not_member_id = app.session.member_id,
|
bsw@217
|
78 order = "name"
|
bsw@217
|
79 }
|
bsw@217
|
80
|
bsw@217
|
81 if member_areas_selector:count() > 0 then
|
bsw@217
|
82 ui.box{ content = function()
|
bsw@217
|
83 ui.box_row{ class = "head", content = function() ui.box_col{ class = "head", content = function()
|
bsw@215
|
84 ui.link{ text = _"Areas, you are member of", module = "lf2", view = "index" }
|
bsw@215
|
85 end } end }
|
bsw@215
|
86
|
bsw@215
|
87 execute.view{
|
bsw@215
|
88 module = "lf2", view = "_areas", params = {
|
bsw@215
|
89 areas_selector = member_areas_selector,
|
bsw@215
|
90 current_area_id = current_area_id,
|
bsw@215
|
91 current_phase = current_phase
|
bsw@215
|
92 }
|
bsw@215
|
93 }
|
bsw@217
|
94 end }
|
bsw@217
|
95 end
|
bsw@215
|
96
|
bsw@217
|
97 if other_areas_selector:count() > 0 then
|
bsw@217
|
98 ui.box{ content = function()
|
bsw@217
|
99 ui.box_row{ class = "head", content = function() ui.box_col{ class = "head", content = function()
|
bsw@217
|
100 ui.link{ content = _"Areas", module = "lf2", view = "index" }
|
bsw@215
|
101 end } end }
|
bsw@215
|
102
|
bsw@215
|
103 execute.view{
|
bsw@215
|
104 module = "lf2", view = "_areas", params = {
|
bsw@215
|
105 areas_selector = other_areas_selector,
|
bsw@215
|
106 current_area_id = current_area_id,
|
bsw@215
|
107 current_phase = current_phase
|
bsw@215
|
108 }
|
bsw@215
|
109 }
|
bsw@217
|
110 end }
|
bsw@217
|
111 end
|
bsw@217
|
112 end
|
bsw@215
|
113
|
bsw@215
|
114 execute.view{ module = "lf2", view = "_search", params = { area = area } }
|