liquid_feedback_frontend
view app/main/delegation/_info.lua @ 526:18cd8595459b
Fixes for public access
| author | bsw | 
|---|---|
| date | Fri May 18 19:21:45 2012 +0200 (2012-05-18) | 
| parents | 63d6549cc00b | 
| children | 5ca9de94cb13 | 
 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   unit:load_delegation_info_once_for_member_id(app.session.member_id)
    18   info = unit.delegation_info
    19   delegation_text = _"Delegate unit"
    20 end
    22 if area then
    23   area:load_delegation_info_once_for_member_id(app.session.member_id)
    24   info = area.delegation_info
    25   delegation_text = _"Delegate area"
    26 end
    28 if issue then
    29   issue:load_delegation_info_once_for_member_id(app.session.member_id)
    30   info = issue.delegation_info
    31   delegation_text = _"Delegate issue"
    32 end
    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 info.first_trustee_id and (not issue or not issue.closed) then
    61       slot.put(" ")
    62       ui.tag{ attr = { class = "link" }, content = delegation_text }
    63     end
    65     if not (issue and issue.state == "voting" and info.own_participation) then
    67       if info.first_trustee_id then
    69         local text = _"delegates to"
    70         ui.image{
    71           attr = { class = "delegation_arrow", alt = text, title = text },
    72           static = "delegation_arrow_24_horizontal.png"
    73         }
    75         local class = "micro_avatar"
    76         if not participant_occured and info.first_trustee_participation then
    77           participant_occured = true
    78           class = class .. " highlighted"
    79         end
    81         execute.view{ module = "member_image", view = "_show", params = {
    82           member_id = info.first_trustee_id, class = class, popup_text = info.first_trustee_name,
    83           image_type = "avatar", show_dummy = true,
    84         } }
    86       end
    88       if info.first_trustee_ellipsis then
    90         local text = _"delegates to"
    91         ui.image{
    92           attr = { class = "delegation_arrow", alt = text, title = text },
    93           static = "delegation_arrow_24_horizontal.png"
    94         }
    96         slot.put("...")
    98       end
   100       if info.other_trustee_id then
   102         local text = _"delegates to"
   103         ui.image{
   104           attr = { class = "delegation_arrow", alt = text, title = text },
   105           static = "delegation_arrow_24_horizontal.png"
   106         }
   108         local class = "micro_avatar"
   109         if not participant_occured and info.other_trustee_participation then
   110           participant_occured = true
   111           class = class .. " highlighted"
   112         end
   114         execute.view{ module = "member_image", view = "_show", params = {
   115           member_id = info.other_trustee_id, class = class, popup_text = info.other_trustee_name,
   116           image_type = "avatar", show_dummy = true,
   117         } }
   119       end
   121       if info.other_trustee_ellipsis then
   123         local text = _"delegates to"
   124         ui.image{
   125           attr = { class = "delegation_arrow", alt = text, title = text },
   126           static = "delegation_arrow_24_horizontal.png"
   127         }
   129         slot.put("...")
   131       end
   133       local trailing_ellipsis = info.other_trustee_ellipsis or
   134         (info.first_trustee_ellipsis and not info.other_trustee_id)
   136       if info.delegation_loop == "own" then
   138         local text = _"delegates to"
   139         ui.image{
   140           attr = { class = "delegation_arrow", alt = text, title = text },
   141           static = "delegation_arrow_24_horizontal.png"
   142         }
   144         execute.view{ module = "member_image", view = "_show", params = {
   145           member = app.session.member, class = "micro_avatar", popup_text = app.session.member.name,
   146           image_type = "avatar", show_dummy = true,
   147         } }
   149       elseif info.delegation_loop == "first" then
   150         if info.first_trustee_ellipsis then
   151           if not trailing_ellipsis then
   153             local text = _"delegates to"
   154             ui.image{
   155               attr = { class = "delegation_arrow", alt = text, title = text },
   156               static = "delegation_arrow_24_horizontal.png"
   157             }
   159             slot.put("...")
   160           end
   162         else
   164           local text = _"delegates to"
   165           ui.image{
   166             attr = { class = "delegation_arrow", alt = text, title = text },
   167             static = "delegation_arrow_24_horizontal.png"
   168           }
   170           execute.view{ module = "member_image", view = "_show", params = {
   171             member_id = info.first_trustee_id, class = "micro_avatar", popup_text = info.first_trustee_name,
   172             image_type = "avatar", show_dummy = true,
   173           } }
   174         end
   177       elseif info.delegation_loop and not trailing_ellipsis then
   178         local text = _"delegates to"
   179         ui.image{
   180           attr = { class = "delegation_arrow", alt = text, title = text },
   181           static = "delegation_arrow_24_horizontal.png"
   182         }
   184         slot.put("...")
   185       end
   187     end
   189   end
   191 }
