rev |
line source |
bsw@273
|
1 local units = app.session.member.units_with_voting_right
|
bsw@273
|
2 local member = param.get("member", "table")
|
bsw@273
|
3 for i, unit in ipairs(units) do
|
bsw@375
|
4 local trustee_member = Member:new_selector()
|
bsw@375
|
5 :join("delegation", nil, { "delegation.unit_id = ? AND delegation.truster_id = ?", unit.id, member.id })
|
bsw@375
|
6 :optional_object_mode()
|
bsw@375
|
7 :exec()
|
bsw@375
|
8
|
bsw@273
|
9 local areas_selector = Area:new_selector()
|
bsw@273
|
10 :join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id })
|
bsw@273
|
11 :add_where{ "area.unit_id = ?", unit.id }
|
bsw@273
|
12 :add_order_by("area.member_weight DESC")
|
bsw@273
|
13
|
bsw@280
|
14 local area_count = areas_selector:count()
|
bsw@375
|
15
|
bsw@375
|
16 ui.container{ attr = { class = "member_area_list" }, content = function()
|
bsw@375
|
17 ui.container{ attr = { class = "unit_head" }, content = function()
|
bsw@375
|
18 ui.link{
|
bsw@375
|
19 text = unit.name,
|
bsw@375
|
20 module = "unit", view = "show", id = unit.id
|
bsw@375
|
21 }
|
bsw@280
|
22
|
bsw@375
|
23 if trustee_member then
|
bsw@375
|
24 local text = _("Unit delegated to '#{name}'", { name = trustee_member.name })
|
bsw@375
|
25 ui.image{
|
bsw@375
|
26 attr = { class = "delegation_arrow", alt = text, title = text },
|
bsw@375
|
27 static = "delegation_arrow_24_horizontal.png"
|
bsw@375
|
28 }
|
bsw@375
|
29 execute.view{
|
bsw@375
|
30 module = "member_image",
|
bsw@375
|
31 view = "_show",
|
bsw@375
|
32 params = {
|
bsw@375
|
33 member = trustee_member,
|
bsw@375
|
34 image_type = "avatar",
|
bsw@375
|
35 show_dummy = true,
|
bsw@375
|
36 class = "micro_avatar",
|
bsw@375
|
37 popup_text = text
|
bsw@375
|
38 }
|
bsw@375
|
39 }
|
bsw@375
|
40 end
|
bsw@375
|
41 end }
|
bsw@375
|
42
|
bsw@375
|
43 if area_count > 0 then
|
bsw@375
|
44 execute.view{
|
bsw@375
|
45 module = "area", view = "_list",
|
bsw@375
|
46 params = { areas_selector = areas_selector, hide_membership = true }
|
bsw@375
|
47 }
|
bsw@375
|
48 else
|
bsw@375
|
49 ui.tag{ content = _"You have voting privileges for this unit, but you are not member of any of its areas." }
|
bsw@375
|
50 slot.put(" ")
|
bsw@375
|
51 ui.link{
|
bsw@375
|
52 text = _"Show all areas of this unit",
|
bsw@375
|
53 module = "unit", view = "show", id = unit.id
|
bsw@375
|
54 }
|
bsw@375
|
55 end
|
bsw@375
|
56 end }
|
bsw@274
|
57
|
bsw@273
|
58 end
|
bsw@273
|
59
|