liquid_feedback_frontend
view app/main/member/_show_thumb.lua @ 733:9c88e513a8f7
Renamed example config to example.lua
| author | bsw | 
|---|---|
| date | Thu Jun 28 17:24:18 2012 +0200 (2012-06-28) | 
| parents | 1641f0218177 | 
| children | ea3d3757ddc3 | 
 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_html
     9 if member.name_highlighted then
    10   name_html = encode.highlight(member.name_highlighted)
    11 else
    12   name_html = 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.active then
    45           local text = _"inactive"
    46           ui.tag{ content = text }
    47           ui.image{
    48             attr = { alt = text, title = text },
    49             static = "icons/16/cross.png"
    50           }
    51         end
    53         if member.grade then
    54           ui.link{
    55             module = "vote",
    56             view = "list",
    57             params = {
    58               issue_id = initiative.issue.id,
    59               member_id = member.id,
    60             },
    61             content = function()
    62               if member.grade > 0 then
    63                 ui.image{
    64                   attr = { 
    65                     alt   = _"Voted yes",
    66                     title = _"Voted yes"
    67                   },
    68                   static = "icons/16/thumb_up_green.png"
    69                 }
    70               elseif member.grade < 0 then
    71                 ui.image{
    72                   attr = { 
    73                     alt   = _"Voted no",
    74                     title = _"Voted no"
    75                   },
    76                   static = "icons/16/thumb_down_red.png"
    77                 }
    78               else
    79                 ui.image{
    80                   attr = { 
    81                     alt   = _"Abstention",
    82                     title = _"Abstention"
    83                   },
    84                   static = "icons/16/bullet_yellow.png"
    85                 }
    86               end
    87             end
    88           }
    89         end
    91         local weight = 0
    92         if member.weight then
    93           weight = member.weight
    94         end
    95         if member.voter_weight then
    96           weight = member.voter_weight
    97         end
    98         if (issue or initiative) and weight > 1 then
    99           local module
   100           if issue then
   101             module = "interest"
   102           elseif initiative then
   103             if member.voter_weight then
   104                module = "vote"
   105             else
   106               module = "supporter"
   107             end
   108           end
   109           ui.link{
   110             attr = { 
   111               class = in_delegation_chain and "in_delegation_chain" or nil,
   112               title = _"Number of incoming delegations, follow link to see more details"
   113             },
   114             content = _("+ #{weight}", { weight = weight - 1 }),
   115             module = module,
   116             view = "show_incoming",
   117             params = { 
   118               member_id = member.id, 
   119               initiative_id = initiative and initiative.id or nil,
   120               issue_id = issue and issue.id or nil
   121             }
   122           }
   123         end
   125         if initiator and initiator.accepted then
   126           if member.accepted == nil then
   127             slot.put(_"Invited")
   128           elseif member.accepted == false then
   129             slot.put(_"Rejected")
   130           end
   131         end
   133         if member.is_informed == false then
   134           local text = _"Member has not approved latest draft"
   135           ui.image{
   136             attr = { alt = text, title = text },
   137             static = "icons/16/help_yellow.png"
   138           }
   139         end
   141       end
   142     }
   144     ui.link{
   145       attr = { title = _"Show member" },
   146       module = "member",
   147       view = "show",
   148       id = member.id,
   149       content = function()
   150         execute.view{
   151           module = "member_image",
   152           view = "_show",
   153           params = {
   154             member = member,
   155             image_type = "avatar",
   156             show_dummy = true
   157           }
   158         }
   159         ui.container{
   160           attr = { class = "member_name" },
   161           content = function() slot.put(name_html) end
   162         }
   163       end
   164     }
   165   end
   166 }
