| 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@1045
 | 
    11 local for_title = param.get("for_title", "boolean")
 | 
| 
bsw@1045
 | 
    12 
 | 
| 
bsw@525
 | 
    13 local unit_id  = unit  and unit.id  or nil
 | 
| 
bsw@525
 | 
    14 local area_id  = area  and area.id  or nil
 | 
| 
bsw@525
 | 
    15 local issue_id = issue and issue.id or nil
 | 
| 
bsw@525
 | 
    16 
 | 
| 
bsw@525
 | 
    17 local info
 | 
| 
bsw@525
 | 
    18 local delegation_text
 | 
| 
bsw@525
 | 
    19 
 | 
| 
bsw@525
 | 
    20 if unit then
 | 
| 
bsw@525
 | 
    21   info = unit.delegation_info
 | 
| 
bsw@525
 | 
    22   delegation_text = _"Delegate unit"
 | 
| 
bsw@525
 | 
    23 end
 | 
| 
bsw@525
 | 
    24 
 | 
| 
bsw@525
 | 
    25 if area then
 | 
| 
bsw@525
 | 
    26   info = area.delegation_info
 | 
| 
bsw@525
 | 
    27   delegation_text = _"Delegate area"
 | 
| 
bsw@525
 | 
    28 end
 | 
| 
bsw@525
 | 
    29 
 | 
| 
bsw@525
 | 
    30 if issue then
 | 
| 
bsw@774
 | 
    31   info = issue.member_info
 | 
| 
bsw@525
 | 
    32   delegation_text = _"Delegate issue"
 | 
| 
bsw@525
 | 
    33 end
 | 
| 
bsw@525
 | 
    34 
 | 
| 
bsw@1045
 | 
    35 if not info then
 | 
| 
bsw@1045
 | 
    36   --return
 | 
| 
bsw@1045
 | 
    37 end
 | 
| 
bsw@1045
 | 
    38 
 | 
| 
bsw@780
 | 
    39 local function print_delegation_info()
 | 
| 
bsw@1045
 | 
    40   local participant_occured = info.own_participation
 | 
| 
bsw@780
 | 
    41   
 | 
| 
bsw@780
 | 
    42   if not (issue and issue.state == "voting" and info.own_participation) then
 | 
| 
bsw@780
 | 
    43     
 | 
| 
bsw@780
 | 
    44     if info.first_trustee_id then
 | 
| 
bsw@780
 | 
    45     
 | 
| 
bsw@780
 | 
    46       local text = _"delegates to"
 | 
| 
bsw@780
 | 
    47       ui.image{
 | 
| 
bsw@780
 | 
    48         attr = { class = "delegation_arrow", alt = text, title = text },
 | 
| 
bsw@780
 | 
    49         static = "delegation_arrow_24_horizontal.png"
 | 
| 
bsw@780
 | 
    50       }
 | 
| 
bsw@780
 | 
    51 
 | 
| 
bsw@780
 | 
    52       local class = "micro_avatar"
 | 
| 
bsw@780
 | 
    53       if not participant_occured and info.first_trustee_participation then
 | 
| 
bsw@780
 | 
    54         participant_occured = true
 | 
| 
bsw@780
 | 
    55         class = class .. " highlighted"
 | 
| 
bsw@780
 | 
    56       end
 | 
| 
bsw@525
 | 
    57       
 | 
| 
bsw@780
 | 
    58       execute.view{ module = "member_image", view = "_show", params = {
 | 
| 
bsw@780
 | 
    59         member_id = info.first_trustee_id, class = class, popup_text = info.first_trustee_name,
 | 
| 
bsw@780
 | 
    60         image_type = "avatar", show_dummy = true,
 | 
| 
bsw@780
 | 
    61       } }
 | 
| 
bsw@780
 | 
    62 
 | 
| 
bsw@780
 | 
    63     end
 | 
| 
bsw@780
 | 
    64           
 | 
