# HG changeset patch
# User bsw
# Date 1612647874 -3600
# Node ID a17ad625ffbcf37641b6359b5e4b38d40f622370
# Parent e7a0f1235ac0e4587776ea57b04b2b5c412707e5
Reworked member edit view
diff -r e7a0f1235ac0 -r a17ad625ffbc app/main/admin/member_deactivate.lua
--- a/app/main/admin/member_deactivate.lua Tue Feb 02 21:32:13 2021 +0100
+++ b/app/main/admin/member_deactivate.lua Sat Feb 06 22:44:34 2021 +0100
@@ -2,42 +2,63 @@
local member = Member:by_id(id)
-ui.title(_"Deactivate member")
+--ui.title(_"Deactivate member")
+
+ui.titleAdmin(_"Member")
+
+ui.grid{ content = function()
+
+ ui.cell_main{ content = function()
+ ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
+ ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
+ ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"Deactivate member" }
+ end }
+ ui.container{ attr = { class = "mdl-card__content" }, content = function()
-ui.form{
- attr = { class = "vertical section" },
- module = "admin",
- action = "member_deactivate",
- id = member and member.id,
- record = member,
- routing = {
- error = {
- mode = "forward",
- module = "admin", view = "member_deactivate", id = id
- },
- default = {
- mode = "redirect",
- modules = "admin", view = "index"
- }
- },
- content = function()
- ui.sectionHead( function()
- ui.heading { level = 1, content = member and (member.name or member.id) or _"New member" }
- if member and member.identification then
- ui.heading { level = 3, content = member.identification }
- end
- end )
- ui.sectionRow(function()
- ui.heading { level = 2, content = _"Do you really want to irrevocably deactive this member?" }
- ui.tag{ tag = "input", attr = { type = "checkbox", name = "sure", value = "yes" } }
- ui.tag { content = _"I want to deactive this member irrevocably" }
- slot.put("
")
- slot.put("
")
- ui.submit{ text = _"Deactivate member" }
- slot.put(" ")
- ui.link { module = "admin", view = "member_edit", id = member.id, content = _"cancel" }
- end)
- end
-}
+ ui.form{
+ attr = { class = "vertical section" },
+ module = "admin",
+ action = "member_deactivate",
+ id = member and member.id,
+ record = member,
+ routing = {
+ error = {
+ mode = "forward",
+ module = "admin", view = "member_deactivate", id = id
+ },
+ default = {
+ mode = "redirect",
+ modules = "admin", view = "index"
+ }
+ },
+ content = function()
+ ui.container{ content = _"Do you really want to irrevocably deactive this member?" }
+ slot.put("
")
+ ui.container{ content = _"ID" .. ": " .. member.id }
+ ui.container{ content = _"Identification" .. ": " .. member.identification }
+ ui.container{ content = _"Screen name" .. ": " .. member.name }
+ slot.put("
")
+ ui.tag{ tag = "input", attr = { type = "checkbox", name = "sure", value = "yes" } }
+ ui.tag { content = _"I want to deactive this member irrevocably" }
+ slot.put("
")
+ slot.put("
")
+
+ ui.submit{
+ attr = { class = "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" },
+ text = _"Deactivate member"
+ }
+ slot.put(" ")
+ ui.link {
+ attr = { class = "mdl-button mdl-js-button" },
+ module = "admin", view = "member_edit", id = member.id, content = _"cancel"
+ }
+
+ end
+ }
+ end }
+ end }
+ end }
+end }
+
diff -r e7a0f1235ac0 -r a17ad625ffbc app/main/admin/member_edit.lua
--- a/app/main/admin/member_edit.lua Tue Feb 02 21:32:13 2021 +0100
+++ b/app/main/admin/member_edit.lua Sat Feb 06 22:44:34 2021 +0100
@@ -1,3 +1,42 @@
+local function field(name, label, value, tooltip)
+ ui.field.text{
+ container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" },
+ attr = { id = "field_" .. name, class = "mdl-textfield__input" },
+ label_attr = { class = "mdl-textfield__label", ["for"] = "field_" .. name },
+ label = label,
+ name = name,
+ value = value or nil
+ }
+ if tooltip then
+ ui.container{ attr = { class = "mdl-tooltip", ["for"] = "field_" .. name }, content = tooltip }
+ end
+end
+
+local function field_boolean(id, name, checked, label)
+ ui.container{ content = function()
+ ui.tag{ tag = "label", attr = {
+ class = "mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect",
+ ["for"] = id
+ },
+ content = function()
+ ui.tag{
+ tag = "input",
+ attr = {
+ id = id,
+ class = "mdl-checkbox__input",
+ type = "checkbox", name = name, value = "true",
+ checked = checked and "checked" or nil,
+ }
+ }
+ ui.tag{
+ attr = { class = "mdl-checkbox__label", ['for'] = id },
+ content = label
+ }
+ end
+ }
+ end }
+end
+
local id = param.get_id()
local member = Member:by_id(id)
@@ -22,7 +61,11 @@
ui.cell_main{ content = function()
ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
- ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"Member" }
+ local text = _"Member"
+ if member then
+ text = text .. " ID " .. member.id
+ end
+ ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = text }
end }
ui.container{ attr = { class = "mdl-card__content" }, content = function()
ui.form{
@@ -41,26 +84,30 @@
},
content = function()
- ui.field.text{ label = _"Identification", name = "identification" }
- ui.field.text{ label = _"Notification email (confirmed)", name = "notify_email" }
- ui.field.text{ label = _"Notification email (unconfirmed)", name = "notify_email_unconfirmed" }
+ ui.container{ content = function()
+ field("identification", _"Identification")
+ if member and member.activated then
+ slot.put(" ")
+ field("name", "Screen name")
+ end
+ end }
+ ui.container{ content = function()
+ field("notify_email", _"Notification email (confirmed)")
+ slot.put(" ")
+ field("notify_email_unconfirmed", _"Notification email (unconfirmed)")
+ end }
+-- field("", "")
- if member and member.activated then
- ui.field.text{ label = _"Screen name", name = "name" }
- end
if member and member.activated and not deactivated then
- ui.field.text{ label = _"Login name", name = "login" }
+ field("login", "Login name")
end
for i, unit in ipairs(units) do
- ui.field.boolean{
- name = "unit_" .. unit.id,
- label = unit.name,
- value = unit.voting_right
- }
+ field_boolean("checkbox_unit_" .. unit.id, "unit_" .. unit.id, unit.voting_right, unit.name)
+
end
- slot.put("
")
+ slot.put("
")
if member then
ui.field.text{ label = _"Activated", name = "activated", readonly = true }
@@ -91,13 +138,13 @@
attr = { class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-js-ripple-effect" },
text = _"update member"
}
- slot.put(" ")
+ slot.put(" ")
if member then
ui.link {
- attr = { class = "mdl-button mdl-js-button mdl-button--raised" },
+ attr = { class = "mdl-button mdl-js-button" },
module = "admin", view = "member_deactivate", content = _"Deactivate member", id = member.id
}
- slot.put(" ")
+ slot.put(" ")
end
ui.link {
attr = { class = "mdl-button mdl-js-button" },
diff -r e7a0f1235ac0 -r a17ad625ffbc env/ui/titleAdmin.lua
--- a/env/ui/titleAdmin.lua Tue Feb 02 21:32:13 2021 +0100
+++ b/env/ui/titleAdmin.lua Sat Feb 06 22:44:34 2021 +0100
@@ -1,13 +1,13 @@
function ui.titleAdmin(title)
ui.title(function()
if title then
- ui.link { module = "admin", view = "index", content = _"System administration" }
+ ui.link { module = "admin", view = "index", content = _"System settings" }
else
- ui.tag{ content = _"System administration" }
+ ui.tag{ content = _"System settings" }
end
if title then
slot.put ( " ยป " )
ui.tag { tag = "span", content = title }
end
end)
-end
\ No newline at end of file
+end