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