liquid_feedback_frontend
view app/main/admin/member_edit.lua @ 1458:3494edd607e7
Fixed nesting again part 2
author | bsw |
---|---|
date | Thu Oct 18 17:27:02 2018 +0200 (2018-10-18) |
parents | 77fb282db8a1 |
children | ad2297c57457 |
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" }
46 if member and member.identification then
47 ui.heading { level = 3, content = member.identification }
48 end
50 ui.field.text{ label = _"Identification", name = "identification" }
51 ui.field.text{ label = _"Notification email (confirmed)", name = "notify_email" }
52 ui.field.text{ label = _"Notification email (unconfirmed)", name = "notify_email_unconfirmed" }
54 if member and member.activated then
55 ui.field.text{ label = _"Screen name", name = "name" }
56 end
58 if member and member.activated and not deactivated then
59 ui.field.text{ label = _"Login name", name = "login" }
60 end
62 for i, unit in ipairs(units) do
63 ui.field.boolean{
64 name = "unit_" .. unit.id,
65 label = unit.name,
66 value = unit.voting_right
67 end
68 slot.put("<br /><br />")
70 if member then
71 ui.field.text{ label = _"Activated", name = "activated", readonly = true }
72 end
74 if not member or not member.activated then
75 ui.field.boolean{ label = _"Send invite?", name = "invite_member" }
76 end
78 if member then
79 ui.field.boolean{
80 label = _"Member inactive?", name = "deactivate",
81 readonly = true,
82 value = member and member.active == false
83 }
84 end
86 if member then
87 ui.field.boolean{
88 label = _"Lock member?", name = "locked",
89 }
90 end
92 slot.put("<br />")
93 ui.field.boolean{ label = _"Admin?", name = "admin" }
94 slot.put("<br />")
95 ui.submit{ text = _"update member" }
96 slot.put(" ")
97 if member then
98 ui.link { module = "admin", view = "member_deactivate", content = _"Deactivate member", id = member.id }
99 slot.put(" ")
100 end
101 ui.link { module = "admin", view = "index", content = _"cancel" }
103 end
104 }
105 end }
106 end }
107 end }
108 end }