| rev | 
   line source | 
| 
bsw/jbe@0
 | 
     1 local id = param.get_id()
 | 
| 
bsw/jbe@0
 | 
     2 
 | 
| 
bsw@193
 | 
     3 local member = Member:by_id(id)
 | 
| 
bsw@193
 | 
     4 
 | 
| 
bsw@1088
 | 
     5 local deactivated = member and member.locked and member.login == nil and member.authority_login == nil
 | 
| 
bsw@1088
 | 
     6 
 | 
| 
bsw@1184
 | 
     7 ui.titleAdmin(_"Member")
 | 
| 
bsw/jbe@0
 | 
     8 
 | 
| 
bsw@513
 | 
     9 local units_selector = Unit:new_selector()
 | 
| 
bsw@512
 | 
    10   
 | 
| 
bsw@513
 | 
    11 if member then
 | 
| 
bsw@513
 | 
    12   units_selector
 | 
| 
bsw@513
 | 
    13     :left_join("privilege", nil, { "privilege.member_id = ? AND privilege.unit_id = unit.id", member.id })
 | 
| 
bsw@513
 | 
    14     :add_field("privilege.voting_right", "voting_right")
 | 
| 
bsw@1438
 | 
    15     :add_order_by("unit.name")
 | 
| 
bsw@513
 | 
    16 end
 | 
| 
bsw@513
 | 
    17 
 | 
| 
bsw@513
 | 
    18 local units = units_selector:exec()
 | 
| 
bsw@512
 | 
    19   
 | 
| 
bsw@1455
 | 
    20 ui.grid{ content = function()
 | 
| 
bsw@310
 | 
    21 
 | 
| 
bsw@1455
 | 
    22   ui.cell_main{ content = function()
 | 
| 
bsw@1455
 | 
    23     ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
 | 
| 
bsw@1455
 | 
    24       ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
 | 
| 
bsw@1455
 | 
    25         ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"Member" }
 | 
| 
bsw@1455
 | 
    26       end }
 | 
