liquid_feedback_frontend

view app/main/admin/member_edit.lua @ 1781:c28ff4a85ded

Removed unused views
author bsw
date Tue Oct 19 14:45:36 2021 +0200 (2021-10-19)
parents 40a388c07af9
children caa6c71dd22a
line source
1 local function field(name, label, value, tooltip)
2 ui.field.text{
3 container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" },
4 attr = { id = "field_" .. name, class = "mdl-textfield__input" },
5 label_attr = { class = "mdl-textfield__label", ["for"] = "field_" .. name },
6 label = label,
7 name = name,
8 value = value or nil
9 }
10 if tooltip then
11 ui.container{ attr = { class = "mdl-tooltip", ["for"] = "field_" .. name }, content = tooltip }
12 end
13 end
15 local function field_boolean(id, name, checked, label)
16 ui.container{ content = function()
17 ui.tag{ tag = "label", attr = {
18 class = "mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect",
19 ["for"] = id
20 },
21 content = function()
22 ui.tag{
23 tag = "input",
24 attr = {
25 id = id,
26 class = "mdl-checkbox__input",
27 type = "checkbox", name = name, value = "true",
28 checked = checked and "checked" or nil,
29 }
30 }
31 ui.tag{
32 attr = { class = "mdl-checkbox__label", ['for'] = id },
33 content = label
34 }
35 end
36 }
37 end }
38 end
40 local id = param.get_id()
42 local member = Member:by_id(id)
44 local deactivated = member and member.locked and member.login == nil and member.authority_login == nil
46 ui.titleAdmin(_"Member")
48 local units_selector = Unit:new_selector()
49 :add_where("active")
52 if member then
53 units_selector
54 :left_join("privilege", nil, { "privilege.member_id = ? AND privilege.unit_id = unit.id", member.id })
55 :add_field("privilege.voting_right", "voting_right")
56 :add_order_by("unit.name")
57 end
59 local units = units_selector:exec()
61 ui.grid{ content = function()
63 ui.cell_main{ content = function()
64 ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
65 ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
66 local text = _"Member"
67 if member then
68 text = text .. " ID " .. member.id
69 end
70 ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = text }
71 end }
72 ui.container{ attr = { class = "mdl-card__content" }, content = function()
73 ui.form{
74 attr = { class = "vertical section" },
75 module = "admin",
76 action = "member_update",
77 id = member and member.id,
78 record = member,
79 readonly = not app.session.member.admin,
80 routing = {
81 default = {
82 mode = "redirect",
83 modules = "admin",
84 view = "index"
85 }
86 },
87 content = function()
89 ui.container{ content = function()
90 field("identification", _"Identification")
91 if member and member.activated then
92 slot.put("   ")
93 field("name", "Screen name")
94 end
95 end }
96 ui.container{ content = function()
97 field("notify_email", _"Notification email (confirmed)")
98 slot.put("   ")
99 field("notify_email_unconfirmed", _"Notification email (unconfirmed)")
100 end }
101 -- field("", "")
104 if member and member.activated and not deactivated then
105 field("login", "Login name")
106 end
108 for i, unit in ipairs(units) do
109 field_boolean("checkbox_unit_" .. unit.id, "unit_" .. unit.id, unit.voting_right, unit.name)
111 end
112 slot.put("<br />")
114 if member then
115 ui.field.text{ label = _"Activated", name = "activated", readonly = true }
116 end
118 if not member or not member.activated then
119 ui.field.boolean{ label = _"Send invite?", name = "invite_member" }
120 end
122 if member then
123 ui.field.boolean{
124 label = _"Member inactive?", name = "deactivate",
125 readonly = true,
126 value = member and member.active == false
127 }
128 end
130 if member then
131 ui.field.boolean{
132 label = _"Lock member?", name = "locked",
133 }
134 end
136 slot.put("<br />")
137 ui.field.boolean{ label = _"Admin?", name = "admin" }
138 slot.put("<br />")
139 ui.submit{
140 attr = { class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-js-ripple-effect" },
141 text = _"update member"
142 }
143 slot.put(" &nbsp; ")
144 if member then
145 ui.link {
146 attr = { class = "mdl-button mdl-js-button" },
147 module = "admin", view = "member_deactivate", content = _"Deactivate member", id = member.id
148 }
149 slot.put(" &nbsp; ")
150 end
151 ui.link {
152 attr = { class = "mdl-button mdl-js-button" },
153 module = "admin", view = "index", content = _"cancel"
154 }
156 end
157 }
158 end }
159 end }
160 end }
161 end }

Impressum / About Us