rev |
line source |
bsw@525
|
1 local unit = param.get("unit", "table")
|
bsw@525
|
2 local area = param.get("area", "table")
|
bsw@525
|
3 local issue = param.get("issue", "table")
|
bsw@525
|
4
|
bsw@525
|
5 local unit_id = unit and unit.id or nil
|
bsw@525
|
6 local area_id = area and area.id or nil
|
bsw@525
|
7 local issue_id = issue and issue.id or nil
|
bsw@525
|
8
|
bsw@525
|
9 local info
|
bsw@525
|
10 local delegation_text
|
bsw@525
|
11
|
bsw@525
|
12 if unit then
|
bsw@525
|
13 unit:load_delegation_info_once_for_member_id(app.session.member_id)
|
bsw@525
|
14 info = unit.delegation_info
|
bsw@525
|
15 delegation_text = _"Delegate unit"
|
bsw@525
|
16 end
|
bsw@525
|
17
|
bsw@525
|
18 if area then
|
bsw@525
|
19 area:load_delegation_info_once_for_member_id(app.session.member_id)
|
bsw@525
|
20 info = area.delegation_info
|
bsw@525
|
21 delegation_text = _"Delegate area"
|
bsw@525
|
22 end
|
bsw@525
|
23
|
bsw@525
|
24 if issue then
|
bsw@525
|
25 issue:load_delegation_info_once_for_member_id(app.session.member_id)
|
bsw@525
|
26 info = issue.delegation_info
|
bsw@525
|
27 delegation_text = _"Delegate issue"
|
bsw@525
|
28 end
|
bsw@525
|
29
|
bsw@525
|
30 ui.link{
|
bsw@525
|
31 module = "delegation", view = "show", params = {
|
bsw@525
|
32 unit_id = unit_id,
|
bsw@525
|
33 area_id = area_id,
|
bsw@525
|
34 issue_id = issue_id
|
bsw@525
|
35 },
|
bsw@525
|
36 attr = { class = "delegation_info" }, content = function()
|
bsw@525
|
37
|
bsw@525
|
38
|
bsw@525
|
39 local participant_occured = false
|
bsw@525
|
40
|
bsw@525
|
41 if info.own_participation or info.first_trustee_id then
|
bsw@525
|
42
|
bsw@525
|
43 local class = "micro_avatar"
|
bsw@525
|
44 if info.own_participation then
|
bsw@525
|
45 participant_occured = true
|
bsw@525
|
46 class = class .. " highlighted"
|
bsw@525
|
47 end
|
bsw@525
|
48
|
bsw@525
|
49 execute.view{ module = "member_image", view = "_show", params = {
|
bsw@525
|
50 member = app.session.member, class = class, popup_text = app.session.member.name,
|
bsw@525
|
51 image_type = "avatar", show_dummy = true,
|
bsw@525
|
52 } }
|
bsw@525
|
53
|
bsw@525
|
54 end
|
bsw@525
|
55
|
bsw@525
|
56 if not info.first_trustee_id and (not issue or not issue.closed) then
|
bsw@525
|
57 slot.put(" ")
|
bsw@525
|
58 ui.tag{ attr = { class = "link" }, content = delegation_text }
|
bsw@525
|
59 end
|
bsw@525
|
60
|
bsw@525
|
61 if not (issue and issue.state == "voting" and info.own_participation) then
|
bsw@525
|
62
|
bsw@525
|
63 if info.first_trustee_id then
|
bsw@525
|
64
|
bsw@525
|
65 local text = _"delegates to"
|
bsw@525
|
66 ui.image{
|
bsw@525
|
67 attr = { class = "delegation_arrow", alt = text, title = text },
|
bsw@525
|
68 static = "delegation_arrow_24_horizontal.png"
|
bsw@525
|
69 }
|
bsw@525
|
70
|
bsw@525
|
71 local class = "micro_avatar"
|
bsw@525
|
72 if not participant_occured and info.first_trustee_participation then
|
bsw@525
|
73 participant_occured = true
|
bsw@525
|
74 class = class .. " highlighted"
|
bsw@525
|
75 end
|
bsw@525
|
76
|
bsw@525
|
77 execute.view{ module = "member_image", view = "_show", params = {
|
bsw@525
|
78 member_id = info.first_trustee_id, class = class, popup_text = info.first_trustee_name,
|
bsw@525
|
79 image_type = "avatar", show_dummy = true,
|
bsw@525
|
80 } }
|
bsw@525
|
81
|
bsw@525
|
82 end
|
bsw@525
|
83
|
bsw@525
|
84 if info.first_trustee_ellipsis then
|
bsw@525
|
85
|
bsw@525
|
86 local text = _"delegates to"
|
bsw@525
|
87 ui.image{
|
bsw@525
|
88 attr = { class = "delegation_arrow", alt = text, title = text },
|
bsw@525
|
89 static = "delegation_arrow_24_horizontal.png"
|
bsw@525
|
90 }
|
bsw@525
|
91
|
bsw@525
|
92 slot.put("...")
|
bsw@525
|
93
|
bsw@525
|
94 end
|
bsw@525
|
95
|
bsw@525
|
96 if info.other_trustee_id then
|
bsw@525
|
97
|
bsw@525
|
98 local text = _"delegates to"
|
bsw@525
|
99 ui.image{
|
bsw@525
|
100 attr = { class = "delegation_arrow", alt = text, title = text },
|
bsw@525
|
101 static = "delegation_arrow_24_horizontal.png"
|
bsw@525
|
102 }
|
bsw@525
|
103
|
bsw@525
|
104 local class = "micro_avatar"
|
bsw@525
|
105 if not participant_occured and info.other_trustee_participation then
|
bsw@525
|
106 participant_occured = true
|
bsw@525
|
107 class = class .. " highlighted"
|
bsw@525
|
108 end
|
bsw@525
|
109
|
bsw@525
|
110 execute.view{ module = "member_image", view = "_show", params = {
|
bsw@525
|
111 member_id = info.other_trustee_id, class = class, popup_text = info.other_trustee_name,
|
bsw@525
|
112 image_type = "avatar", show_dummy = true,
|
bsw@525
|
113 } }
|
bsw@525
|
114
|
bsw@525
|
115 end
|
bsw@525
|
116
|
bsw@525
|
117 if info.other_trustee_ellipsis then
|
bsw@525
|
118
|
bsw@525
|
119 local text = _"delegates to"
|
bsw@525
|
120 ui.image{
|
bsw@525
|
121 attr = { class = "delegation_arrow", alt = text, title = text },
|
bsw@525
|
122 static = "delegation_arrow_24_horizontal.png"
|
bsw@525
|
123 }
|
bsw@525
|
124
|
bsw@525
|
125 slot.put("...")
|
bsw@525
|
126
|
bsw@525
|
127 end
|
bsw@525
|
128
|
bsw@525
|
129 local trailing_ellipsis = info.other_trustee_ellipsis or
|
bsw@525
|
130 (info.first_trustee_ellipsis and not info.other_trustee_id)
|
bsw@525
|
131
|
bsw@525
|
132 if info.delegation_loop == "own" then
|
bsw@525
|
133
|
bsw@525
|
134 local text = _"delegates to"
|
bsw@525
|
135 ui.image{
|
bsw@525
|
136 attr = { class = "delegation_arrow", alt = text, title = text },
|
bsw@525
|
137 static = "delegation_arrow_24_horizontal.png"
|
bsw@525
|
138 }
|
bsw@525
|
139
|
bsw@525
|
140 execute.view{ module = "member_image", view = "_show", params = {
|
bsw@525
|
141 member = app.session.member, class = "micro_avatar", popup_text = app.session.member.name,
|
bsw@525
|
142 image_type = "avatar", show_dummy = true,
|
bsw@525
|
143 } }
|
bsw@525
|
144
|
bsw@525
|
145 elseif info.delegation_loop == "first" then
|
bsw@525
|
146 if info.first_trustee_ellipsis then
|
bsw@525
|
147 if not trailing_ellipsis then
|
bsw@525
|
148
|
bsw@525
|
149 local text = _"delegates to"
|
bsw@525
|
150 ui.image{
|
bsw@525
|
151 attr = { class = "delegation_arrow", alt = text, title = text },
|
bsw@525
|
152 static = "delegation_arrow_24_horizontal.png"
|
bsw@525
|
153 }
|
bsw@525
|
154
|
bsw@525
|
155 slot.put("...")
|
bsw@525
|
156 end
|
bsw@525
|
157
|
bsw@525
|
158 else
|
bsw@525
|
159
|
bsw@525
|
160 local text = _"delegates to"
|
bsw@525
|
161 ui.image{
|
bsw@525
|
162 attr = { class = "delegation_arrow", alt = text, title = text },
|
bsw@525
|
163 static = "delegation_arrow_24_horizontal.png"
|
bsw@525
|
164 }
|
bsw@525
|
165
|
bsw@525
|
166 execute.view{ module = "member_image", view = "_show", params = {
|
bsw@525
|
167 member_id = info.first_trustee_id, class = "micro_avatar", popup_text = info.first_trustee_name,
|
bsw@525
|
168 image_type = "avatar", show_dummy = true,
|
bsw@525
|
169 } }
|
bsw@525
|
170 end
|
bsw@525
|
171
|
bsw@525
|
172
|
bsw@525
|
173 elseif info.delegation_loop and not trailing_ellipsis then
|
bsw@525
|
174 local text = _"delegates to"
|
bsw@525
|
175 ui.image{
|
bsw@525
|
176 attr = { class = "delegation_arrow", alt = text, title = text },
|
bsw@525
|
177 static = "delegation_arrow_24_horizontal.png"
|
bsw@525
|
178 }
|
bsw@525
|
179
|
bsw@525
|
180 slot.put("...")
|
bsw@525
|
181 end
|
bsw@525
|
182
|
bsw@525
|
183 end
|
bsw@525
|
184
|
bsw@525
|
185 end
|
bsw@525
|
186
|
bsw@525
|
187 }
|
bsw@525
|
188
|