| 
bsw@780
 | 
    65     if info.first_trustee_ellipsis then
 | 
| 
bsw@780
 | 
    66 
 | 
| 
bsw@780
 | 
    67       local text = _"delegates to"
 | 
| 
bsw@780
 | 
    68       ui.image{
 | 
| 
bsw@780
 | 
    69         attr = { class = "delegation_arrow", alt = text, title = text },
 | 
| 
bsw@780
 | 
    70         static = "delegation_arrow_24_horizontal.png"
 | 
| 
bsw@780
 | 
    71       }
 | 
| 
bsw@525
 | 
    72 
 | 
| 
bsw@780
 | 
    73       slot.put("...")
 | 
| 
bsw@780
 | 
    74       
 | 
| 
bsw@780
 | 
    75     end
 | 
| 
bsw@780
 | 
    76     
 | 
| 
bsw@780
 | 
    77     if info.other_trustee_id then
 | 
| 
bsw@780
 | 
    78     
 | 
| 
bsw@780
 | 
    79       local text = _"delegates to"
 | 
| 
bsw@780
 | 
    80       ui.image{
 | 
| 
bsw@780
 | 
    81         attr = { class = "delegation_arrow", alt = text, title = text },
 | 
| 
bsw@780
 | 
    82         static = "delegation_arrow_24_horizontal.png"
 | 
| 
bsw@780
 | 
    83       }
 | 
| 
bsw@525
 | 
    84 
 | 
| 
bsw@780
 | 
    85       local class = "micro_avatar"
 | 
| 
bsw@780
 | 
    86       if not participant_occured and info.other_trustee_participation then
 | 
| 
bsw@780
 | 
    87         participant_occured = true
 | 
| 
bsw@780
 | 
    88         class = class .. " highlighted"
 | 
| 
bsw@780
 | 
    89       end
 | 
| 
bsw@780
 | 
    90       
 | 
| 
bsw@780
 | 
    91       execute.view{ module = "member_image", view = "_show", params = {
 | 
| 
bsw@780
 | 
    92         member_id = info.other_trustee_id, class = class, popup_text = info.other_trustee_name,
 | 
| 
bsw@780
 | 
    93         image_type = "avatar", show_dummy = true,
 | 
| 
bsw@780
 | 
    94       } }
 | 
| 
bsw@780
 | 
    95 
 | 
| 
bsw@780
 | 
    96     end
 | 
| 
bsw@780
 | 
    97           
 | 
| 
bsw@780
 | 
    98     if info.other_trustee_ellipsis then
 | 
| 
bsw@525
 | 
    99 
 | 
| 
bsw@780
 | 
   100       local text = _"delegates to"
 | 
| 
bsw@780
 | 
   101       ui.image{
 | 
| 
bsw@780
 | 
   102         attr = { class = "delegation_arrow", alt = text, title = text },
 | 
| 
bsw@780
 | 
   103         static = "delegation_arrow_24_horizontal.png"
 | 
| 
bsw@780
 | 
   104       }
 | 
| 
bsw@529
 | 
   105 
 | 
| 
bsw@780
 | 
   106       slot.put("...")
 | 
| 
bsw@780
 | 
   107       
 | 
| 
bsw@780
 | 
   108     end
 | 
| 
bsw@780
 | 
   109     
 | 
| 
bsw@780
 | 
   110     local trailing_ellipsis = info.other_trustee_ellipsis or
 | 
| 
bsw@780
 | 
   111       (info.first_trustee_ellipsis and not info.other_trustee_id)
 | 
| 
bsw@780
 | 
   112     
 | 
| 
bsw@780
 | 
   113     if info.delegation_loop == "own" then
 | 
| 
bsw@780
 | 
   114       
 | 
| 
bsw@780
 | 
   115       local text = _"delegates to"
 | 
