liquid_feedback_frontend
view app/main/member/_show_thumb.lua @ 1823:a3ca8d5c8c79
Do not offer to save the member itself as a contact
| author | bsw | 
|---|---|
| date | Thu Feb 03 11:34:28 2022 +0100 (2022-02-03) | 
| parents | 20c1c8cc28ba | 
| children | a5e1de39e19a | 
 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       local text = _"Voting comment available",
   105       ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "comment" }
   106     end
   109     if (issue or initiative) and weight > 0 then
   110     end
   112     if member.supporter then
   113       ui.tag { attr = { class = "mdl-chip__action" }, content = function()
   114         if member.supporter_satisfied then
   115           local text = _"supporter"
   116           ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "thumb_up" }
   117         else
   118           local text = _"supporter with restricting suggestions"
   119           ui.tag{ tag = "i", attr = { class = "material-icons mdl-color-text--orange-900" }, content = "thumb_up" }
   120         end
   121       end }
   122     end
   124     if not member.active then
   125       local text = _"member inactive"
   126       ui.tag{ tag = "i", attr = { class = "material-icons icon-red" }, content = "disabled_by_default" }
   127     end
   129     if initiator and initiator.accepted then
   130       if member.accepted == nil then
   131         slot.put(_"Invited [as initiator]")
   132       elseif member.accepted == false then
   133         slot.put(_"Rejected [initiator invitation]")
   134       end
   135     end
   137     if member.is_informed == false then
   138       local text = _"Member has not approved latest draft"
   139       ui.tag{ tag = "i", attr = { class = "material-icons icon-yellow" }, content = "help" }
   140     end
   142   end
   143 }
   145 if member.grade or (issue and weight > 1) or app.session.member_id or app.session:has_access("everything") then
   146   ui.tag { tag = "ul", attr = { class = "mdl-menu mdl-menu--bottom-left mdl-js-menu mdl-js-ripple-effect", ["for"] = el_id }, content = function()
   147     if (member.grade) then
   148       ui.tag{ tag = "li", attr = { class = "mdl-menu__item" }, content = function()
   149         ui.link{
   150           attr = { class = "mdl-menu__link" },
   151           module = "vote",
   152           view = "list",
   153           params = {
   154             issue_id = issue.id,
   155             member_id = member.id,
   156           },
   157           content = _"show ballot"
   158         }
   159       end }
   160     end
   161     if issue and weight > 1 then
   162       ui.tag{ tag = "li", attr = { class = "mdl-menu__item" }, content = function()
   163         local module = "interest"
   164         if member.voter_weight then
   165           module = "vote"
   166         end
   167         ui.link{ attr = { class = "mdl-menu__link" }, content = _"show incoming delegations", module = module, view = "show_incoming", params = {
   168           member_id = member.id, 
   169           initiative_id = initiative and initiative.id or nil,
   170           issue_id = issue and issue.id or nil
   171         } }
   172       end }
   173     end
   174     if app.session:has_access("everything") then
   175       ui.tag{ tag = "li", attr = { class = "mdl-menu__item" }, content = function()
   176         ui.link{ attr = { class = "mdl-menu__link" }, content = _"show profile", module = "member", view = "show", id = member.id }
   177       end }
   178     end
   179     if app.session.member_id and app.session.member_id ~= member.id then
   180       ui.tag{ tag = "li", attr = { class = "mdl-menu__item" }, content = function()
   181         ui.link{
   182           attr = { class = "mdl-menu__link" },
   183           text    = _"add to my list of private contacts",
   184           module  = "contact",
   185           action  = "add_member",
   186           id      = member.id,
   187           routing = {
   188             default = {
   189               mode = "redirect",
   190               module = request.get_module(),
   191               view = request.get_view(),
   192               id = request.get_id_string(),
   193               params = request.get_param_strings()
   194             }
   195           }
   196         }
   197       end }
   198     end  
   199   end }
   200 end
