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@1828
|
15 local function field_boolean(id, name, checked, label, depth)
|
bsw@1830
|
16 ui.container{ attr = { style = "margin-left: " .. (depth -1) * 24 .. "px;" }, 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@1829
|
48 local units = Unit:get_flattened_tree{ include_inactive = inactive, include_hidden = true, member_id = member and member.id }
|
bsw@512
|
49
|
bsw@1455
|
50 ui.grid{ content = function()
|
bsw@310
|
51
|
bsw@1455
|
52 ui.cell_main{ content = function()
|
bsw@1455
|
53 ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
|
bsw@1455
|
54 ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
|
bsw@1621
|
55 local text = _"Member"
|
bsw@1621
|
56 if member then
|
bsw@1621
|
57 text = text .. " ID " .. member.id
|
bsw@1621
|
58 end
|
bsw@1621
|
59 ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = text }
|
bsw@1455
|
60 end }
|
bsw@1455
|
61 ui.container{ attr = { class = "mdl-card__content" }, content = function()
|
bsw@1455
|
62 ui.form{
|
bsw@1455
|
63 attr = { class = "vertical section" },
|
bsw@1455
|
64 module = "admin",
|
bsw@1455
|
65 action = "member_update",
|
bsw@1455
|
66 id = member and member.id,
|
bsw@1455
|
67 record = member,
|
bsw@1455
|
68 readonly = not app.session.member.admin,
|
bsw@1455
|
69 routing = {
|
bsw@1455
|
70 default = {
|
bsw@1455
|
71 mode = "redirect",
|
bsw@1455
|
72 modules = "admin",
|
bsw@1455
|
73 view = "index"
|
bsw@1455
|
74 }
|
bsw@1455
|
75 },
|
bsw@1455
|
76 content = function()
|
bsw@1455
|
77
|
bsw@1621
|
78 ui.container{ content = function()
|
bsw@1621
|
79 field("identification", _"Identification")
|
bsw@1621
|
80 if member and member.activated then
|
bsw@1621
|
81 slot.put(" ")
|
bsw@1621
|
82 field("name", "Screen name")
|
bsw@1621
|
83 end
|
bsw@1621
|
84 end }
|
bsw@1621
|
85 ui.container{ content = function()
|
bsw@1621
|
86 field("notify_email", _"Notification email (confirmed)")
|
bsw@1621
|
87 slot.put(" ")
|
bsw@1621
|
88 field("notify_email_unconfirmed", _"Notification email (unconfirmed)")
|
bsw@1621
|
89 end }
|
bsw@1621
|
90 -- field("", "")
|
bsw@1458
|
91
|
bsw@1456
|
92
|
bsw@1456
|
93 if member and member.activated and not deactivated then
|
bsw@1621
|
94 field("login", "Login name")
|
bsw@1456
|
95 end
|
bsw@1088
|
96
|
bsw@1456
|
97 for i, unit in ipairs(units) do
|
bsw@1828
|
98 field_boolean("checkbox_unit_" .. unit.id, "unit_" .. unit.id, unit.voting_right, unit.name, unit.depth)
|
bsw@1621
|
99
|
bsw@1458
|
100 end
|
bsw@1621
|
101 slot.put("<br />")
|
bsw@1045
|
102
|
bsw@1455
|
103 if member then
|
bsw@1455
|
104 ui.field.text{ label = _"Activated", name = "activated", readonly = true }
|
bsw@1455
|
105 end
|
bsw@1455
|
106
|
bsw@1455
|
107 if not member or not member.activated then
|
bsw@1455
|
108 ui.field.boolean{ label = _"Send invite?", name = "invite_member" }
|
bsw@1455
|
109 end
|
bsw@1455
|
110
|
bsw@1455
|
111 if member then
|
bsw@1455
|
112 ui.field.boolean{
|
bsw@1455
|
113 label = _"Member inactive?", name = "deactivate",
|
bsw@1455
|
114 readonly = true,
|
bsw@1455
|
115 value = member and member.active == false
|
bsw@1455
|
116 }
|
bsw@1455
|
117 end
|
bsw@1455
|
118
|
bsw@1455
|
119 if member then
|
bsw@1455
|
120 ui.field.boolean{
|
bsw@1455
|
121 label = _"Lock member?", name = "locked",
|
bsw@1455
|
122 }
|
bsw@1455
|
123 end
|
bsw@1455
|
124
|
bsw@1455
|
125 slot.put("<br />")
|
bsw@1455
|
126 ui.field.boolean{ label = _"Admin?", name = "admin" }
|
bsw@1455
|
127 slot.put("<br />")
|
bsw@1461
|
128 ui.submit{
|
bsw@1461
|
129 attr = { class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-js-ripple-effect" },
|
bsw@1461
|
130 text = _"update member"
|
bsw@1461
|
131 }
|
bsw@1621
|
132 slot.put(" ")
|
bsw@1455
|
133 if member then
|
bsw@1461
|
134 ui.link {
|
bsw@1621
|
135 attr = { class = "mdl-button mdl-js-button" },
|
bsw@1461
|
136 module = "admin", view = "member_deactivate", content = _"Deactivate member", id = member.id
|
bsw@1461
|
137 }
|
bsw@1621
|
138 slot.put(" ")
|
bsw@1455
|
139 end
|
bsw@1461
|
140 ui.link {
|
bsw@1461
|
141 attr = { class = "mdl-button mdl-js-button" },
|
bsw@1461
|
142 module = "admin", view = "index", content = _"cancel"
|
bsw@1461
|
143 }
|
bsw@1456
|
144
|
bsw@1457
|
145 end
|
bsw@1457
|
146 }
|
bsw@1457
|
147 end }
|
bsw@1455
|
148 end }
|
bsw@1455
|
149 end }
|
bsw@1455
|
150 end }
|