liquid_feedback_frontend
view app/main/delegation/_info.lua @ 529:5ca9de94cb13
Delegation preview when setting delegation, optical enhancements, typos fixed
| author | bsw | 
|---|---|
| date | Sun May 20 19:43:01 2012 +0200 (2012-05-20) | 
| parents | 18cd8595459b | 
| children | 57a261a81c5a | 
 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   issue:load_delegation_info_once_for_member_id(app.session.member_id)
    29   info = issue.delegation_info
    30   delegation_text = _"Delegate issue"
    31 end
    33 if info.own_participation or info.first_trustee_id then
    35   ui.link{
    36     module = "delegation", view = "show", params = {
    37       unit_id = unit_id,
    38       area_id = area_id,
    39       issue_id = issue_id
    40     },
    41     attr = { class = "delegation_info" }, content = function()
    44       local participant_occured = false
    46       if info.own_participation or info.first_trustee_id then
    48         local class = "micro_avatar"
    49         if info.own_participation then
    50           participant_occured = true
    51           class = class .. " highlighted"
    52         end
    54         execute.view{ module = "member_image", view = "_show", params = {
    55           member = app.session.member, class = class, popup_text = app.session.member.name,
    56           image_type = "avatar", show_dummy = true,
    57         } }
    59       end
    61       if not (issue and issue.state == "voting" and info.own_participation) then
    63         if info.first_trustee_id then
    65           local text = _"delegates to"
    66           ui.image{
    67             attr = { class = "delegation_arrow", alt = text, title = text },
    68             static = "delegation_arrow_24_horizontal.png"
    69           }
    71           local class = "micro_avatar"
    72           if not participant_occured and info.first_trustee_participation then
    73             participant_occured = true
    74             class = class .. " highlighted"
    75           end
    77           execute.view{ module = "member_image", view = "_show", params = {
    78             member_id = info.first_trustee_id, class = class, popup_text = info.first_trustee_name,
    79             image_type = "avatar", show_dummy = true,
    80           } }
    82         end
    84         if info.first_trustee_ellipsis then
    86           local text = _"delegates to"
    87           ui.image{
    88             attr = { class = "delegation_arrow", alt = text, title = text },
    89             static = "delegation_arrow_24_horizontal.png"
    90           }
    92           slot.put("...")
    94         end
    96         if info.other_trustee_id then
    98           local text = _"delegates to"
    99           ui.image{
   100             attr = { class = "delegation_arrow", alt = text, title = text },
   101             static = "delegation_arrow_24_horizontal.png"
   102           }
   104           local class = "micro_avatar"
   105           if not participant_occured and info.other_trustee_participation then
   106             participant_occured = true
   107             class = class .. " highlighted"
   108           end
   110           execute.view{ module = "member_image", view = "_show", params = {
   111             member_id = info.other_trustee_id, class = class, popup_text = info.other_trustee_name,
   112             image_type = "avatar", show_dummy = true,
   113           } }
   115         end
   117         if info.other_trustee_ellipsis then
   119           local text = _"delegates to"
   120           ui.image{
   121             attr = { class = "delegation_arrow", alt = text, title = text },
   122             static = "delegation_arrow_24_horizontal.png"
   123           }
   125           slot.put("...")
   127         end
   129         local trailing_ellipsis = info.other_trustee_ellipsis or
   130           (info.first_trustee_ellipsis and not info.other_trustee_id)
   132         if info.delegation_loop == "own" then
   134           local text = _"delegates to"
   135           ui.image{
   136             attr = { class = "delegation_arrow", alt = text, title = text },
   137             static = "delegation_arrow_24_horizontal.png"
   138           }
   140           execute.view{ module = "member_image", view = "_show", params = {
   141             member = app.session.member, class = "micro_avatar", popup_text = app.session.member.name,
   142             image_type = "avatar", show_dummy = true,
   143           } }
   145         elseif info.delegation_loop == "first" then
   146           if info.first_trustee_ellipsis then
   147             if not trailing_ellipsis then
   149               local text = _"delegates to"
   150               ui.image{
   151                 attr = { class = "delegation_arrow", alt = text, title = text },
   152                 static = "delegation_arrow_24_horizontal.png"
   153               }
   155               slot.put("...")
   156             end
   158           else
   160             local text = _"delegates to"
   161             ui.image{
   162               attr = { class = "delegation_arrow", alt = text, title = text },
   163               static = "delegation_arrow_24_horizontal.png"
   164             }
   166             execute.view{ module = "member_image", view = "_show", params = {
   167               member_id = info.first_trustee_id, class = "micro_avatar", popup_text = info.first_trustee_name,
   168               image_type = "avatar", show_dummy = true,
   169             } }
   170           end
   173         elseif info.delegation_loop and not trailing_ellipsis then
   174           local text = _"delegates to"
   175           ui.image{
   176             attr = { class = "delegation_arrow", alt = text, title = text },
   177             static = "delegation_arrow_24_horizontal.png"
   178           }
   180           slot.put("...")
   181         end
   183       end
   185     end
   187   }
   189 end
