liquid_feedback_frontend
view app/main/delegation/_info.lua @ 1184:8c65f5a029b0
Unified navigation in admin area
| author | bsw | 
|---|---|
| date | Thu Mar 26 20:38:08 2015 +0100 (2015-03-26) | 
| parents | 701a5cf6b067 | 
| children | 32cc544d5a5b | 
 line source
     1 if not app.session.member_id then
     2   return
     3 end
     5 local member = param.get("member", "table") or app.session.member
     7 local unit  = param.get("unit", "table")
     8 local area  = param.get("area", "table")
     9 local issue = param.get("issue", "table")
    11 local for_title = param.get("for_title", "boolean")
    13 local unit_id  = unit  and unit.id  or nil
    14 local area_id  = area  and area.id  or nil
    15 local issue_id = issue and issue.id or nil
    17 local info
    18 local delegation_text
    20 if unit then
    21   info = unit.delegation_info
    22   delegation_text = _"Delegate unit"
    23 end
    25 if area then
    26   info = area.delegation_info
    27   delegation_text = _"Delegate area"
    28 end
    30 if issue then
    31   info = issue.member_info
    32   delegation_text = _"Delegate issue"
    33 end
    35 if not info then
    36   --return
    37 end
    39 local function print_delegation_info()
    40   local participant_occured = info.own_participation
    42   if not (issue and issue.state == "voting" and info.own_participation) then
    44     if info.first_trustee_id then
    46       local text = _"delegates to"
    47       ui.image{
    48         attr = { class = "delegation_arrow", alt = text, title = text },
    49         static = "delegation_arrow_24_horizontal.png"
    50       }
    52       local class = "micro_avatar"
    53       if not participant_occured and info.first_trustee_participation then
    54         participant_occured = true
    55         class = class .. " highlighted"
    56       end
    58       execute.view{ module = "member_image", view = "_show", params = {
    59         member_id = info.first_trustee_id, class = class, popup_text = info.first_trustee_name,
    60         image_type = "avatar", show_dummy = true,
    61       } }
    63     end
    65     if info.first_trustee_ellipsis then
    67       local text = _"delegates to"
    68       ui.image{
    69         attr = { class = "delegation_arrow", alt = text, title = text },
    70         static = "delegation_arrow_24_horizontal.png"
    71       }
    73       slot.put("...")
    75     end
    77     if info.other_trustee_id then
    79       local text = _"delegates to"
    80       ui.image{
    81         attr = { class = "delegation_arrow", alt = text, title = text },
    82         static = "delegation_arrow_24_horizontal.png"
    83       }
    85       local class = "micro_avatar"
    86       if not participant_occured and info.other_trustee_participation then
    87         participant_occured = true
    88         class = class .. " highlighted"
    89       end
    91       execute.view{ module = "member_image", view = "_show", params = {
    92         member_id = info.other_trustee_id, class = class, popup_text = info.other_trustee_name,
    93         image_type = "avatar", show_dummy = true,
    94       } }
    96     end
    98     if info.other_trustee_ellipsis then
   100       local text = _"delegates to"
   101       ui.image{
   102         attr = { class = "delegation_arrow", alt = text, title = text },
   103         static = "delegation_arrow_24_horizontal.png"
   104       }
   106       slot.put("...")
   108     end
   110     local trailing_ellipsis = info.other_trustee_ellipsis or
   111       (info.first_trustee_ellipsis and not info.other_trustee_id)
   113     if info.delegation_loop == "own" then
   115       local text = _"delegates to"
   116       ui.image{
   117         attr = { class = "delegation_arrow", alt = text, title = text },
   118         static = "delegation_arrow_24_horizontal.png"
   119       }
   121       execute.view{ module = "member_image", view = "_show", params = {
   122         member = member, class = "micro_avatar", popup_text = member.name,
   123         image_type = "avatar", show_dummy = true,
   124       } }
   126     elseif info.delegation_loop == "first" then
   127       if info.first_trustee_ellipsis then
   128         if not trailing_ellipsis then
   130           local text = _"delegates to"
   131           ui.image{
   132             attr = { class = "delegation_arrow", alt = text, title = text },
   133             static = "delegation_arrow_24_horizontal.png"
   134           }
   136           slot.put("...")
   137         end
   139       else
   141         local text = _"delegates to"
   142         ui.image{
   143           attr = { class = "delegation_arrow", alt = text, title = text },
   144           static = "delegation_arrow_24_horizontal.png"
   145         }
   147         execute.view{
   148           module = "member_image", view = "_show", params = {
   149             member_id = info.first_trustee_id, 
   150             class = "micro_avatar", 
   151             popup_text = info.first_trustee_name,
   152             image_type = "avatar",
   153             show_dummy = true,
   154           }
   155         }
   156       end
   159     elseif info.delegation_loop and not trailing_ellipsis then
   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       slot.put("...")
   167     end
   169   end
   170 end
   172 if not param.get("no_star", "boolean") then
   174   if info.own_participation then
   175     if issue and issue.fully_frozen then
   176       ui.link{
   177         attr = { class = "right" },
   178         module = "vote", view = "list", params = {
   179           issue_id = issue.id
   180         },
   181         content = function ()
   182           ui.tag { content = _"you voted" }
   183         end
   184       }
   185     else
   186       if issue then
   187         local text = _"you are interested"
   188         ui.image { attr = { class = "star", title = text, alt = text }, static = "icons/48/eye.png" }
   189         if not issue.closed and info.own_participation and info.weight and info.weight > 1 then
   190           ui.link { 
   191             attr = { class = "right" }, content = "+" .. (info.weight - 1),
   192             module = "delegation", view = "show_incoming", params = { 
   193               issue_id = issue.id, member_id = member.id
   194             }
   195           }
   196         end
   197       else
   198         local text = _"you are subscribed"
   199         ui.image { attr = { class = "icon24 star", title = text, alt = text }, static = "icons/48/star.png" }
   200       end
   201       if not for_title then
   202         slot.put("<br />")
   203       else
   204         slot.put(" ")
   205       end
   206     end
   207   end
   208 end
   211 if info.own_participation or info.first_trustee_id then
   212   local class = "delegation_info"
   213   if info.own_participation then
   214     class = class .. " suspended"
   215   end
   217   local voting_member_id
   218   local voting_member_name
   219   if issue and issue.fully_frozen and issue.closed then
   220     if issue.member_info.first_trustee_participation then
   221       voting_member_id = issue.member_info.first_trustee_id
   222       voting_member_name = issue.member_info.first_trustee_name
   223     elseif issue.member_info.other_trustee_participation then
   224       voting_member_id = issue.member_info.other_trustee_id
   225       voting_member_name = issue.member_info.other_trustee_name
   226     end
   227   end
   229   if app.session.member_id == member.id then
   231     if voting_member_id  then
   232       ui.link{
   233         module = "vote", view = "list", params = {
   234           issue_id = issue.id,
   235           member_id = voting_member_id
   236         },
   237         attr = { class = class }, content = function()
   238           print_delegation_info()
   239         end
   240       }
   242     else
   243       ui.link{
   244         module = "delegation", view = "show", params = {
   245           unit_id = unit_id,
   246           area_id = area_id,
   247           issue_id = issue_id
   248         },
   249         attr = { class = class }, content = function()
   250           print_delegation_info()
   251         end
   252       }
   253     end
   254   else
   255     ui.container{
   256       attr = { class = class }, content = function()
   257         print_delegation_info()
   258       end
   259     }
   260   end
   261 end