| 
bsw@1455
 | 
    27       ui.container{ attr = { class = "mdl-card__content" }, content = function()
 | 
| 
bsw@1455
 | 
    28         ui.form{
 | 
| 
bsw@1455
 | 
    29           attr = { class = "vertical section" },
 | 
| 
bsw@1455
 | 
    30           module = "admin",
 | 
| 
bsw@1455
 | 
    31           action = "member_update",
 | 
| 
bsw@1455
 | 
    32           id = member and member.id,
 | 
| 
bsw@1455
 | 
    33           record = member,
 | 
| 
bsw@1455
 | 
    34           readonly = not app.session.member.admin,
 | 
| 
bsw@1455
 | 
    35           routing = {
 | 
| 
bsw@1455
 | 
    36             default = {
 | 
| 
bsw@1455
 | 
    37               mode = "redirect",
 | 
| 
bsw@1455
 | 
    38               modules = "admin",
 | 
| 
bsw@1455
 | 
    39               view = "index"
 | 
| 
bsw@1455
 | 
    40             }
 | 
| 
bsw@1455
 | 
    41           },
 | 
| 
bsw@1455
 | 
    42           content = function()
 | 
| 
bsw@1455
 | 
    43 
 | 
| 
bsw@1456
 | 
    44             ui.field.text{     label = _"Identification", name = "identification" }
 | 
| 
bsw@1456
 | 
    45             ui.field.text{     label = _"Notification email (confirmed)", name = "notify_email" }
 | 
| 
bsw@1456
 | 
    46             ui.field.text{     label = _"Notification email (unconfirmed)", name = "notify_email_unconfirmed" }
 | 
| 
bsw@1458
 | 
    47             
 | 
| 
bsw@1456
 | 
    48             if member and member.activated then
 | 
| 
bsw@1456
 | 
    49               ui.field.text{     label = _"Screen name",        name = "name" }
 | 
| 
bsw@1456
 | 
    50             end
 | 
| 
bsw@1456
 | 
    51             
 | 
| 
bsw@1456
 | 
    52             if member and member.activated and not deactivated then
 | 
| 
bsw@1456
 | 
    53               ui.field.text{     label = _"Login name",        name = "login" }
 | 
| 
bsw@1456
 | 
    54             end
 | 
| 
bsw@1088
 | 
    55 
 | 
| 
bsw@1456
 | 
    56             for i, unit in ipairs(units) do
 | 
| 
bsw@1456
 | 
    57               ui.field.boolean{
 | 
| 
bsw@1459
 | 
    58                 name = "unit_" .. unit.id,
 | 
| 
bsw@1459
 | 
    59                 label = unit.name,
 | 
| 
bsw@1459
 | 
    60                 value = unit.voting_right
 | 
| 
bsw@1459
 | 
    61               }
 | 
| 
bsw@1458
 | 
    62             end
 | 
| 
bsw@1455
 | 
    63             slot.put("<br /><br />")
 | 
| 
bsw@1045
 | 
    64 
 | 
| 
bsw@1455
 | 
    65             if member then
 | 
| 
bsw@1455
 | 
    66               ui.field.text{  label = _"Activated",       name = "activated", readonly = true }
 | 
| 
bsw@1455
 | 
    67             end
 | 
| 
bsw@1455
 | 
    68               
 | 
| 
bsw@1455
 | 
    69             if not member or not member.activated then
 | 
| 
bsw@1455
 | 
    70               ui.field.boolean{  label = _"Send invite?",       name = "invite_member" }
 | 
| 
bsw@1455
 | 
    71             end
 | 
| 
bsw@1455
 | 
    72             
 | 
| 
bsw@1455
 | 
    73             if member then
 | 
| 
bsw@1455
 | 
    74               ui.field.boolean{ 
 | 
| 
bsw@1455
 | 
    75                 label = _"Member inactive?", name = "deactivate",
 | 
| 
bsw@1455
 | 
    76                 readonly = true, 
 | 
| 
bsw@1455
 | 
    77                 value = member and member.active == false
 | 
| 
bsw@1455
 | 
    78               }
 | 
| 
bsw@1455
 | 
    79             end
 | 
| 
bsw@1455
 | 
    80             
 | 
| 
bsw@1455
 | 
    81             if member then
 | 
| 
bsw@1455
 | 
    82               ui.field.boolean{
 | 
| 
bsw@1455
 | 
    83                 label = _"Lock member?", name = "locked",
 | 
| 
bsw@1455
 | 
    84               }
 | 
| 
bsw@1455
 | 
    85             end
 | 
| 
bsw@1455
 | 
    86             
 | 
| 
bsw@1455
 | 
    87             slot.put("<br />")
 | 
| 
bsw@1455
 | 
    88             ui.field.boolean{  label = _"Admin?", name = "admin" }
 | 
| 
bsw@1455
 | 
    89             slot.put("<br />")
 | 
| 
bsw@1461
 | 
    90             ui.submit{
 | 
| 
bsw@1461
 | 
    91               attr = { class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-js-ripple-effect" },
 | 
| 
bsw@1461
 | 
    92               text  = _"update member"
 | 
| 
bsw@1461
 | 
    93             }
 | 
| 
bsw@1455
 | 
    94             slot.put(" ")
 | 
| 
bsw@1455
 | 
    95             if member then
 | 
| 
bsw@1461
 | 
    96               ui.link { 
 | 
| 
bsw@1461
 | 
    97                 attr = { class = "mdl-button mdl-js-button mdl-button--raised" },
 | 
| 
bsw@1461
 | 
    98                 module = "admin", view = "member_deactivate", content = _"Deactivate member", id = member.id 
 | 
| 
bsw@1461
 | 
    99               }
 | 
| 
bsw@1455
 | 
   100               slot.put(" ")
 | 
| 
bsw@1455
 | 
   101             end
 | 
| 
bsw@1461
 | 
   102             ui.link {
 | 
| 
bsw@1461
 | 
   103                 attr = { class = "mdl-button mdl-js-button" },
 | 
| 
bsw@1461
 | 
   104                 module = "admin", view = "index", content = _"cancel"
 | 
| 
bsw@1461
 | 
   105             }
 | 
| 
bsw@1456
 | 
   106 
 | 
| 
bsw@1457
 | 
   107           end
 | 
| 
bsw@1457
 | 
   108         }
 | 
| 
bsw@1457
 | 
   109       end }
 | 
| 
bsw@1455
 | 
   110     end }
 | 
| 
bsw@1455
 | 
   111   end }
 | 
| 
bsw@1455
 | 
   112 end }
 |