liquid_feedback_frontend
view app/main/contact/list.lua @ 1085:8be69c8d99a8
Fixed error when accessing member profile without being logged in
| author | bsw | 
|---|---|
| date | Sat Aug 02 21:26:53 2014 +0200 (2014-08-02) | 
| parents | 701a5cf6b067 | 
| children | 904f6807f7fa | 
 line source
     1 local contacts_selector = Contact:build_selector{
     2   member_id = app.session.member_id,
     3   order = "name"
     4 }
     6 ui.title(_"Contacts")
     9 ui.paginate{
    10   selector = contacts_selector,
    11   content = function()
    12     local contacts = contacts_selector:exec()
    13     if #contacts == 0 then
    14       ui.field.text{ value = _"You didn't save any member as contact yet." }
    15     else
    16       ui.list{
    17         records = contacts,
    18         columns = {
    19           {
    20             label = _"Name",
    21             content = function(record)
    22               ui.link{
    23                 text = record.other_member.name,
    24                 module = "member",
    25                 view = "show",
    26                 id = record.other_member_id
    27               }
    28             end
    29           },
    30           {
    31             label = _"Published",
    32             content = function(record)
    33               ui.field.boolean{ value = record.public }
    34             end
    35           },
    36           {
    37             content = function(record)
    38               if record.public then
    39                 ui.link{
    40                   attr = { class = "action" },
    41                   text = _"Hide",
    42                   module = "contact",
    43                   action = "add_member",
    44                   id = record.other_member_id,
    45                   params = { public = false },
    46                   routing = {
    47                     default = {
    48                       mode = "redirect",
    49                       module = request.get_module(),
    50                       view = request.get_view(),
    51                       id = param.get_id_cgi(),
    52                       params = param.get_all_cgi()
    53                     }
    54                   }
    55                 }
    56               else
    57                 ui.link{
    58                   attr = { class = "action" },
    59                   text = _"Publish",
    60                   module = "contact",
    61                   action = "add_member",
    62                   id = record.other_member_id,
    63                   params = { public = true },
    64                   routing = {
    65                     default = {
    66                       mode = "redirect",
    67                       module = request.get_module(),
    68                       view = request.get_view(),
    69                       id = param.get_id_cgi(),
    70                       params = param.get_all_cgi()
    71                     }
    72                   }
    73                 }
    74               end
    75             end
    76           },
    77           {
    78             content = function(record)
    79               ui.link{
    80                 attr = { class = "action" },
    81                 text = _"Remove",
    82                 module = "contact",
    83                 action = "remove_member",
    84                 id = record.other_member_id,
    85                 routing = {
    86                   default = {
    87                     mode = "redirect",
    88                     module = request.get_module(),
    89                     view = request.get_view(),
    90                     id = param.get_id_cgi(),
    91                     params = param.get_all_cgi()
    92                   }
    93                 }
    94               }
    95             end
    96           },
    97         }
    98       }
    99     end
   100   end
   101 }
