| rev | 
   line source | 
| 
bsw@581
 | 
     1 local search = param.get("search")
 | 
| 
bsw@193
 | 
     2 
 | 
| 
bsw@581
 | 
     3 ui.title(_"Member list")
 | 
| 
bsw/jbe@0
 | 
     4 
 | 
| 
bsw@603
 | 
     5 ui.actions(function()
 | 
| 
bsw@603
 | 
     6   ui.link{
 | 
| 
bsw@603
 | 
     7     attr = { class = { "admin_only" } },
 | 
| 
bsw@603
 | 
     8     text = _"Register new member",
 | 
| 
bsw@603
 | 
     9     module = "admin",
 | 
| 
bsw@603
 | 
    10     view = "member_edit"
 | 
| 
bsw@603
 | 
    11   }
 | 
| 
bsw/jbe@0
 | 
    12 end)
 | 
| 
bsw/jbe@0
 | 
    13 
 | 
| 
bsw/jbe@0
 | 
    14 
 | 
| 
bsw@581
 | 
    15 ui.form{
 | 
| 
bsw@581
 | 
    16   module = "admin", view = "member_list",
 | 
| 
bsw@581
 | 
    17   content = function()
 | 
| 
bsw@581
 | 
    18   
 | 
| 
bsw@581
 | 
    19     ui.field.text{ label = _"Search for members", name = "search" }
 | 
| 
bsw@581
 | 
    20     
 | 
| 
bsw@581
 | 
    21     ui.submit{ value = _"Start search" }
 | 
| 
bsw@581
 | 
    22   
 | 
| 
bsw@581
 | 
    23   end
 | 
| 
bsw@581
 | 
    24 }
 | 
| 
bsw@581
 | 
    25 
 | 
| 
bsw@584
 | 
    26 if not search then
 | 
| 
bsw@584
 | 
    27   return
 | 
| 
bsw@584
 | 
    28 end
 | 
| 
bsw@584
 | 
    29 
 | 
| 
bsw@584
 | 
    30 local members_selector = Member:build_selector{
 | 
| 
bsw@584
 | 
    31   admin_search = search,
 | 
| 
bsw@584
 | 
    32   order = "identification"
 | 
| 
bsw@584
 | 
    33 }
 | 
| 
bsw@584
 | 
    34 
 | 
| 
bsw@584
 | 
    35 
 | 
| 
bsw/jbe@0
 | 
    36 ui.paginate{
 | 
| 
bsw/jbe@0
 | 
    37   selector = members_selector,
 | 
| 
bsw@193
 | 
    38   per_page = 30,
 | 
| 
bsw/jbe@0
 | 
    39   content = function() 
 | 
| 
bsw/jbe@0
 | 
    40     ui.list{
 | 
| 
bsw/jbe@0
 | 
    41       records = members_selector:exec(),
 | 
| 
bsw/jbe@0
 | 
    42       columns = {
 | 
| 
bsw/jbe@0
 | 
    43         {
 | 
| 
bsw/jbe@0
 | 
    44           field_attr = { style = "text-align: right;" },
 | 
| 
bsw/jbe@0
 | 
    45           label = _"Id",
 | 
| 
bsw/jbe@0
 | 
    46           name = "id"
 | 
| 
bsw/jbe@0
 | 
    47         },
 | 
| 
bsw/jbe@0
 | 
    48         {
 | 
| 
bsw@581
 | 
    49           label = _"Identification",
 | 
| 
bsw@581
 | 
    50           name = "identification"
 | 
| 
bsw/jbe@0
 | 
    51         },
 | 
| 
bsw/jbe@0
 | 
    52         {
 | 
| 
bsw@581
 | 
    53           label = _"Screen name",
 | 
| 
bsw@581
 | 
    54           name = "name"
 | 
| 
bsw@581
 | 
    55         },
 | 
| 
bsw@581
 | 
    56         {
 | 
| 
bsw@581
 | 
    57           label = _"Admin?",
 | 
| 
bsw/jbe@0
 | 
    58           content = function(record)
 | 
| 
bsw@581
 | 
    59             if record.admin then
 | 
| 
bsw@581
 | 
    60               ui.field.text{ value = "admin" }
 | 
| 
bsw@581
 | 
    61             end
 | 
| 
bsw/jbe@0
 | 
    62           end
 | 
| 
bsw/jbe@0
 | 
    63         },
 | 
| 
bsw/jbe@0
 | 
    64         {
 | 
| 
bsw/jbe@0
 | 
    65           content = function(record)
 | 
| 
bsw@590
 | 
    66             if not record.activated then
 | 
| 
bsw@581
 | 
    67               ui.field.text{ value = "not activated" }
 | 
| 
bsw@581
 | 
    68             elseif not record.active then
 | 
| 
bsw@581
 | 
    69               ui.field.text{ value = "inactive" }
 | 
| 
bsw@584
 | 
    70             else
 | 
| 
bsw@584
 | 
    71               ui.field.text{ value = "active" }
 | 
| 
bsw/jbe@0
 | 
    72             end
 | 
| 
bsw/jbe@0
 | 
    73           end
 | 
| 
bsw/jbe@0
 | 
    74         },
 | 
| 
bsw/jbe@0
 | 
    75         {
 | 
| 
bsw/jbe@0
 | 
    76           content = function(record)
 | 
| 
bsw@590
 | 
    77             if record.locked then
 | 
| 
bsw@590
 | 
    78               ui.field.text{ value = "locked" }
 | 
| 
bsw@590
 | 
    79             end
 | 
| 
bsw@590
 | 
    80           end
 | 
| 
bsw@590
 | 
    81         },
 | 
| 
bsw@590
 | 
    82         {
 | 
| 
bsw@590
 | 
    83           content = function(record)
 | 
| 
bsw@193
 | 
    84             ui.link{
 | 
| 
bsw@193
 | 
    85               attr = { class = "action admin_only" },
 | 
| 
bsw@193
 | 
    86               text = _"Edit",
 | 
| 
bsw@193
 | 
    87               module = "admin",
 | 
| 
bsw@193
 | 
    88               view = "member_edit",
 | 
| 
bsw@193
 | 
    89               id = record.id
 | 
| 
bsw@193
 | 
    90             }
 | 
| 
bsw/jbe@0
 | 
    91           end
 | 
| 
bsw/jbe@0
 | 
    92         }
 | 
| 
bsw/jbe@0
 | 
    93       }
 | 
| 
bsw/jbe@0
 | 
    94     }
 | 
| 
bsw/jbe@0
 | 
    95   end
 | 
| 
bsw/jbe@0
 | 
    96 } |