liquid_feedback_frontend
view app/main/contact/list.lua @ 730:2496ac5368ad
Better formatting of config file
| author | bsw | 
|---|---|
| date | Thu Jun 28 17:08:52 2012 +0200 (2012-06-28) | 
| parents | 418b590fa9ed | 
| children | 701a5cf6b067 | 
 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 util.help("contact.list")
    12 ui.paginate{
    13   selector = contacts_selector,
    14   content = function()
    15     local contacts = contacts_selector:exec()
    16     if #contacts == 0 then
    17       ui.field.text{ value = _"You didn't save any member as contact yet." }
    18     else
    19       ui.list{
    20         records = contacts,
    21         columns = {
    22           {
    23             label = _"Name",
    24             content = function(record)
    25               ui.link{
    26                 text = record.other_member.name,
    27                 module = "member",
    28                 view = "show",
    29                 id = record.other_member_id
    30               }
    31             end
    32           },
    33           {
    34             label = _"Published",
    35             content = function(record)
    36               ui.field.boolean{ value = record.public }
    37             end
    38           },
    39           {
    40             content = function(record)
    41               if record.public then
    42                 ui.link{
    43                   attr = { class = "action" },
    44                   text = _"Hide",
    45                   module = "contact",
    46                   action = "add_member",
    47                   id = record.other_member_id,
    48                   params = { public = false },
    49                   routing = {
    50                     default = {
    51                       mode = "redirect",
    52                       module = request.get_module(),
    53                       view = request.get_view(),
    54                       id = param.get_id_cgi(),
    55                       params = param.get_all_cgi()
    56                     }
    57                   }
    58                 }
    59               else
    60                 ui.link{
    61                   attr = { class = "action" },
    62                   text = _"Publish",
    63                   module = "contact",
    64                   action = "add_member",
    65                   id = record.other_member_id,
    66                   params = { public = true },
    67                   routing = {
    68                     default = {
    69                       mode = "redirect",
    70                       module = request.get_module(),
    71                       view = request.get_view(),
    72                       id = param.get_id_cgi(),
    73                       params = param.get_all_cgi()
    74                     }
    75                   }
    76                 }
    77               end
    78             end
    79           },
    80           {
    81             content = function(record)
    82               ui.link{
    83                 attr = { class = "action" },
    84                 text = _"Remove",
    85                 module = "contact",
    86                 action = "remove_member",
    87                 id = record.other_member_id,
    88                 routing = {
    89                   default = {
    90                     mode = "redirect",
    91                     module = request.get_module(),
    92                     view = request.get_view(),
    93                     id = param.get_id_cgi(),
    94                     params = param.get_all_cgi()
    95                   }
    96                 }
    97               }
    98             end
    99           },
   100         }
   101       }
   102     end
   103   end
   104 }
