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