liquid_feedback_frontend
view app/main/member/_show_thumb.lua @ 1313:7cdc685bb7a6
Added optional registration fields
| author | bsw | 
|---|---|
| date | Wed Aug 01 17:21:01 2018 +0200 (2018-08-01) | 
| parents | 32cc544d5a5b | 
| children | 64229f002a47 | 
 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 if member.weight then
    46   weight = member.weight
    47 end
    48 if member.voter_weight then
    49   weight = member.voter_weight
    50 end
    52 ui.container{
    53   attr = { id = el_id, class = container_class, ["data-badge"] = weight > 1 and "+" .. weight - 1 or nil },
    54   content = function()
    56     execute.view{
    57       module = "member_image",
    58       view = "_show",
    59       params = {
    60         member = member,
    61         image_type = "avatar",
    62         show_dummy = true
    63       }
    64     }
    65     ui.tag{
    66       attr = { class = "mdl-chip__text" },
    67       content = function() slot.put(name_html) end
    68     }
    70     if member.grade then
    71       slot.put ( " " )
    72       if member.grade > 0 then
    73         ui.tag{ tag = "i", attr = { class = "material-icons icon-green" }, content = "thumb_up" }
    74       elseif member.grade < 0 then
    75         ui.tag{ tag = "i", attr = { class = "material-icons icon-red" }, content = "thumb_down" }
    76       else
    77         ui.tag{ tag = "i", attr = { class = "material-icons icon-yellow" }, content = "brightness_1" }
    78       end
    79     end
    81     if (member.voter_comment) then
    82       ui.image{
    83         attr = { 
    84           alt   = _"Voting comment available",
    85           title = _"Voting comment available",
    86           class = "icon24 right"
    87         },
    88         static = "icons/16/comment.png"
    89       }
    90     end
    93     if (issue or initiative) and weight > 0 then
    94     end
    96     if member.supporter then
    97       ui.tag { attr = { class = "mdl-chip__action" }, content = function()
    98         if member.supporter_satisfied then
    99           local text = _"supporter"
   100           ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "thumb_up" }
   101         else
   102           local text = _"supporter with restricting suggestions"
   103           ui.tag{ tag = "i", attr = { class = "material-icons mdl-color-text--orange-900" }, content = "thumb_up" }
   104         end
   105       end }
   106     end
   108     if not member.active then
   109       slot.put ( " " )
   110       local text = _"member inactive"
   111       ui.image{
   112         attr = { alt = text, title = text },
   113         static = "icons/16/cross.png"
   114       }
   115       ui.tag{ content = _"inactive" }
   116     end
   118     if initiator and initiator.accepted then
   119       if member.accepted == nil then
   120         slot.put(_"Invited")
   121       elseif member.accepted == false then
   122         slot.put(_"Rejected")
   123       end
   124     end
   126     if member.is_informed == false then
   127       local text = _"Member has not approved latest draft"
   128       ui.image{
   129         attr = { alt = text, title = text },
   130         static = "icons/16/help_yellow.png"
   131       }
   132     end
   134   end
   135 }
   137 if member.grade or (issue and weight > 1) or app.session.member_id or app.session:has_access("everything") then
   138   ui.tag { tag = "ul", attr = { class = "mdl-menu mdl-menu--bottom-left mdl-js-menu mdl-js-ripple-effect", ["for"] = el_id }, content = function()
   139     if (member.grade) then
   140       ui.tag{ tag = "li", attr = { class = "mdl-menu__item" }, content = function()
   141         ui.link{
   142           attr = { class = "mdl-menu__link" },
   143           module = "vote",
   144           view = "list",
   145           params = {
   146             issue_id = issue.id,
   147             member_id = member.id,
   148           },
   149           content = _"show ballot"
   150         }
   151       end }
   152     end
   153     if issue and weight > 1 then
   154       ui.tag{ tag = "li", attr = { class = "mdl-menu__item" }, content = function()
   155         local module = "interest"
   156         if member.voter_weight then
   157           module = "vote"
   158         end
   159         ui.link{ attr = { class = "mdl-menu__link" }, content = _"show incoming delegations", module = module, view = "show_incoming", params = {
   160           member_id = member.id, 
   161           initiative_id = initiative and initiative.id or nil,
   162           issue_id = issue and issue.id or nil
   163         } }
   164       end }
   165     end
   166     if app.session:has_access("everything") then
   167       ui.tag{ tag = "li", attr = { class = "mdl-menu__item" }, content = function()
   168         ui.link{ attr = { class = "mdl-menu__link" }, content = _"show profile", module = "member", view = "show", id = member.id }
   169       end }
   170     end
   171     if app.session.member_id then
   172       ui.tag{ tag = "li", attr = { class = "mdl-menu__item" }, content = function()
   173         ui.link{
   174           attr = { class = "mdl-menu__link" },
   175           text    = _"add to my list of private contacts",
   176           module  = "contact",
   177           action  = "add_member",
   178           id      = member.id,
   179           routing = {
   180             default = {
   181               mode = "redirect",
   182               module = request.get_module(),
   183               view = request.get_view(),
   184               id = request.get_id_string(),
   185               params = request.get_param_strings()
   186             }
   187           }
   188         }
   189       end }
   190     end  
   191   end }
   192 end
