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