| 
bsw@780
 | 
   116       ui.image{
 | 
| 
bsw@780
 | 
   117         attr = { class = "delegation_arrow", alt = text, title = text },
 | 
| 
bsw@780
 | 
   118         static = "delegation_arrow_24_horizontal.png"
 | 
| 
bsw@780
 | 
   119       }
 | 
| 
bsw@780
 | 
   120 
 | 
| 
bsw@780
 | 
   121       execute.view{ module = "member_image", view = "_show", params = {
 | 
| 
bsw@780
 | 
   122         member = member, class = "micro_avatar", popup_text = member.name,
 | 
| 
bsw@780
 | 
   123         image_type = "avatar", show_dummy = true,
 | 
| 
bsw@780
 | 
   124       } }
 | 
| 
bsw@780
 | 
   125 
 | 
| 
bsw@780
 | 
   126     elseif info.delegation_loop == "first" then
 | 
| 
bsw@780
 | 
   127       if info.first_trustee_ellipsis then
 | 
| 
bsw@780
 | 
   128         if not trailing_ellipsis then
 | 
| 
bsw@529
 | 
   129 
 | 
| 
bsw@529
 | 
   130           local text = _"delegates to"
 | 
| 
bsw@529
 | 
   131           ui.image{
 | 
| 
bsw@529
 | 
   132             attr = { class = "delegation_arrow", alt = text, title = text },
 | 
| 
bsw@529
 | 
   133             static = "delegation_arrow_24_horizontal.png"
 | 
| 
bsw@529
 | 
   134           }
 | 
| 
bsw@529
 | 
   135 
 | 
| 
bsw@529
 | 
   136           slot.put("...")
 | 
| 
bsw@780
 | 
   137         end
 | 
| 
bsw@529
 | 
   138           
 | 
| 
bsw@780
 | 
   139       else
 | 
| 
bsw@529
 | 
   140           
 | 
| 
bsw@780
 | 
   141         local text = _"delegates to"
 | 
| 
bsw@780
 | 
   142         ui.image{
 | 
| 
bsw@780
 | 
   143           attr = { class = "delegation_arrow", alt = text, title = text },
 | 
| 
bsw@780
 | 
   144           static = "delegation_arrow_24_horizontal.png"
 | 
| 
bsw@780
 | 
   145         }
 | 
| 
bsw@525
 | 
   146 
 | 
| 
bsw@1045
 | 
   147         execute.view{
 | 
| 
bsw@1045
 | 
   148           module = "member_image", view = "_show", params = {
 | 
| 
bsw@1045
 | 
   149             member_id = info.first_trustee_id, 
 | 
| 
bsw@1045
 | 
   150             class = "micro_avatar", 
 | 
| 
bsw@1045
 | 
   151             popup_text = info.first_trustee_name,
 | 
| 
bsw@1045
 | 
   152             image_type = "avatar",
 | 
| 
bsw@1045
 | 
   153             show_dummy = true,
 | 
| 
bsw@1045
 | 
   154           }
 | 
| 
bsw@1045
 | 
   155         }
 | 
| 
bsw@780
 | 
   156       end
 | 
| 
bsw@780
 | 
   157     
 | 
| 
bsw@529
 | 
   158         
 | 
| 
bsw@780
 | 
   159     elseif info.delegation_loop and not trailing_ellipsis then
 | 
| 
bsw@780
 | 
   160       local text = _"delegates to"
 | 
| 
bsw@780
 | 
   161       ui.image{
 | 
| 
bsw@780
 | 
   162         attr = { class = "delegation_arrow", alt = text, title = text },
 | 
| 
bsw@780
 | 
   163         static = "delegation_arrow_24_horizontal.png"
 | 
| 
bsw@780
 | 
   164       }
 | 
| 
bsw@525
 | 
   165 
 | 
| 
bsw@780
 | 
   166       slot.put("...")
 | 
| 
bsw@780
 | 
   167     end
 | 
| 
bsw@529
 | 
   168 
 | 
