liquid_feedback_frontend
view app/main/admin/member_edit.lua @ 1859:02c34183b6df
Fixed wrong filename in INSTALL file
| author | bsw | 
|---|---|
| date | Tue Nov 28 18:54:51 2023 +0100 (23 months ago) | 
| parents | 5e70733e1757 | 
| children | 
 line source
     1 local function field(name, label, value, tooltip)
     2   ui.field.text{
     3     container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" },
     4     attr = { id = "field_" .. name, class = "mdl-textfield__input" },
     5     label_attr = { class = "mdl-textfield__label", ["for"] = "field_" .. name },
     6     label = label,
     7     name = name,
     8     value = value or nil
     9   }
    10   if tooltip then
    11     ui.container{ attr = { class = "mdl-tooltip", ["for"] = "field_" .. name }, content = tooltip }
    12   end
    13 end
    15 local function field_boolean(id, name, checked, label, depth)
    16   ui.container{ attr = { style = "margin-left: " .. (depth -1) * 24 .. "px;" }, content = function()
    17     ui.tag{ tag = "label", attr = {
    18         class = "mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect",
    19         ["for"] = id
    20       },
    21       content = function()
    22         ui.tag{
    23           tag = "input",
    24           attr = {
    25             id = id,
    26             class = "mdl-checkbox__input",
    27             type = "checkbox", name = name, value = "true",
    28             checked = checked and "checked" or nil,
    29           }
    30         }
    31         ui.tag{
    32           attr = { class = "mdl-checkbox__label", ['for'] = id },
    33           content = label
    34         } 
    35       end
    36     }
    37   end }
    38 end
    40 local id = param.get_id()
    42 local member = Member:by_id(id)
    44 local deactivated = member and member.locked and member.login == nil and member.authority_login == nil
    46 ui.titleAdmin(_"Member")
    48 local units = Unit:get_flattened_tree{ include_inactive = inactive, include_hidden = true, member_id = member and member.id }
    50 ui.grid{ content = function()
    52   ui.cell_main{ content = function()
    53     ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
    54       ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
    55         local text = _"Member"
    56         if member then
    57           text = text .. " ID " .. member.id
    58         end
    59         ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = text }
    60       end }
    61       ui.container{ attr = { class = "mdl-card__content" }, content = function()
    62         ui.form{
    63           attr = { class = "vertical section" },
    64           module = "admin",
    65           action = "member_update",
    66           id = member and member.id,
    67           record = member,
    68           readonly = not app.session.member.admin,
    69           routing = {
    70             default = {
    71               mode = "redirect",
    72               modules = "admin",
    73               view = "index"
    74             }
    75           },
    76           content = function()
    78             ui.container{ content = function()
    79               field("identification", _"Identification")
    80               if member and member.activated then
    81                 slot.put("   ")
    82                 field("name", "Screen name")
    83               end
    84             end }
    85             ui.container{ content = function()
    86               field("notify_email", _"Notification email (confirmed)")
    87               slot.put("   ")
    88               field("notify_email_unconfirmed", _"Notification email (unconfirmed)")
    89             end }
    90 --            field("", "")
    93             if member and member.activated and not deactivated then
    94               field("login", "Login name")
    95             end
    97             for i, unit in ipairs(units) do
    98               field_boolean("checkbox_unit_" .. unit.id, "unit_" .. unit.id, unit.voting_right, unit.name, unit.depth)
   100             end
   101             slot.put("<br />")
   103             if member then
   104               ui.field.text{  label = _"Activated",       name = "activated", readonly = true }
   105             end
   107             if not member or not member.activated then
   108               ui.field.boolean{  label = _"Send invite?",       name = "invite_member" }
   109             end
   111             if member then
   112               ui.field.boolean{ 
   113                 label = _"Member inactive?", name = "deactivate",
   114                 readonly = true, 
   115                 value = member and member.active == false
   116               }
   117             end
   119             if member then
   120               ui.field.boolean{
   121                 label = _"Lock member?", name = "locked",
   122               }
   123             end
   125             slot.put("<br />")
   126             ui.field.boolean{  label = _"Admin?", name = "admin" }
   127             slot.put("<br />")
   128             ui.submit{
   129               attr = { class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-js-ripple-effect" },
   130               text  = _"update member"
   131             }
   132             slot.put("   ")
   133             if member then
   134               ui.link { 
   135                 attr = { class = "mdl-button mdl-js-button" },
   136                 module = "admin", view = "member_deactivate", content = _"Deactivate member", id = member.id 
   137               }
   138               slot.put("   ")
   139             end
   140             ui.link {
   141                 attr = { class = "mdl-button mdl-js-button" },
   142                 module = "admin", view = "index", content = _"cancel"
   143             }
   145           end
   146         }
   147       end }
   148     end }
   149   end }
   150 end }
