rev |
line source |
bsw@988
|
1 local delegations = Delegation:delegations_to_check_for_member_id(app.session.member_id)
|
bsw@988
|
2
|
bsw@988
|
3 ui.title(_"Current unit and area delegations need confirmation")
|
bsw@988
|
4
|
bsw@988
|
5 ui.actions(function()
|
bsw@988
|
6 if not app.session.needs_delegation_check then
|
bsw@988
|
7 ui.link{ module = "index", view = "index", text = _"Cancel" }
|
bsw@988
|
8 end
|
bsw@988
|
9 end)
|
bsw@988
|
10
|
bsw@993
|
11 if app.session.needs_delegation_check then
|
bsw@993
|
12 util.help("index.check_delegations_hard", _"Check delegations")
|
bsw@993
|
13 else
|
bsw@993
|
14 util.help("index.check_delegations", _"Check delegations")
|
bsw@993
|
15 end
|
bsw@988
|
16
|
bsw@988
|
17 ui.form{
|
bsw@988
|
18 module = "index", action = "check_delegations",
|
bsw@988
|
19 routing = {
|
bsw@988
|
20 default = { mode = "redirect", module = "index", view = "index" },
|
bsw@988
|
21 error = { mode = "redirect", module = "index", view = "check_delegations" }
|
bsw@988
|
22 },
|
bsw@988
|
23 content = function()
|
bsw@988
|
24
|
bsw@988
|
25 ui.tag{ tag = "table", attr = { class = "striped" }, content = function()
|
bsw@988
|
26
|
bsw@988
|
27 ui.tag{ tag = "tr", content = function()
|
bsw@988
|
28
|
bsw@988
|
29 ui.tag{ tag = "th", content = _"unit / area" }
|
bsw@988
|
30 ui.tag{ tag = "th", content = _"delegated to" }
|
bsw@988
|
31 ui.tag{ tag = "th", content = _"action" }
|
bsw@988
|
32
|
bsw@988
|
33 end }
|
bsw@988
|
34
|
bsw@988
|
35 for i, delegation in ipairs(delegations) do
|
bsw@988
|
36
|
bsw@988
|
37 local unit = Unit:by_id(delegation.unit_id)
|
bsw@988
|
38 local area = Area:by_id(delegation.area_id)
|
bsw@988
|
39 local member = Member:by_id(delegation.trustee_id)
|
bsw@988
|
40 local info
|
bsw@988
|
41 if area then
|
bsw@988
|
42 area:load_delegation_info_once_for_member_id(app.session.member_id)
|
bsw@988
|
43 info = area.delegation_info
|
bsw@988
|
44 else
|
bsw@988
|
45 unit:load_delegation_info_once_for_member_id(app.session.member_id)
|
bsw@988
|
46 info = unit.delegation_info
|
bsw@988
|
47 end
|
bsw@988
|
48
|
bsw@988
|
49 ui.tag{ tag = "tr", content = function ()
|
bsw@988
|
50
|
bsw@988
|
51 ui.tag { tag = "td", content = function()
|
bsw@988
|
52 ui.tag{ tag = "span", attr = { class = "unit_link" }, content = delegation.unit_name }
|
bsw@988
|
53 ui.tag{ tag = "span", attr = { class = "area_link" }, content = delegation.area_name }
|
bsw@988
|
54 end }
|
bsw@988
|
55
|
bsw@988
|
56 ui.tag { tag = "td", content = function()
|
bsw@988
|
57 if (member) then
|
bsw@988
|
58 local text = _"delegates to"
|
bsw@988
|
59 ui.image{
|
bsw@988
|
60 attr = { class = "delegation_arrow", alt = text, title = text },
|
bsw@988
|
61 static = "delegation_arrow_24_horizontal.png"
|
bsw@988
|
62 }
|
bsw@988
|
63 execute.view{ module = "member_image", view = "_show", params = {
|
bsw@988
|
64 member = member, class = "micro_avatar", popup_text = member.name,
|
bsw@988
|
65 image_type = "avatar", show_dummy = true,
|
bsw@988
|
66 } }
|
bsw@988
|
67 slot.put(" ")
|
bsw@988
|
68 ui.tag { tag = "span", content = delegation.member_name }
|
bsw@988
|
69 else
|
bsw@988
|
70 ui.tag{ tag = "span", content = _"Abandon unit delegation" }
|
bsw@988
|
71 end
|
bsw@988
|
72 end }
|
bsw@988
|
73
|
bsw@988
|
74 ui.tag { tag = "td", content = function()
|
bsw@988
|
75 local checked = config.check_delegations_default
|
bsw@988
|
76 ui.tag{ tag = "input", attr = {
|
bsw@988
|
77 type = "radio",
|
bsw@988
|
78 id = "delegation_" .. delegation.id .. "_confirm",
|
bsw@988
|
79 name = "delegation_" .. delegation.id,
|
bsw@988
|
80 value = "confirm",
|
bsw@988
|
81 checked = checked == "confirm" and "checked" or nil
|
bsw@988
|
82 } }
|
bsw@988
|
83 ui.tag{
|
bsw@988
|
84 tag = "label",
|
bsw@988
|
85 attr = { ["for"] = "delegation_" .. delegation.id .. "_confirm" },
|
bsw@988
|
86 content = _"confirm"
|
bsw@988
|
87 }
|
bsw@988
|
88 ui.tag{ tag = "input", attr = {
|
bsw@988
|
89 type = "radio",
|
bsw@988
|
90 id = "delegation_" .. delegation.id .. "_revoke",
|
bsw@988
|
91 name = "delegation_" .. delegation.id,
|
bsw@988
|
92 value = "revoke",
|
bsw@988
|
93 checked = checked == "revoke" and "checked" or nil
|
bsw@988
|
94 } }
|
bsw@988
|
95 ui.tag{
|
bsw@988
|
96 tag = "label",
|
bsw@988
|
97 attr = { ["for"] = "delegation_" .. delegation.id .. "_revoke" },
|
bsw@988
|
98 content = _"revoke"
|
bsw@988
|
99 }
|
bsw@988
|
100 end}
|
bsw@988
|
101
|
bsw@988
|
102 end }
|
bsw@988
|
103
|
bsw@988
|
104 end
|
bsw@988
|
105
|
bsw@988
|
106 end}
|
bsw@988
|
107
|
bsw@988
|
108
|
bsw@988
|
109 slot.put("<br />")
|
bsw@988
|
110
|
bsw@999
|
111 ui.submit{ text = _"Finish delegation check" }
|
bsw@988
|
112
|
bsw@988
|
113 end
|
bsw@988
|
114 }
|