liquid_feedback_frontend
view app/main/delegation/_info.lua @ 653:49dd0cf5e1a8
Added tab "member" in help files index.index.XX.txt
| author | jbe | 
|---|---|
| date | Tue Jun 26 01:13:55 2012 +0200 (2012-06-26) | 
| parents | c1dc3b14a4f3 | 
| children | a3eb6ca34484 | 
 line source
     1 if not app.session.member_id then
     2   return
     3 end
     5 local unit  = param.get("unit", "table")
     6 local area  = param.get("area", "table")
     7 local issue = param.get("issue", "table")
     9 local unit_id  = unit  and unit.id  or nil
    10 local area_id  = area  and area.id  or nil
    11 local issue_id = issue and issue.id or nil
    13 local info
    14 local delegation_text
    16 if unit then
    17   info = unit.delegation_info
    18   delegation_text = _"Delegate unit"
    19 end
    21 if area then
    22   area:load_delegation_info_once_for_member_id(app.session.member_id)
    23   info = area.delegation_info
    24   delegation_text = _"Delegate area"
    25 end
    27 if issue then
    28   if app.session.member_id then
    29     info = issue.member_info
    30   end
    31   delegation_text = _"Delegate issue"
    32 end
    34 if info.own_participation or info.first_trustee_id then
    36   ui.link{
    37     module = "delegation", view = "show", params = {
    38       unit_id = unit_id,
    39       area_id = area_id,
    40       issue_id = issue_id
    41     },
    42     attr = { class = "delegation_info" }, content = function()
    45       local participant_occured = false
    47       if info.own_participation or info.first_trustee_id then
    49         local class = "micro_avatar"
    50         if info.own_participation then
    51           participant_occured = true
    52           class = class .. " highlighted"
    53         end
    55         execute.view{ module = "member_image", view = "_show", params = {
    56           member = app.session.member, class = class, popup_text = app.session.member.name,
    57           image_type = "avatar", show_dummy = true,
    58         } }
    60       end
    62       if not (issue and issue.state == "voting" and info.own_participation) then
    64         if info.first_trustee_id then
    66           local text = _"delegates to"
    67           ui.image{
    68             attr = { class = "delegation_arrow", alt = text, title = text },
    69             static = "delegation_arrow_24_horizontal.png"
    70           }
    72           local class = "micro_avatar"
    73           if not participant_occured and info.first_trustee_participation then
    74             participant_occured = true
    75             class = class .. " highlighted"
    76           end
    78           execute.view{ module = "member_image", view = "_show", params = {
    79             member_id = info.first_trustee_id, class = class, popup_text = info.first_trustee_name,
    80             image_type = "avatar", show_dummy = true,
    81           } }
    83         end
    85         if info.first_trustee_ellipsis then
    87           local text = _"delegates to"
    88           ui.image{
    89             attr = { class = "delegation_arrow", alt = text, title = text },
    90             static = "delegation_arrow_24_horizontal.png"
    91           }
    93           slot.put("...")
    95         end
    97         if info.other_trustee_id then
    99           local text = _"delegates to"
   100           ui.image{
   101             attr = { class = "delegation_arrow", alt = text, title = text },
   102             static = "delegation_arrow_24_horizontal.png"
   103           }
   105           local class = "micro_avatar"
   106           if not participant_occured and info.other_trustee_participation then
   107             participant_occured = true
   108             class = class .. " highlighted"
   109           end
   111           execute.view{ module = "member_image", view = "_show", params = {
   112             member_id = info.other_trustee_id, class = class, popup_text = info.other_trustee_name,
   113             image_type = "avatar", show_dummy = true,
   114           } }
   116         end
   118         if info.other_trustee_ellipsis then
   120           local text = _"delegates to"
   121           ui.image{
   122             attr = { class = "delegation_arrow", alt = text, title = text },
   123             static = "delegation_arrow_24_horizontal.png"
   124           }
   126           slot.put("...")
   128         end
   130         local trailing_ellipsis = info.other_trustee_ellipsis or
   131           (info.first_trustee_ellipsis and not info.other_trustee_id)
   133         if info.delegation_loop == "own" then
   135           local text = _"delegates to"
   136           ui.image{
   137             attr = { class = "delegation_arrow", alt = text, title = text },
   138             static = "delegation_arrow_24_horizontal.png"
   139           }
   141           execute.view{ module = "member_image", view = "_show", params = {
   142             member = app.session.member, class = "micro_avatar", popup_text = app.session.member.name,
   143             image_type = "avatar", show_dummy = true,
   144           } }
   146         elseif info.delegation_loop == "first" then
   147           if info.first_trustee_ellipsis then
   148             if not trailing_ellipsis then
   150               local text = _"delegates to"
   151               ui.image{
   152                 attr = { class = "delegation_arrow", alt = text, title = text },
   153                 static = "delegation_arrow_24_horizontal.png"
   154               }
   156               slot.put("...")
   157             end
   159           else
   161             local text = _"delegates to"
   162             ui.image{
   163               attr = { class = "delegation_arrow", alt = text, title = text },
   164               static = "delegation_arrow_24_horizontal.png"
   165             }
   167             execute.view{ module = "member_image", view = "_show", params = {
   168               member_id = info.first_trustee_id, class = "micro_avatar", popup_text = info.first_trustee_name,
   169               image_type = "avatar", show_dummy = true,
   170             } }
   171           end
   174         elseif info.delegation_loop and not trailing_ellipsis then
   175           local text = _"delegates to"
   176           ui.image{
   177             attr = { class = "delegation_arrow", alt = text, title = text },
   178             static = "delegation_arrow_24_horizontal.png"
   179           }
   181           slot.put("...")
   182         end
   184       end
   186     end
   188   }
   190 end
