rev |
line source |
bsw/jbe@1309
|
1 if true then return end
|
bsw/jbe@1309
|
2
|
bsw@1045
|
3 local member = param.get ( "member", "table" )
|
bsw@1045
|
4 local units
|
bsw@1045
|
5 if member then
|
bsw@1218
|
6 units = member:get_reference_selector("units"):add_order_by("name"):exec()
|
bsw@1045
|
7 units:load_delegation_info_once_for_member_id(member.id)
|
bsw@1045
|
8 else
|
bsw@1045
|
9 units = Unit:new_selector():add_where("active"):add_order_by("name"):exec()
|
bsw@1045
|
10 ui.sidebar( "tab-whatcanido", function()
|
bsw@1045
|
11 ui.sidebarHead( function()
|
bsw@1045
|
12 ui.heading { level = 2, content = _"Organizational units" }
|
bsw@1045
|
13 end )
|
bsw@1045
|
14 ui.sidebarSection( function()
|
bsw@1045
|
15 execute.view { module = "unit", view = "_list" }
|
bsw@1045
|
16 end )
|
bsw@1045
|
17 end )
|
bsw@1045
|
18 return
|
bsw@1045
|
19 end
|
bsw@1045
|
20
|
bsw@1045
|
21
|
bsw@1045
|
22 for i, unit in ipairs(units) do
|
bsw@1045
|
23
|
bsw@1045
|
24 ui.sidebar ( "tab-whatcanido units", function ()
|
bsw@1045
|
25
|
bsw@1045
|
26 local areas_selector = Area:new_selector()
|
bsw@1045
|
27 :reset_fields()
|
bsw@1045
|
28 :add_field("area.id", nil, { "grouped" })
|
bsw@1045
|
29 :add_field("area.unit_id", nil, { "grouped" })
|
bsw@1045
|
30 :add_field("area.name", nil, { "grouped" })
|
bsw@1045
|
31 :add_where{ "area.unit_id = ?", unit.id }
|
bsw@1045
|
32 :add_where{ "area.active" }
|
bsw@1045
|
33 :add_order_by("area.name")
|
bsw@1045
|
34
|
bsw@1045
|
35 local areas = areas_selector:exec()
|
bsw@1045
|
36 if member then
|
bsw@1045
|
37 areas:load_delegation_info_once_for_member_id(member.id)
|
bsw@1045
|
38 end
|
bsw@1045
|
39
|
bsw@1045
|
40 if #areas > 0 then
|
bsw@1045
|
41
|
bsw@1045
|
42 ui.container {
|
bsw@1045
|
43 attr = { class = "sidebarHead" },
|
bsw@1045
|
44 content = function ()
|
bsw@1045
|
45 ui.heading { level = 2, content = function ()
|
bsw@1045
|
46 ui.link {
|
bsw@1045
|
47 attr = { class = "unit" },
|
bsw@1045
|
48 module = "unit", view = "show", id = unit.id,
|
bsw@1045
|
49 content = unit.name
|
bsw@1045
|
50 }
|
bsw@1045
|
51
|
bsw@1045
|
52 if member then
|
bsw@1045
|
53 local delegation = Delegation:by_pk(member.id, unit.id, nil, nil)
|
bsw@1045
|
54
|
bsw@1045
|
55 if delegation then
|
bsw@1045
|
56 ui.link {
|
bsw@1045
|
57 module = "delegation", view = "show", params = {
|
bsw@1045
|
58 unit_id = unit.id
|
bsw@1045
|
59 },
|
bsw@1045
|
60 attr = { class = "delegation_info" },
|
bsw@1045
|
61 content = function ()
|
bsw@1045
|
62 ui.delegation(delegation.trustee_id, delegation.trustee.name)
|
bsw@1045
|
63 end
|
bsw@1045
|
64 }
|
bsw@1045
|
65 end
|
bsw@1045
|
66 end
|
bsw@1045
|
67 end }
|
bsw@1045
|
68
|
bsw@1045
|
69 end
|
bsw@1045
|
70 }
|
bsw@1045
|
71
|
bsw@1045
|
72
|
bsw@1045
|
73 ui.tag { tag = "div", attr = { class = "areas areas-" .. unit.id }, content = function ()
|
bsw@1045
|
74
|
bsw@1045
|
75 for i, area in ipairs(areas) do
|
bsw@1045
|
76
|
bsw/jbe@1309
|
77 ui.tag { tag = "div", attr = { class = "sidebarRow" }, content = function ()
|
bsw@1045
|
78
|
bsw@1045
|
79 if member then
|
bsw@1045
|
80 local delegation = Delegation:by_pk(member.id, nil, area.id, nil)
|
bsw@1045
|
81
|
bsw@1045
|
82 if delegation then
|
bsw@1045
|
83 ui.link {
|
bsw@1045
|
84 module = "delegation", view = "show", params = {
|
bsw@1045
|
85 area_id = area.id
|
bsw@1045
|
86 },
|
bsw@1045
|
87 attr = { class = "delegation_info" },
|
bsw@1045
|
88 content = function ()
|
bsw@1045
|
89 ui.delegation(delegation.trustee_id, delegation.trustee_id and delegation.trustee.name)
|
bsw@1045
|
90 end
|
bsw@1045
|
91 }
|
bsw@1045
|
92 end
|
bsw@1045
|
93 end
|
bsw@1045
|
94
|
bsw@1045
|
95 slot.put ( " " )
|
bsw@1045
|
96
|
bsw@1045
|
97 ui.link {
|
bsw@1045
|
98 attr = { class = "area" },
|
bsw@1045
|
99 module = "area", view = "show", id = area.id,
|
bsw@1045
|
100 content = area.name
|
bsw@1045
|
101 }
|
bsw@1045
|
102
|
bsw@1045
|
103
|
bsw@1045
|
104 end }
|
bsw@1045
|
105 end
|
bsw@1045
|
106 end }
|
bsw@1045
|
107 end
|
bsw@1045
|
108 end )
|
bsw@1045
|
109 end
|
bsw@1045
|
110
|
bsw@1045
|
111
|