rev |
line source |
bsw@211
|
1 local area = param.get("area", "table")
|
bsw@211
|
2
|
bsw@211
|
3 local membership = Membership:by_pk(area.id, app.session.member_id)
|
bsw@211
|
4
|
bsw@211
|
5 local trustees = Member:new_selector()
|
bsw@211
|
6 :add_field("delegation_chain.*")
|
bsw@211
|
7 :join("delegation_chain(" .. app.session.member_id .. ", " .. area.id .. ", NULL)", "delegation_chain", "member.id = delegation_chain.member_id")
|
bsw@211
|
8 :add_order_by("index")
|
bsw@211
|
9 :exec()
|
bsw@211
|
10
|
bsw@211
|
11 ui.box{ class = "area", content = function()
|
bsw@211
|
12
|
bsw@211
|
13 ui.box_row{ class = "head", content = function()
|
bsw@212
|
14 ui.box_col{ class = "head left name", content = area.name }
|
bsw@212
|
15 ui.box_col{ class = "right", content = _("#{direct_count}+#{delegated_count} members", {
|
bsw@211
|
16 direct_count = area.direct_member_count,
|
bsw@211
|
17 delegated_count = area.member_weight - area.direct_member_count
|
bsw@211
|
18 } ) }
|
bsw@211
|
19 end }
|
bsw@211
|
20
|
bsw@211
|
21 if area.description and #area.description > 0 then
|
bsw@211
|
22 ui.box_row{ class = "description", content = function() ui.box_col{ content = area.description } end }
|
bsw@211
|
23 end
|
bsw@211
|
24
|
bsw@212
|
25 if #trustees > 1 then
|
bsw@212
|
26 ui.box_row{ content = function()
|
bsw@212
|
27 ui.box_col{ class = "left", content = function()
|
bsw@212
|
28 execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small" } }
|
bsw@212
|
29 end }
|
bsw@212
|
30 if trustees[1].scope_out == "area" then
|
bsw@212
|
31 text = _"Change or revoke area delegation..."
|
bsw@212
|
32 else
|
bsw@212
|
33 text = _"Set area delegation..."
|
bsw@212
|
34 end
|
bsw@212
|
35 ui.box_col{ class = "right", content = function()
|
bsw@212
|
36 ui.link{
|
bsw@212
|
37 text = text,
|
bsw@212
|
38 module = "lf2", view = "delegation", params = { area_id = area.id }
|
bsw@212
|
39 }
|
bsw@212
|
40 end }
|
bsw@211
|
41 end }
|
bsw@212
|
42 end
|
bsw@211
|
43
|
bsw@211
|
44 ui.box_row{ content = function()
|
bsw@211
|
45 ui.box_col{ class = "left", content = function()
|
bsw@211
|
46 if membership then
|
bsw@211
|
47 ui.image{ static = "lf2/icon_star.png" }
|
bsw@211
|
48 slot.put(" ", _"You are member of this area")
|
bsw@211
|
49 else
|
bsw@211
|
50 ui.link{
|
bsw@211
|
51 module = "membership", action = "update", params = { area_id = area.id },
|
bsw@211
|
52 routing = { default = {
|
bsw@211
|
53 mode = "redirect", module = "lf2", view = "area", id = area.id
|
bsw@211
|
54 } },
|
bsw@211
|
55 text = _"Become a member of this area"
|
bsw@211
|
56 }
|
bsw@211
|
57 end
|
bsw@211
|
58 end }
|
bsw@211
|
59 ui.box_col{ class = "right", content = function()
|
bsw@211
|
60 if membership then
|
bsw@211
|
61 ui.link{
|
bsw@211
|
62 module = "membership", action = "update", params = { area_id = area.id, delete = true },
|
bsw@211
|
63 routing = { default = {
|
bsw@211
|
64 mode = "redirect", module = "lf2", view = "area", id = area.id
|
bsw@211
|
65 } },
|
bsw@211
|
66 text = _"Give up membership"
|
bsw@211
|
67 }
|
bsw@211
|
68 end
|
bsw@212
|
69 if #trustees == 1 then
|
bsw@211
|
70 if membership then
|
bsw@211
|
71 slot.put(" · ")
|
bsw@211
|
72 end
|
bsw@212
|
73 ui.link{
|
bsw@212
|
74 text = _"Set area delegation...",
|
bsw@212
|
75 module = "lf2", view = "delegation", params = { area_id = area.id }
|
bsw@212
|
76 }
|
bsw@211
|
77 end
|
bsw@211
|
78 end }
|
bsw@211
|
79 end }
|
bsw@211
|
80
|
bsw@211
|
81 end } |