liquid_feedback_frontend
view app/main/member/_show_thumb.lua @ 1509:e2b674b132eb
merge
| author | bsw | 
|---|---|
| date | Mon Aug 03 11:30:03 2020 +0200 (2020-08-03) | 
| parents | 64229f002a47 | 
| children | dcbe505ddf24 | 
 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 class = param.get("class")
    10 local name_html
    11 if member.name_highlighted then
    12   name_html = encode.highlight(member.name_highlighted)
    13 else
    14   name_html = encode.html(member.name)
    15 end
    17 local container_class = "mdl-chip mdl-chip--contact clickable mdl-badge mdl-badge--overlap"
    18 if initiator and member.accepted ~= true then
    19   container_class = container_class .. " not_accepted"
    20 end
    22 if member.is_informed == false then
    23   container_class = container_class .. " not_informed"
    24 end
    26 if class then
    27   container_class = container_class .. " " .. class
    28 end
    30 local in_delegation_chain = member.in_delegation_chain
    31 --[[if member.delegate_member_ids then
    32   for member_id in member.delegate_member_ids:gmatch("(%w+)") do
    33     if tonumber(member_id) == member.id then
    34       in_delegation_chain = true
    35     end
    36   end
    37 end
    38 --]]
    39 if in_delegation_chain or ((issue or initiative) and member.id == app.session.member_id) then
    40   container_class = container_class .. " in_delegation_chain"
    41 end
    43 local el_id = multirand.string(32, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")
    44 local weight = 0
    45 local ownweight = member.ownweight
    46 if member.weight then
    47   weight = member.weight
    48 end
    49 if member.voter_weight then
    50   weight = member.voter_weight
    51 end
    52 local delegated_weight = weight - (ownweight or 0)
    54 local weight_text = ""
    56 if ownweight and ownweight > 1 then
    57   weight_text = weight_text .. ownweight
    58 end
    60 if delegated_weight > 0 then
    61   weight_text = weight_text .. "+" .. delegated_weight
    62 end
    64 if weight_text == "" then
    65   weight_text = nil
    66 end
    68 ui.container{
    69   attr = { id = el_id, class = container_class },
    70   content = function()
    72     execute.view{
    73       module = "member_image",
    74       view = "_show",
    75       params = {
    76         member = member,
    77         image_type = "avatar",
    78         show_dummy = true
    79       }
    80     }
    81     ui.tag{
    82       attr = { class = "mdl-chip__text" },
    83       content = function() 
    84         slot.put(name_html)
    85         if weight_text then
    86           slot.put(" ")
    87           ui.tag{ attr = { class = "member_weight" }, content = weight_text }
    88         end
    89       end
    90     }
    92     if member.grade then
    93       slot.put ( " " )
    94       if member.grade > 0 then
    95         ui.tag{ tag = "i", attr = { class = "material-icons icon-green" }, content = "thumb_up" }
    96       elseif member.grade < 0 then
    97         ui.tag{ tag = "i", attr = { class = "material-icons icon-red" }, content = "thumb_down" }
    98       else
    99         ui.tag{ tag = "i", attr = { class = "material-icons icon-yellow" }, content = "brightness_1" }
   100       end
   101     end
   103     if (member.voter_comment) then
   104       ui.image{
   105         attr = { 
   106           alt   = _"Voting comment available",
   107           title = _"Voting comment available",
   108           class = "icon24 right"
   109         },
   110         static = "icons/16/comment.png"
   111       }
   112     end
   115     if (issue or initiative) and weight > 0 then
   116     end
   118     if member.supporter then
   119       ui.tag { attr = { class = "mdl-chip__action" }, content = function()
   120         if member.supporter_satisfied then
   121           local text = _"supporter"
   122           ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "thumb_up" }
   123         else
   124           local text = _"supporter with restricting suggestions"
   125           ui.tag{ tag = "i", attr = { class = "material-icons mdl-color-text--orange-900" }, content = "thumb_up" }
   126         end
   127       end }
   128     end
   130     if not member.active then
   131       slot.put ( " " )
   132       local text = _"member inactive"
   133       ui.image{
   134         attr = { alt = text, title = text },
   135         static = "icons/16/cross.png"
   136       }
   137       ui.tag{ content = _"inactive" }
   138     end
   140     if initiator and initiator.accepted then
   141       if member.accepted == nil then
   142         slot.put(_"Invited")
   143       elseif member.accepted == false then
   144         slot.put(_"Rejected")
   145       end
   146     end
   148     if member.is_informed == false then
   149       local text = _"Member has not approved latest draft"
   150       ui.image{
   151         attr = { alt = text, title = text },
   152         static = "icons/16/help_yellow.png"
   153       }
   154     end
   156   end
   157 }
   159 if member.grade or (issue and weight > 1) or app.session.member_id or app.session:has_access("everything") then
   160   ui.tag { tag = "ul", attr = { class = "mdl-menu mdl-menu--bottom-left mdl-js-menu mdl-js-ripple-effect", ["for"] = el_id }, content = function()
   161     if (member.grade) then
   162       ui.tag{ tag = "li", attr = { class = "mdl-menu__item" }, content = function()
   163         ui.link{
   164           attr = { class = "mdl-menu__link" },
   165           module = "vote",
   166           view = "list",
   167           params = {
   168             issue_id = issue.id,
   169             member_id = member.id,
   170           },
   171           content = _"show ballot"
   172         }
   173       end }
   174     end
   175     if issue and weight > 1 then
   176       ui.tag{ tag = "li", attr = { class = "mdl-menu__item" }, content = function()
   177         local module = "interest"
   178         if member.voter_weight then
   179           module = "vote"
   180         end
   181         ui.link{ attr = { class = "mdl-menu__link" }, content = _"show incoming delegations", module = module, view = "show_incoming", params = {
   182           member_id = member.id, 
   183           initiative_id = initiative and initiative.id or nil,
   184           issue_id = issue and issue.id or nil
   185         } }
   186       end }
   187     end
   188     if app.session:has_access("everything") then
   189       ui.tag{ tag = "li", attr = { class = "mdl-menu__item" }, content = function()
   190         ui.link{ attr = { class = "mdl-menu__link" }, content = _"show profile", module = "member", view = "show", id = member.id }
   191       end }
   192     end
   193     if app.session.member_id then
   194       ui.tag{ tag = "li", attr = { class = "mdl-menu__item" }, content = function()
   195         ui.link{
   196           attr = { class = "mdl-menu__link" },
   197           text    = _"add to my list of private contacts",
   198           module  = "contact",
   199           action  = "add_member",
   200           id      = member.id,
   201           routing = {
   202             default = {
   203               mode = "redirect",
   204               module = request.get_module(),
   205               view = request.get_view(),
   206               id = request.get_id_string(),
   207               params = request.get_param_strings()
   208             }
   209           }
   210         }
   211       end }
   212     end  
   213   end }
   214 end
