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