rev |
line source |
bsw@395
|
1 local member = param.get("member", "table")
|
bsw@472
|
2 local for_member = param.get("for_member", atom.boolean)
|
bsw@525
|
3 local filter_unit = param.get_all_cgi()["filter_unit"] or "personal"
|
bsw@472
|
4
|
bsw@525
|
5 ui.container{ attr = { class = "ui_filter_head" }, content = function()
|
bsw@525
|
6
|
bsw@525
|
7 ui.link{
|
bsw@525
|
8 attr = { class = filter_unit == "personal" and "ui_tabs_link active" or nil },
|
bsw@525
|
9 text = _"With voting right",
|
bsw@525
|
10 module = "index", view = "index", params = { filter_unit = "personal" }
|
bsw@525
|
11 }
|
bsw@525
|
12
|
bsw@525
|
13 slot.put(" ")
|
bsw@525
|
14
|
bsw@525
|
15 ui.link{
|
bsw@525
|
16 attr = { class = filter_unit == "global" and "active" or nil },
|
bsw@525
|
17 text = _"All units",
|
bsw@525
|
18 module = "index", view = "index", params = { filter_unit = "global" }
|
bsw@525
|
19 }
|
bsw@525
|
20 end }
|
bsw@525
|
21
|
bsw@525
|
22 slot.put("<br />")
|
bsw@525
|
23
|
bsw@525
|
24
|
bsw@525
|
25 if filter_unit == "global" then
|
bsw@525
|
26 execute.view{ module = "unit", view = "_list" }
|
bsw@525
|
27 return
|
bsw@525
|
28 end
|
bsw@525
|
29
|
bsw@525
|
30 local units = Unit:new_selector():exec()
|
bsw@395
|
31
|
bsw@273
|
32 for i, unit in ipairs(units) do
|
bsw@375
|
33 local trustee_member = Member:new_selector()
|
bsw@417
|
34 :join("delegation", nil, { "delegation.scope = 'unit' AND delegation.unit_id = ? AND delegation.trustee_id = member.id AND delegation.truster_id = ?", unit.id, member.id })
|
bsw@375
|
35 :optional_object_mode()
|
bsw@375
|
36 :exec()
|
bsw@375
|
37
|
bsw@273
|
38 local areas_selector = Area:new_selector()
|
bsw@273
|
39 :join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id })
|
bsw@273
|
40 :add_where{ "area.unit_id = ?", unit.id }
|
bsw@424
|
41 :add_where{ "area.active" }
|
bsw@273
|
42 :add_order_by("area.member_weight DESC")
|
bsw@273
|
43
|
bsw@280
|
44 local area_count = areas_selector:count()
|
bsw@375
|
45
|
bsw@375
|
46 ui.container{ attr = { class = "member_area_list" }, content = function()
|
bsw@525
|
47 ui.container{ attr = { class = "xunit_head" }, content = function()
|
bsw@375
|
48 ui.link{
|
bsw@375
|
49 text = unit.name,
|
bsw@375
|
50 module = "unit", view = "show", id = unit.id
|
bsw@375
|
51 }
|
bsw@280
|
52
|
bsw@375
|
53 if trustee_member then
|
bsw@375
|
54 local text = _("Unit delegated to '#{name}'", { name = trustee_member.name })
|
bsw@375
|
55 ui.image{
|
bsw@375
|
56 attr = { class = "delegation_arrow", alt = text, title = text },
|
bsw@375
|
57 static = "delegation_arrow_24_horizontal.png"
|
bsw@375
|
58 }
|
bsw@375
|
59 execute.view{
|
bsw@375
|
60 module = "member_image",
|
bsw@375
|
61 view = "_show",
|
bsw@375
|
62 params = {
|
bsw@375
|
63 member = trustee_member,
|
bsw@375
|
64 image_type = "avatar",
|
bsw@375
|
65 show_dummy = true,
|
bsw@375
|
66 class = "micro_avatar",
|
bsw@375
|
67 popup_text = text
|
bsw@375
|
68 }
|
bsw@375
|
69 }
|
bsw@375
|
70 end
|
bsw@375
|
71 end }
|
bsw@375
|
72
|
bsw@375
|
73 if area_count > 0 then
|
bsw@375
|
74 execute.view{
|
bsw@375
|
75 module = "area", view = "_list",
|
bsw@375
|
76 params = { areas_selector = areas_selector, hide_membership = true }
|
bsw@375
|
77 }
|
bsw@525
|
78 elseif member:has_voting_right_for_unit_id(unit.id) then
|
bsw@472
|
79 if for_member then
|
bsw@472
|
80 ui.container{ attr = { class = "voting_priv_info" }, content = _"This member has voting privileges for this unit, but you ist not member of any of its areas." }
|
bsw@472
|
81 else
|
bsw@472
|
82 ui.container{ attr = { class = "voting_priv_info" }, content = _"You have voting privileges for this unit, but you are not member of any of its areas." }
|
bsw@472
|
83 end
|
bsw@375
|
84 end
|
bsw@424
|
85 local max_area_count = Area:new_selector()
|
bsw@424
|
86 :add_where{ "area.unit_id = ?", unit.id }
|
bsw@424
|
87 :add_where{ "area.active" }
|
bsw@424
|
88 :count()
|
bsw@424
|
89 local more_area_count = max_area_count - area_count
|
bsw@424
|
90 local delegated_count = Area:new_selector()
|
bsw@424
|
91 :add_where{ "area.unit_id = ?", unit.id }
|
bsw@424
|
92 :add_where{ "area.active" }
|
bsw@424
|
93 :left_join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id } )
|
bsw@424
|
94 :add_where{ "membership.member_id ISNULL" }
|
bsw@424
|
95 :join("delegation", nil, { "delegation.area_id = area.id AND delegation.truster_id = ?", member.id } )
|
bsw@424
|
96 :count()
|
bsw@424
|
97 if more_area_count > 0 then
|
bsw@424
|
98 slot.put("<br />")
|
bsw@447
|
99 ui.container{ attr = { class = "more_areas" }, content = function()
|
bsw@472
|
100 ui.link{ content = _("#{count} more areas in this unit, #{delegated_count} of them are delegated", { count = more_area_count, delegated_count = delegated_count }), module = "unit", view = "show", id = unit.id }
|
bsw@424
|
101 end }
|
bsw@424
|
102 end
|
bsw@375
|
103 end }
|
bsw@414
|
104
|
bsw@273
|
105 end
|
bsw@525
|
106
|
bsw@525
|
107
|