liquid_feedback_frontend
view app/main/member/_show_thumb.lua @ 277:bde068b37608
Dropdown boxes except of delegation box removed, optical enhancements and repositioning of elements
| author | bsw | 
|---|---|
| date | Mon Feb 13 00:16:42 2012 +0100 (2012-02-13) | 
| parents | dac08fce1ab7 | 
| children | 5ca9de94cb13 | 
 line source
     1 local initiator = param.get("initiator", "table")
     2 local member = param.get("member", "table")
     4 local issue = param.get("issue", "table")
     5 local initiative = param.get("initiative", "table")
     6 local trustee = param.get("trustee", "table")
     8 local name
     9 if member.name_highlighted then
    10   name = encode.highlight(member.name_highlighted)
    11 else
    12   name = encode.html(member.name)
    13 end
    15 local container_class = "member_thumb"
    16 if initiator and member.accepted ~= true then
    17   container_class = container_class .. " not_accepted"
    18 end
    20 if member.is_informed == false then
    21   container_class = container_class .. " not_informed"
    22 end
    24 local in_delegation_chain = false 
    25 if member.delegate_member_ids then
    26   for member_id in member.delegate_member_ids:gmatch("(%w+)") do
    27     if tonumber(member_id) == member.id then
    28       in_delegation_chain = true
    29     end
    30   end
    31 end
    33 if in_delegation_chain or ((issue or initiative) and member.id == app.session.member_id) then
    34   container_class = container_class .. " in_delegation_chain"
    35 end
    37 ui.container{
    38   attr = { class = container_class },
    39   content = function()
    40     ui.container{
    41       attr = { class = "flags" },
    42       content = function()
    44         if not member.activated then
    45           local text = _"Member is deactivated"
    46           ui.image{
    47             attr = { alt = text, title = text },
    48             static = "icons/16/cross.png"
    49           }
    50         end
    52         if member.grade then
    53           ui.link{
    54             module = "vote",
    55             view = "list",
    56             params = {
    57               issue_id = initiative.issue.id,
    58               member_id = member.id,
    59             },
    60             content = function()
    61               if member.grade > 0 then
    62                 ui.image{
    63                   attr = { 
    64                     alt   = _"Voted yes",
    65                     title = _"Voted yes"
    66                   },
    67                   static = "icons/16/thumb_up_green.png"
    68                 }
    69               elseif member.grade < 0 then
    70                 ui.image{
    71                   attr = { 
    72                     alt   = _"Voted no",
    73                     title = _"Voted no"
    74                   },
    75                   static = "icons/16/thumb_down_red.png"
    76                 }
    77               else
    78                 ui.image{
    79                   attr = { 
    80                     alt   = _"Abstention",
    81                     title = _"Abstention"
    82                   },
    83                   static = "icons/16/bullet_yellow.png"
    84                 }
    85               end
    86             end
    87           }
    88         end
    90         local weight = 0
    91         if member.weight then
    92           weight = member.weight
    93         end
    94         if member.voter_weight then
    95           weight = member.voter_weight
    96         end
    97         if (issue or initiative) and weight > 1 then
    98           local module
    99           if issue then
   100             module = "interest"
   101           elseif initiative then
   102             if member.voter_weight then
   103                module = "vote"
   104             else
   105               module = "supporter"
   106             end
   107           end
   108           ui.link{
   109             attr = { 
   110               class = in_delegation_chain and "in_delegation_chain" or nil,
   111               title = _"Number of incoming delegations, follow link to see more details"
   112             },
   113             content = _("+ #{weight}", { weight = weight - 1 }),
   114             module = module,
   115             view = "show_incoming",
   116             params = { 
   117               member_id = member.id, 
   118               initiative_id = initiative and initiative.id or nil,
   119               issue_id = issue and issue.id or nil
   120             }
   121           }
   122         end
   124         if initiator and initiator.accepted then
   125           if member.accepted == nil then
   126             slot.put(_"Invited")
   127           elseif member.accepted == false then
   128             slot.put(_"Rejected")
   129           end
   130         end
   132         if member.is_informed == false then
   133           local text = _"Member has not approved latest draft"
   134           ui.image{
   135             attr = { alt = text, title = text },
   136             static = "icons/16/help_yellow.png"
   137           }
   138         end
   140         if member.admin then
   141           ui.image{
   142             attr = { 
   143               alt   = _"Member is administrator",
   144               title = _"Member is administrator"
   145             },
   146             static = "icons/16/cog.png"
   147           }
   148         end
   150         -- TODO performance
   151         if app.session.member_id then
   152           local contact = Contact:by_pk(app.session.member.id, member.id)
   153           if contact then
   154             ui.image{
   155               attr = { 
   156                 alt   = _"You have saved this member as contact",
   157                 title = _"You have saved this member as contact"
   158               },
   159               static = "icons/16/bullet_disk.png"
   160             }
   161           end
   162         end
   163       end
   164     }
   166     ui.link{
   167       attr = { title = _"Show member" },
   168       module = "member",
   169       view = "show",
   170       id = member.id,
   171       content = function()
   172         execute.view{
   173           module = "member_image",
   174           view = "_show",
   175           params = {
   176             member = member,
   177             image_type = "avatar",
   178             show_dummy = true
   179           }
   180         }
   181         ui.container{
   182           attr = { class = "member_name" },
   183           content = function()
   184             slot.put(name)
   185           end
   186         }
   187       end
   188     }
   189   end
   190 }
