liquid_feedback_frontend
view app/main/admin/member_edit.lua @ 1455:24dc7bd75d0a
New layout for admin member edit view
author | bsw |
---|---|
date | Thu Oct 18 17:23:45 2018 +0200 (2018-10-18) |
parents | d55f506f032b |
children | 9e5cfd6411aa |
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.sectionHead( function()
45 ui.heading { level = 1, content = member and (member.name or member.id) or _"New member" }
46 if member and member.identification then
47 ui.heading { level = 3, content = member.identification }
48 end
49 end )
51 ui.sectionRow( function()
52 ui.field.text{ label = _"Identification", name = "identification" }
53 ui.field.text{ label = _"Notification email (confirmed)", name = "notify_email" }
54 ui.field.text{ label = _"Notification email (unconfirmed)", name = "notify_email_unconfirmed" }
55 if member and member.activated then
56 ui.field.text{ label = _"Screen name", name = "name" }
57 end
59 if member and member.activated and not deactivated then
60 ui.field.text{ label = _"Login name", name = "login" }
61 end
63 for i, unit in ipairs(units) do
64 ui.field.boolean{
65 name = "unit_" .. unit.id,
66 label = unit.name,
67 value = unit.voting_right
68 }
69 end
70 slot.put("<br /><br />")
72 if member then
73 ui.field.text{ label = _"Activated", name = "activated", readonly = true }
74 end
76 if not member or not member.activated then
77 ui.field.boolean{ label = _"Send invite?", name = "invite_member" }
78 end
80 if member then
81 ui.field.boolean{
82 label = _"Member inactive?", name = "deactivate",
83 readonly = true,
84 value = member and member.active == false
85 }
86 end
88 if member then
89 ui.field.boolean{
90 label = _"Lock member?", name = "locked",
91 }
92 end
94 slot.put("<br />")
95 ui.field.boolean{ label = _"Admin?", name = "admin" }
96 slot.put("<br />")
97 ui.submit{ text = _"update member" }
98 slot.put(" ")
99 if member then
100 ui.link { module = "admin", view = "member_deactivate", content = _"Deactivate member", id = member.id }
101 slot.put(" ")
102 end
103 ui.link { module = "admin", view = "index", content = _"cancel" }
104 end )
105 end
106 }
107 end }
108 end }
109 end }