| 
bsw@780
 | 
   169   end
 | 
| 
bsw@780
 | 
   170 end
 | 
| 
bsw@529
 | 
   171 
 | 
| 
bsw@1045
 | 
   172 if not param.get("no_star", "boolean") then
 | 
| 
bsw@1045
 | 
   173   
 | 
| 
bsw@1045
 | 
   174   if info.own_participation then
 | 
| 
bsw@1045
 | 
   175     if issue and issue.fully_frozen then
 | 
| 
bsw@1045
 | 
   176       ui.link{
 | 
| 
bsw/jbe@1309
 | 
   177         attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
 | 
| 
bsw@1045
 | 
   178         module = "vote", view = "list", params = {
 | 
| 
bsw@1045
 | 
   179           issue_id = issue.id
 | 
| 
bsw@1045
 | 
   180         },
 | 
| 
bsw@1045
 | 
   181         content = function ()
 | 
| 
bsw@1045
 | 
   182           ui.tag { content = _"you voted" }
 | 
| 
bsw@1045
 | 
   183         end
 | 
| 
bsw@1045
 | 
   184       }
 | 
| 
bsw@1045
 | 
   185     else
 | 
| 
bsw@1045
 | 
   186       if issue then
 | 
| 
bsw/jbe@1309
 | 
   187         ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "star" }
 | 
| 
bsw/jbe@1309
 | 
   188         slot.put(" ")
 | 
| 
bsw/jbe@1309
 | 
   189         ui.tag{ content = _"you are interested" }
 | 
| 
bsw@1045
 | 
   190         if not issue.closed and info.own_participation and info.weight and info.weight > 1 then
 | 
| 
bsw@1045
 | 
   191           ui.link { 
 | 
| 
bsw@1045
 | 
   192             attr = { class = "right" }, content = "+" .. (info.weight - 1),
 | 
| 
bsw@1045
 | 
   193             module = "delegation", view = "show_incoming", params = { 
 | 
| 
bsw@1045
 | 
   194               issue_id = issue.id, member_id = member.id
 | 
| 
bsw@1045
 | 
   195             }
 | 
| 
bsw@1045
 | 
   196           }
 | 
| 
bsw@1045
 | 
   197         end
 | 
| 
bsw@1045
 | 
   198       else
 | 
| 
bsw@1045
 | 
   199         local text = _"you are subscribed"
 | 
| 
bsw@1045
 | 
   200         ui.image { attr = { class = "icon24 star", title = text, alt = text }, static = "icons/48/star.png" }
 | 
| 
bsw@1045
 | 
   201       end
 | 
| 
bsw/jbe@1309
 | 
   202       slot.put(" ")
 | 
| 
bsw@1045
 | 
   203     end
 | 
| 
bsw@1045
 | 
   204   end
 | 
| 
bsw@1045
 | 
   205 end
 | 
| 
bsw@1045
 | 
   206 
 | 
| 
bsw@529
 | 
   207 
 | 
| 
bsw@780
 | 
   208 if info.own_participation or info.first_trustee_id then
 | 
| 
bsw@1045
 | 
   209   local class = "delegation_info"
 | 
| 
bsw@1045
 | 
   210   if info.own_participation then
 | 
| 
bsw@1045
 | 
   211     class = class .. " suspended"
 | 
| 
bsw@1045
 | 
   212   end
 | 
| 
bsw@1045
 | 
   213 
 | 
| 
bsw@1045
 | 
   214   local voting_member_id
 | 
| 
bsw@1045
 | 
   215   local voting_member_name
 | 
| 
bsw@1045
 | 
   216   if issue and issue.fully_frozen and issue.closed then
 | 
| 
bsw@1045
 | 
   217     if issue.member_info.first_trustee_participation then
 | 
| 
bsw@1045
 | 
   218       voting_member_id = issue.member_info.first_trustee_id
 | 
| 
bsw@1045
 | 
   219       voting_member_name = issue.member_info.first_trustee_name
 | 
