liquid_feedback_frontend
changeset 1621:a17ad625ffbc
Reworked member edit view
author | bsw |
---|---|
date | Sat Feb 06 22:44:34 2021 +0100 (2021-02-06) |
parents | e7a0f1235ac0 |
children | 72442abafb3c |
files | app/main/admin/member_deactivate.lua app/main/admin/member_edit.lua env/ui/titleAdmin.lua |
line diff
1.1 --- a/app/main/admin/member_deactivate.lua Tue Feb 02 21:32:13 2021 +0100 1.2 +++ b/app/main/admin/member_deactivate.lua Sat Feb 06 22:44:34 2021 +0100 1.3 @@ -2,42 +2,63 @@ 1.4 1.5 local member = Member:by_id(id) 1.6 1.7 -ui.title(_"Deactivate member") 1.8 +--ui.title(_"Deactivate member") 1.9 + 1.10 +ui.titleAdmin(_"Member") 1.11 + 1.12 +ui.grid{ content = function() 1.13 + 1.14 + ui.cell_main{ content = function() 1.15 + ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function() 1.16 + ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function() 1.17 + ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"Deactivate member" } 1.18 + end } 1.19 + ui.container{ attr = { class = "mdl-card__content" }, content = function() 1.20 1.21 1.22 -ui.form{ 1.23 - attr = { class = "vertical section" }, 1.24 - module = "admin", 1.25 - action = "member_deactivate", 1.26 - id = member and member.id, 1.27 - record = member, 1.28 - routing = { 1.29 - error = { 1.30 - mode = "forward", 1.31 - module = "admin", view = "member_deactivate", id = id 1.32 - }, 1.33 - default = { 1.34 - mode = "redirect", 1.35 - modules = "admin", view = "index" 1.36 - } 1.37 - }, 1.38 - content = function() 1.39 - ui.sectionHead( function() 1.40 - ui.heading { level = 1, content = member and (member.name or member.id) or _"New member" } 1.41 - if member and member.identification then 1.42 - ui.heading { level = 3, content = member.identification } 1.43 - end 1.44 - end ) 1.45 - ui.sectionRow(function() 1.46 - ui.heading { level = 2, content = _"Do you really want to irrevocably deactive this member?" } 1.47 - ui.tag{ tag = "input", attr = { type = "checkbox", name = "sure", value = "yes" } } 1.48 - ui.tag { content = _"I want to deactive this member irrevocably" } 1.49 - slot.put("<br />") 1.50 - slot.put("<br />") 1.51 - ui.submit{ text = _"Deactivate member" } 1.52 - slot.put(" ") 1.53 - ui.link { module = "admin", view = "member_edit", id = member.id, content = _"cancel" } 1.54 - end) 1.55 - end 1.56 -} 1.57 + ui.form{ 1.58 + attr = { class = "vertical section" }, 1.59 + module = "admin", 1.60 + action = "member_deactivate", 1.61 + id = member and member.id, 1.62 + record = member, 1.63 + routing = { 1.64 + error = { 1.65 + mode = "forward", 1.66 + module = "admin", view = "member_deactivate", id = id 1.67 + }, 1.68 + default = { 1.69 + mode = "redirect", 1.70 + modules = "admin", view = "index" 1.71 + } 1.72 + }, 1.73 + content = function() 1.74 1.75 + ui.container{ content = _"Do you really want to irrevocably deactive this member?" } 1.76 + slot.put("<br>") 1.77 + ui.container{ content = _"ID" .. ": " .. member.id } 1.78 + ui.container{ content = _"Identification" .. ": " .. member.identification } 1.79 + ui.container{ content = _"Screen name" .. ": " .. member.name } 1.80 + slot.put("<br>") 1.81 + ui.tag{ tag = "input", attr = { type = "checkbox", name = "sure", value = "yes" } } 1.82 + ui.tag { content = _"I want to deactive this member irrevocably" } 1.83 + slot.put("<br />") 1.84 + slot.put("<br />") 1.85 + 1.86 + ui.submit{ 1.87 + attr = { class = "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" }, 1.88 + text = _"Deactivate member" 1.89 + } 1.90 + slot.put(" ") 1.91 + ui.link { 1.92 + attr = { class = "mdl-button mdl-js-button" }, 1.93 + module = "admin", view = "member_edit", id = member.id, content = _"cancel" 1.94 + } 1.95 + 1.96 + end 1.97 + } 1.98 + end } 1.99 + end } 1.100 + end } 1.101 +end } 1.102 +
2.1 --- a/app/main/admin/member_edit.lua Tue Feb 02 21:32:13 2021 +0100 2.2 +++ b/app/main/admin/member_edit.lua Sat Feb 06 22:44:34 2021 +0100 2.3 @@ -1,3 +1,42 @@ 2.4 +local function field(name, label, value, tooltip) 2.5 + ui.field.text{ 2.6 + container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" }, 2.7 + attr = { id = "field_" .. name, class = "mdl-textfield__input" }, 2.8 + label_attr = { class = "mdl-textfield__label", ["for"] = "field_" .. name }, 2.9 + label = label, 2.10 + name = name, 2.11 + value = value or nil 2.12 + } 2.13 + if tooltip then 2.14 + ui.container{ attr = { class = "mdl-tooltip", ["for"] = "field_" .. name }, content = tooltip } 2.15 + end 2.16 +end 2.17 + 2.18 +local function field_boolean(id, name, checked, label) 2.19 + ui.container{ content = function() 2.20 + ui.tag{ tag = "label", attr = { 2.21 + class = "mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect", 2.22 + ["for"] = id 2.23 + }, 2.24 + content = function() 2.25 + ui.tag{ 2.26 + tag = "input", 2.27 + attr = { 2.28 + id = id, 2.29 + class = "mdl-checkbox__input", 2.30 + type = "checkbox", name = name, value = "true", 2.31 + checked = checked and "checked" or nil, 2.32 + } 2.33 + } 2.34 + ui.tag{ 2.35 + attr = { class = "mdl-checkbox__label", ['for'] = id }, 2.36 + content = label 2.37 + } 2.38 + end 2.39 + } 2.40 + end } 2.41 +end 2.42 + 2.43 local id = param.get_id() 2.44 2.45 local member = Member:by_id(id) 2.46 @@ -22,7 +61,11 @@ 2.47 ui.cell_main{ content = function() 2.48 ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function() 2.49 ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function() 2.50 - ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"Member" } 2.51 + local text = _"Member" 2.52 + if member then 2.53 + text = text .. " ID " .. member.id 2.54 + end 2.55 + ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = text } 2.56 end } 2.57 ui.container{ attr = { class = "mdl-card__content" }, content = function() 2.58 ui.form{ 2.59 @@ -41,26 +84,30 @@ 2.60 }, 2.61 content = function() 2.62 2.63 - ui.field.text{ label = _"Identification", name = "identification" } 2.64 - ui.field.text{ label = _"Notification email (confirmed)", name = "notify_email" } 2.65 - ui.field.text{ label = _"Notification email (unconfirmed)", name = "notify_email_unconfirmed" } 2.66 + ui.container{ content = function() 2.67 + field("identification", _"Identification") 2.68 + if member and member.activated then 2.69 + slot.put(" ") 2.70 + field("name", "Screen name") 2.71 + end 2.72 + end } 2.73 + ui.container{ content = function() 2.74 + field("notify_email", _"Notification email (confirmed)") 2.75 + slot.put(" ") 2.76 + field("notify_email_unconfirmed", _"Notification email (unconfirmed)") 2.77 + end } 2.78 +-- field("", "") 2.79 2.80 - if member and member.activated then 2.81 - ui.field.text{ label = _"Screen name", name = "name" } 2.82 - end 2.83 2.84 if member and member.activated and not deactivated then 2.85 - ui.field.text{ label = _"Login name", name = "login" } 2.86 + field("login", "Login name") 2.87 end 2.88 2.89 for i, unit in ipairs(units) do 2.90 - ui.field.boolean{ 2.91 - name = "unit_" .. unit.id, 2.92 - label = unit.name, 2.93 - value = unit.voting_right 2.94 - } 2.95 + field_boolean("checkbox_unit_" .. unit.id, "unit_" .. unit.id, unit.voting_right, unit.name) 2.96 + 2.97 end 2.98 - slot.put("<br /><br />") 2.99 + slot.put("<br />") 2.100 2.101 if member then 2.102 ui.field.text{ label = _"Activated", name = "activated", readonly = true } 2.103 @@ -91,13 +138,13 @@ 2.104 attr = { class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-js-ripple-effect" }, 2.105 text = _"update member" 2.106 } 2.107 - slot.put(" ") 2.108 + slot.put(" ") 2.109 if member then 2.110 ui.link { 2.111 - attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, 2.112 + attr = { class = "mdl-button mdl-js-button" }, 2.113 module = "admin", view = "member_deactivate", content = _"Deactivate member", id = member.id 2.114 } 2.115 - slot.put(" ") 2.116 + slot.put(" ") 2.117 end 2.118 ui.link { 2.119 attr = { class = "mdl-button mdl-js-button" },
3.1 --- a/env/ui/titleAdmin.lua Tue Feb 02 21:32:13 2021 +0100 3.2 +++ b/env/ui/titleAdmin.lua Sat Feb 06 22:44:34 2021 +0100 3.3 @@ -1,13 +1,13 @@ 3.4 function ui.titleAdmin(title) 3.5 ui.title(function() 3.6 if title then 3.7 - ui.link { module = "admin", view = "index", content = _"System administration" } 3.8 + ui.link { module = "admin", view = "index", content = _"System settings" } 3.9 else 3.10 - ui.tag{ content = _"System administration" } 3.11 + ui.tag{ content = _"System settings" } 3.12 end 3.13 if title then 3.14 slot.put ( " ยป " ) 3.15 ui.tag { tag = "span", content = title } 3.16 end 3.17 end) 3.18 -end 3.19 \ No newline at end of file 3.20 +end