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