liquid_feedback_frontend
view app/main/member/_sidebar_contacts.lua @ 1677:20576245ff6a
Fixed typo
| author | bsw | 
|---|---|
| date | Tue Jun 15 10:33:13 2021 +0200 (2021-06-15) | 
| parents | 32cc544d5a5b | 
| children | 
 line source
     1 local member = param.get("member", "table")
     3 local public_contacts_selector = Contact:build_selector{
     4   public = true,
     5   member_id = member.id,
     6   order = "name"
     7 }
     9 local private_contacts_selector = Contact:build_selector{
    10   public = false,
    11   member_id = member.id,
    12   order = "name"
    13 }
    15 ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
    16   ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
    17     ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"Published contacts" }
    18   end }
    20   ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function()
    21     ui.container{ content = _"Published contacts" }
    22     if public_contacts_selector:count() == 0 then
    23       ui.container{ content = _"No published contacts" }
    24     else
    25       ui.paginate{
    26         selector = public_contacts_selector,
    27         name = "contacts",
    28         content = function()
    29           local contacts = public_contacts_selector:exec()
    30           for i, contact in ipairs(contacts) do
    31             ui.container{ content = function()
    32               execute.view{ module = "member_image", view = "_show", params = {
    33                 member_id = contact.other_member.id, class = "micro_avatar", 
    34                 popup_text = contact.other_member.name,
    35                 image_type = "avatar", show_dummy = true,
    36               } }
    37               slot.put(" ")
    38               ui.link{
    39                 content = contact.other_member.name,
    40                 module = "member",
    41                 view = "show",
    42                 id = contact.other_member.id
    43               }
    44               if app.session.member_id == member.id then
    45                 ui.link{
    46                   content = function() 
    47                     ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "get_app" }
    48                   end,
    49                   module = "contact",
    50                   action = "add_member",
    51                   id     = contact.other_member_id,
    52                   params = { public = false },
    53                   routing = {
    54                     default = {
    55                       mode = "redirect",
    56                       module = request.get_module(),
    57                       view = request.get_view(),
    58                       id = request.get_id_string(),
    59                       params = request.get_param_strings()
    60                     }
    61                   }
    62                 }
    63                 ui.link{
    64                   content = function() 
    65                     ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "delete" }
    66                   end,
    67                   module = "contact",
    68                   action = "remove_member",
    69                   id = contact.other_member_id,
    70                   routing = {
    71                     default = {
    72                       mode = "redirect",
    73                       module = request.get_module(),
    74                       view = request.get_view(),
    75                       id = request.get_id_string(),
    76                       params = request.get_param_strings()
    77                     }
    78                   }
    79                 }
    80               end
    81             end }
    82           end
    83         end
    84       }
    85     end
    86   end }
    88   if member.id == app.session.member_id then
    89     ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function()
    90       ui.tag{ content = _"Private contacts" }
    92       if app.session.member_id and app.session.member_id == member.id 
    93         and private_contacts_selector:count() > 0
    94       then
    96         ui.paginate{
    97           selector = private_contacts_selector,
    98           name = "contacts",
    99           content = function()
   100             local contacts = private_contacts_selector:exec()
   101             for i, contact in ipairs(contacts) do
   102               ui.container{ content = function()
   103                 execute.view{ module = "member_image", view = "_show", params = {
   104                   member_id = contact.other_member.id, class = "micro_avatar", 
   105                   popup_text = contact.other_member.name,
   106                   image_type = "avatar", show_dummy = true,
   107                 } }
   108                 slot.put(" ")
   109                 ui.link{
   110                   content = contact.other_member.name,
   111                   module = "member",
   112                   view = "show",
   113                   id = contact.other_member.id
   114                 }
   115                 slot.put(" ")
   116                 ui.link{
   117                   content = function() 
   118                     ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "publish" }
   119                   end,
   120                   module = "contact",
   121                   action = "add_member",
   122                   id     = contact.other_member_id,
   123                   params = { public = true },
   124                   routing = {
   125                     default = {
   126                       mode = "redirect",
   127                       module = request.get_module(),
   128                       view = request.get_view(),
   129                       id = request.get_id_string(),
   130                       params = request.get_param_strings()
   131                     }
   132                   }
   133                 }
   134                 ui.link{
   135                   content = function() 
   136                     ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "delete" }
   137                   end,
   138                   module = "contact",
   139                   action = "remove_member",
   140                   id = contact.other_member_id,
   141                   routing = {
   142                     default = {
   143                       mode = "redirect",
   144                       module = request.get_module(),
   145                       view = request.get_view(),
   146                       id = request.get_id_string(),
   147                       params = request.get_param_strings()
   148                     }
   149                   }
   150                 }
   151               end }
   152             end
   153           end
   154         }
   155       end
   156     end }
   157   end
   158 end }
