liquid_feedback_frontend
view app/main/delegation/_info.lua @ 547:57a261a81c5a
Added preloading to issue list
| author | bsw | 
|---|---|
| date | Tue May 29 20:43:27 2012 +0200 (2012-05-29) | 
| parents | 5ca9de94cb13 | 
| children | c1dc3b14a4f3 | 
 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   info = issue.member_info
    29   delegation_text = _"Delegate issue"
    30 end
    32 if info.own_participation or info.first_trustee_id then
    34   ui.link{
    35     module = "delegation", view = "show", params = {
    36       unit_id = unit_id,
    37       area_id = area_id,
    38       issue_id = issue_id
    39     },
    40     attr = { class = "delegation_info" }, content = function()
    43       local participant_occured = false
    45       if info.own_participation or info.first_trustee_id then
    47         local class = "micro_avatar"
    48         if info.own_participation then
    49           participant_occured = true
    50           class = class .. " highlighted"
    51         end
    53         execute.view{ module = "member_image", view = "_show", params = {
    54           member = app.session.member, class = class, popup_text = app.session.member.name,
    55           image_type = "avatar", show_dummy = true,
    56         } }
    58       end
    60       if not (issue and issue.state == "voting" and info.own_participation) then
    62         if info.first_trustee_id then
    64           local text = _"delegates to"
    65           ui.image{
    66             attr = { class = "delegation_arrow", alt = text, title = text },
    67             static = "delegation_arrow_24_horizontal.png"
    68           }
    70           local class = "micro_avatar"
    71           if not participant_occured and info.first_trustee_participation then
    72             participant_occured = true
    73             class = class .. " highlighted"
    74           end
    76           execute.view{ module = "member_image", view = "_show", params = {
    77             member_id = info.first_trustee_id, class = class, popup_text = info.first_trustee_name,
    78             image_type = "avatar", show_dummy = true,
    79           } }
    81         end
    83         if info.first_trustee_ellipsis then
    85           local text = _"delegates to"
    86           ui.image{
    87             attr = { class = "delegation_arrow", alt = text, title = text },
    88             static = "delegation_arrow_24_horizontal.png"
    89           }
    91           slot.put("...")
    93         end
    95         if info.other_trustee_id then
    97           local text = _"delegates to"
    98           ui.image{
    99             attr = { class = "delegation_arrow", alt = text, title = text },
   100             static = "delegation_arrow_24_horizontal.png"
   101           }
   103           local class = "micro_avatar"
   104           if not participant_occured and info.other_trustee_participation then
   105             participant_occured = true
   106             class = class .. " highlighted"
   107           end
   109           execute.view{ module = "member_image", view = "_show", params = {
   110             member_id = info.other_trustee_id, class = class, popup_text = info.other_trustee_name,
   111             image_type = "avatar", show_dummy = true,
   112           } }
   114         end
   116         if info.other_trustee_ellipsis then
   118           local text = _"delegates to"
   119           ui.image{
   120             attr = { class = "delegation_arrow", alt = text, title = text },
   121             static = "delegation_arrow_24_horizontal.png"
   122           }
   124           slot.put("...")
   126         end
   128         local trailing_ellipsis = info.other_trustee_ellipsis or
   129           (info.first_trustee_ellipsis and not info.other_trustee_id)
   131         if info.delegation_loop == "own" then
   133           local text = _"delegates to"
   134           ui.image{
   135             attr = { class = "delegation_arrow", alt = text, title = text },
   136             static = "delegation_arrow_24_horizontal.png"
   137           }
   139           execute.view{ module = "member_image", view = "_show", params = {
   140             member = app.session.member, class = "micro_avatar", popup_text = app.session.member.name,
   141             image_type = "avatar", show_dummy = true,
   142           } }
   144         elseif info.delegation_loop == "first" then
   145           if info.first_trustee_ellipsis then
   146             if not trailing_ellipsis then
   148               local text = _"delegates to"
   149               ui.image{
   150                 attr = { class = "delegation_arrow", alt = text, title = text },
   151                 static = "delegation_arrow_24_horizontal.png"
   152               }
   154               slot.put("...")
   155             end
   157           else
   159             local text = _"delegates to"
   160             ui.image{
   161               attr = { class = "delegation_arrow", alt = text, title = text },
   162               static = "delegation_arrow_24_horizontal.png"
   163             }
   165             execute.view{ module = "member_image", view = "_show", params = {
   166               member_id = info.first_trustee_id, class = "micro_avatar", popup_text = info.first_trustee_name,
   167               image_type = "avatar", show_dummy = true,
   168             } }
   169           end
   172         elseif info.delegation_loop and not trailing_ellipsis then
   173           local text = _"delegates to"
   174           ui.image{
   175             attr = { class = "delegation_arrow", alt = text, title = text },
   176             static = "delegation_arrow_24_horizontal.png"
   177           }
   179           slot.put("...")
   180         end
   182       end
   184     end
   186   }
   188 end
