liquid_feedback_frontend
diff app/main/admin/member_edit.lua @ 1621:a17ad625ffbc
Reworked member edit view
author | bsw |
---|---|
date | Sat Feb 06 22:44:34 2021 +0100 (2021-02-06) |
parents | 22a1a6711154 |
children | 40a388c07af9 |
line diff
1.1 --- a/app/main/admin/member_edit.lua Tue Feb 02 21:32:13 2021 +0100 1.2 +++ b/app/main/admin/member_edit.lua Sat Feb 06 22:44:34 2021 +0100 1.3 @@ -1,3 +1,42 @@ 1.4 +local function field(name, label, value, tooltip) 1.5 + ui.field.text{ 1.6 + container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" }, 1.7 + attr = { id = "field_" .. name, class = "mdl-textfield__input" }, 1.8 + label_attr = { class = "mdl-textfield__label", ["for"] = "field_" .. name }, 1.9 + label = label, 1.10 + name = name, 1.11 + value = value or nil 1.12 + } 1.13 + if tooltip then 1.14 + ui.container{ attr = { class = "mdl-tooltip", ["for"] = "field_" .. name }, content = tooltip } 1.15 + end 1.16 +end 1.17 + 1.18 +local function field_boolean(id, name, checked, label) 1.19 + ui.container{ content = function() 1.20 + ui.tag{ tag = "label", attr = { 1.21 + class = "mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect", 1.22 + ["for"] = id 1.23 + }, 1.24 + content = function() 1.25 + ui.tag{ 1.26 + tag = "input", 1.27 + attr = { 1.28 + id = id, 1.29 + class = "mdl-checkbox__input", 1.30 + type = "checkbox", name = name, value = "true", 1.31 + checked = checked and "checked" or nil, 1.32 + } 1.33 + } 1.34 + ui.tag{ 1.35 + attr = { class = "mdl-checkbox__label", ['for'] = id }, 1.36 + content = label 1.37 + } 1.38 + end 1.39 + } 1.40 + end } 1.41 +end 1.42 + 1.43 local id = param.get_id() 1.44 1.45 local member = Member:by_id(id) 1.46 @@ -22,7 +61,11 @@ 1.47 ui.cell_main{ content = function() 1.48 ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function() 1.49 ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function() 1.50 - ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"Member" } 1.51 + local text = _"Member" 1.52 + if member then 1.53 + text = text .. " ID " .. member.id 1.54 + end 1.55 + ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = text } 1.56 end } 1.57 ui.container{ attr = { class = "mdl-card__content" }, content = function() 1.58 ui.form{ 1.59 @@ -41,26 +84,30 @@ 1.60 }, 1.61 content = function() 1.62 1.63 - ui.field.text{ label = _"Identification", name = "identification" } 1.64 - ui.field.text{ label = _"Notification email (confirmed)", name = "notify_email" } 1.65 - ui.field.text{ label = _"Notification email (unconfirmed)", name = "notify_email_unconfirmed" } 1.66 + ui.container{ content = function() 1.67 + field("identification", _"Identification") 1.68 + if member and member.activated then 1.69 + slot.put(" ") 1.70 + field("name", "Screen name") 1.71 + end 1.72 + end } 1.73 + ui.container{ content = function() 1.74 + field("notify_email", _"Notification email (confirmed)") 1.75 + slot.put(" ") 1.76 + field("notify_email_unconfirmed", _"Notification email (unconfirmed)") 1.77 + end } 1.78 +-- field("", "") 1.79 1.80 - if member and member.activated then 1.81 - ui.field.text{ label = _"Screen name", name = "name" } 1.82 - end 1.83 1.84 if member and member.activated and not deactivated then 1.85 - ui.field.text{ label = _"Login name", name = "login" } 1.86 + field("login", "Login name") 1.87 end 1.88 1.89 for i, unit in ipairs(units) do 1.90 - ui.field.boolean{ 1.91 - name = "unit_" .. unit.id, 1.92 - label = unit.name, 1.93 - value = unit.voting_right 1.94 - } 1.95 + field_boolean("checkbox_unit_" .. unit.id, "unit_" .. unit.id, unit.voting_right, unit.name) 1.96 + 1.97 end 1.98 - slot.put("<br /><br />") 1.99 + slot.put("<br />") 1.100 1.101 if member then 1.102 ui.field.text{ label = _"Activated", name = "activated", readonly = true } 1.103 @@ -91,13 +138,13 @@ 1.104 attr = { class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-js-ripple-effect" }, 1.105 text = _"update member" 1.106 } 1.107 - slot.put(" ") 1.108 + slot.put(" ") 1.109 if member then 1.110 ui.link { 1.111 - attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, 1.112 + attr = { class = "mdl-button mdl-js-button" }, 1.113 module = "admin", view = "member_deactivate", content = _"Deactivate member", id = member.id 1.114 } 1.115 - slot.put(" ") 1.116 + slot.put(" ") 1.117 end 1.118 ui.link { 1.119 attr = { class = "mdl-button mdl-js-button" },