| 
bsw@1045
 | 
   220     elseif issue.member_info.other_trustee_participation then
 | 
| 
bsw@1045
 | 
   221       voting_member_id = issue.member_info.other_trustee_id
 | 
| 
bsw@1045
 | 
   222       voting_member_name = issue.member_info.other_trustee_name
 | 
| 
bsw@1045
 | 
   223     end
 | 
| 
bsw@1045
 | 
   224   end
 | 
| 
bsw@1045
 | 
   225   
 | 
| 
bsw@780
 | 
   226   if app.session.member_id == member.id then
 | 
| 
bsw@1045
 | 
   227 
 | 
| 
bsw@1045
 | 
   228     if voting_member_id  then
 | 
| 
bsw@1045
 | 
   229       ui.link{
 | 
| 
bsw@1045
 | 
   230         module = "vote", view = "list", params = {
 | 
| 
bsw@1045
 | 
   231           issue_id = issue.id,
 | 
| 
bsw@1045
 | 
   232           member_id = voting_member_id
 | 
| 
bsw@1045
 | 
   233         },
 | 
| 
bsw@1045
 | 
   234         attr = { class = class }, content = function()
 | 
| 
bsw@1045
 | 
   235           print_delegation_info()
 | 
| 
bsw@1045
 | 
   236         end
 | 
| 
bsw@1045
 | 
   237       }
 | 
| 
bsw@1045
 | 
   238     
 | 
| 
bsw@1045
 | 
   239     else
 | 
| 
bsw@1045
 | 
   240       ui.link{
 | 
| 
bsw@1045
 | 
   241         module = "delegation", view = "show", params = {
 | 
| 
bsw@1045
 | 
   242           unit_id = unit_id,
 | 
| 
bsw@1045
 | 
   243           area_id = area_id,
 | 
| 
bsw@1045
 | 
   244           issue_id = issue_id
 | 
| 
bsw@1045
 | 
   245         },
 | 
| 
bsw@1045
 | 
   246         attr = { class = class }, content = function()
 | 
| 
bsw@1045
 | 
   247           print_delegation_info()
 | 
| 
bsw@1045
 | 
   248         end
 | 
| 
bsw@1045
 | 
   249       }
 | 
| 
bsw@1045
 | 
   250     end
 | 
| 
bsw@780
 | 
   251   else
 | 
| 
bsw@780
 | 
   252     ui.container{
 | 
| 
bsw@1045
 | 
   253       attr = { class = class }, content = function()
 | 
| 
bsw@780
 | 
   254         print_delegation_info()
 | 
| 
bsw@780
 | 
   255       end
 | 
| 
bsw@780
 | 
   256     }
 | 
| 
bsw@780
 | 
   257   end
 | 
| 
bsw@551
 | 
   258 end
 | 
| 
bsw@1045
 | 
   259 
 | 
| 
bsw/jbe@1309
 | 
   260 if issue and app.session.member and issue.fully_frozen and not issue.closed and not issue.member_info.direct_voted and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
 | 
| 
bsw/jbe@1309
 | 
   261     ui.link{
 | 
| 
bsw/jbe@1309
 | 
   262       attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
 | 
| 
bsw/jbe@1309
 | 
   263       module = "vote", view = "list", params = {
 | 
| 
bsw/jbe@1309
 | 
   264         issue_id = issue.id
 | 
| 
bsw/jbe@1309
 | 
   265       },
 | 
| 
bsw/jbe@1309
 | 
   266       content = function ()
 | 
| 
bsw/jbe@1309
 | 
   267         ui.tag { content = _"vote now" }
 | 
| 
bsw/jbe@1309
 | 
   268       end
 | 
| 
bsw/jbe@1309
 | 
   269     }
 | 
| 
bsw/jbe@1309
 | 
   270   else
 | 
| 
bsw/jbe@1309
 | 
   271 end
 |