liquid_feedback_frontend

view app/main/registration/_register_form.lua @ 1858:3d1f0464a3ea

Handle missing ldap.member.allowed function
author bsw
date Tue Sep 20 17:35:29 2022 +0200 (20 months ago)
parents e5756a575dde
children
line source
1 for i, field in ipairs(config.self_registration.fields) do
2 local class = ""
3 local field_error = slot.get_content("self_registration__invalid_" .. field.name)
4 if field_error == "" then
5 field_error = nil
6 end
7 if field_error then
8 class = " is-invalid"
9 end
10 if field.title then
11 ui.container{ attr = { style = "font-weight: bold;" }, content = field.title }
12 end
13 if field.text then
14 ui.container{ content = field.text }
15 end
16 if not field.internal then
17 if field.type == "comment" then
18 ui.tag { content = field.label }
19 elseif field.name == "date_of_birth" then
20 local label = field.label
21 if field.optional then
22 label = label .. config.self_registration.optional_field_indicator
23 end
24 ui.tag{ tag = "label", attr = { style = "vertical-align: bottom; border-bottom: 1px solid rgba(0,0,0, 0.12); color: #777; font-size: 16px;" }, content = field.label .. ":" }
25 slot.put("   ")
26 local days = { { id = 0, name = _"day" } }
27 for i = 1, 31 do
28 table.insert(days, { id = i, name = i })
29 end
30 local months = {
31 { id = 0, name = _"month" },
32 { id = 1, name = "gennaio" },
33 { id = 2, name = "febbraio" },
34 { id = 3, name = "marzo" },
35 { id = 4, name = "aprile" },
36 { id = 5, name = "maggio" },
37 { id = 6, name = "giugno" },
38 { id = 7, name = "luglio" },
39 { id = 8, name = "agosto" },
40 { id = 9, name = "settembre" },
41 { id = 10, name = "ottobre" },
42 { id = 11, name = "novembre" },
43 { id = 12, name = "dicembre" },
44 }
45 if config.self_registration.lang == "en" then
46 months = {
47 { id = 0, name = _"month" },
48 { id = 1, name = "January" },
49 { id = 2, name = "February" },
50 { id = 3, name = "March" },
51 { id = 4, name = "April" },
52 { id = 5, name = "May" },
53 { id = 6, name = "June" },
54 { id = 7, name = "July" },
55 { id = 8, name = "August" },
56 { id = 9, name = "September" },
57 { id = 10, name = "October" },
58 { id = 11, name = "November" },
59 { id = 12, name = "December" },
60 }
61 end
62 if config.self_registration.lang == "de" then
63 months = {
64 { id = 0, name = _"month" },
65 { id = 1, name = "Januar" },
66 { id = 2, name = "Februar" },
67 { id = 3, name = "März" },
68 { id = 4, name = "April" },
69 { id = 5, name = "Mai" },
70 { id = 6, name = "Juni" },
71 { id = 7, name = "Juli" },
72 { id = 8, name = "August" },
73 { id = 9, name = "September" },
74 { id = 10, name = "Oktober" },
75 { id = 11, name = "November" },
76 { id = 12, name = "Dezember" },
77 }
78 end
79 local years = { { id = 0, name = _"year" } }
80 local min_age = config.self_registration.min_age or 16
81 for i = (atom.date:get_current()).year - min_age, 1900, -1 do
82 table.insert(years, { id = i, name = i })
83 end
84 ui.field.select{
85 container_attr = { style = "display: inline-block; " },
86 attr = { class = class },
87 foreign_records = days,
88 foreign_id = "id",
89 foreign_name = "name",
90 name = "verification_data_" .. field.name .. "_day",
91 value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_day" })
92 }
93 slot.put("   ")
94 ui.field.select{
95 container_attr = { style = "display: inline-block; " },
96 attr = { class = class },
97 foreign_records = months,
98 foreign_id = "id",
99 foreign_name = "name",
100 name = "verification_data_" .. field.name .. "_month",
101 value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_month" })
102 }
103 slot.put("   ")
104 ui.field.select{
105 container_attr = { style = "display: inline-block; " },
106 attr = { class = class },
107 foreign_records = years,
108 foreign_id = "id",
109 foreign_name = "name",
110 name = "verification_data_" .. field.name .. "_year",
111 value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_year" })
112 }
113 slot.put("<br />")
115 elseif field.type == "dropdown" then
116 local options = { { id = "", name = "" } }
117 local other_option_id
118 for i_options, option in ipairs(field.options) do
119 if not option.id then
120 option.id = option.name
121 end
122 if option.other then
123 other_option_id = option.id
124 end
125 table.insert(options, option)
126 end
127 if field.label then
128 ui.tag{ tag = "label", attr = { style = "vertical-align: bottom; border-bottom: 1px solid rgba(0,0,0, 0.12); color: #777; font-size: 16px;" }, content = field.label .. ":" }
129 slot.put(" &nbsp; ")
130 end
131 local onchange_script
132 if other_option_id then
133 onchange_script = "var el = document.getElementById('lf-register__data_other_container_" .. field.name .. "'); if (this.value == '" .. other_option_id .. "') { console.log(el); el.classList.remove('hidden'); } else { el.classList.add('hidden'); };"
134 end
135 ui.field.select{
136 container_attr = { style = "display: inline-block; " },
137 attr = { class = class, onchange = onchange_script },
138 foreign_records = options,
139 foreign_id = "id",
140 foreign_name = "name",
141 name = "verification_data_" .. field.name,
142 value = request.get_param{ name = "verification_data_" .. field.name }
143 }
144 if other_option_id then
145 slot.put(" ")
146 ui.field.text{
147 container_attr = { id = "lf-register__data_other_container_" .. field.name, class = "hidden mdl-textfield mdl-js-textfield mdl-textfield--floating-label" .. class },
148 attr = { id = "lf-register__data_other_" .. field.name, class = "mdl-textfield__input" },
149 name = "verification_data_" .. field.name .. "_other",
150 label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__data" .. field.name },
151 label = field.name,
152 value = request.get_param{ name = "verification_data_" .. field.name .. "_other" }
153 }
154 end
155 slot.put("<br />")
157 elseif field.type == "multiselect" then
158 local options = { { id = "", name = "" } }
159 local other_option_id
160 for i_options, option in ipairs(field.options) do
161 if not option.id then
162 option.id = option.name
163 end
164 local onchange_script
165 if option.other then
166 onchange_script = "var el = document.getElementById('lf-register__data_other_container_" .. field.name .. "'); if (this.checked) { console.log(el); el.classList.remove('hidden'); } else { el.classList.add('hidden'); };"
167 end
168 ui.container{ content = function()
169 ui.tag{ tag = "label", attr = {
170 class = "mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect",
171 style = "display: inline;",
172 ["for"] = "verification_data_" .. field.name .. "__" .. option.id,
173 },
174 content = function()
175 ui.tag{
176 tag = "input",
177 attr = {
178 type = "checkbox",
179 class = "mdl-checkbox__input",
180 onchange = onchange_script,
181 id = "verification_data_" .. field.name .. "__" .. option.id,
182 name = "verification_data_" .. field.name .. "__" .. option.id,
183 value = "1",
184 style = "float: left;",
185 checked = request.get_param{ name = "verification_data_" .. field.name .. "__" .. option.id } and "checked" or nil,
186 }
187 }
188 ui.tag{
189 attr = { class = "mdl-checkbox__label" },
190 content = option.name
191 }
192 end
193 }
194 end }
195 if option.other then
196 slot.put(" ")
197 ui.field.text{
198 container_attr = { id = "lf-register__data_other_container_" .. field.name, class = "hidden mdl-textfield mdl-js-textfield mdl-textfield--floating-label" .. class },
199 attr = { id = "lf-register__data_other_" .. field.name, class = "mdl-textfield__input" },
200 name = "verification_data_" .. field.name .. "_other",
201 label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__data" .. field.name },
202 label = field.name,
203 value = request.get_param{ name = "verification_data_" .. field.name .. "_other" }
204 }
205 end
206 end
207 slot.put("<br />")
209 elseif field.type == "image" then
210 slot.put("<br />")
211 ui.tag{ tag = "label", attr = { style = "vertical-align: bottom; border-bottom: 1px solid rgba(0,0,0, 0.12); color: #777; font-size: 16px;" }, content = field.label .. ":" }
212 slot.put("<br />")
213 ui.script{ script = [[
214 function getFile(){
215 document.getElementById("fileInput").click();
216 }
217 function fileChoosen(obj){
218 var file = obj.value;
219 var fileName = file.split("\\");
220 var checked = false;
221 var label = "]] .. field.upload_label .. [[";
222 if (fileName[fileName.length-1].length > 0) {
223 label = fileName[fileName.length-1];
224 }
225 document.getElementById("fileBtn").innerHTML = label;
226 event.preventDefault();
227 }
228 ]] }
229 ui.tag{ tag = "input", attr = { id = "fileInput", style = "display: none;", type = "file", name = "verification_data_" .. field.name, onchange = "fileChoosen(this);" } }
230 ui.tag{
231 attr = { id = "fileBtn", class = "mdl-button mdl-js-button mdl-button--underlined", onclick = "getFile();" },
232 content = field.upload_label
233 }
234 if field.optional_checkbox then
235 slot.put(" &nbsp; ")
236 ui.tag{ tag = "label", attr = {
237 class = "mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect",
238 style = "display: inline;",
239 ["for"] = "verification_data_" .. field.name .. "_optout"
240 },
241 content = function()
242 ui.tag{
243 tag = "input",
244 attr = {
245 type = "checkbox",
246 class = "mdl-checkbox__input",
247 id = "verification_data_" .. field.name .. "_optout",
248 name = "verification_data_" .. field.name .. "_optout",
249 value = "1",
250 style = "float: left;",
251 checked = request.get_param{ name = "verification_data_" .. field.name .. "_optout" } and "checked" or nil,
252 }
253 }
254 ui.tag{
255 attr = { class = "mdl-checkbox__label" },
256 content = field.optional_checkbox
257 }
258 end
259 }
260 end
262 elseif field.name == "unit" then
263 local units_selector = Unit:new_selector()
264 :add_where{ "active" }
265 :add_order_by("name")
266 if field.where then
267 units_selector:add_where(field.where)
268 end
269 local units = { { id = "", name = "" } }
270 if field.optional then
271 table.insert(units, {
272 id = "",
273 name = _"none"
274 })
275 end
276 for i_unit, unit in ipairs(units_selector:exec()) do
277 table.insert(units, unit)
278 end
279 ui.tag{ tag = "label", attr = { style = "vertical-align: bottom; border-bottom: 1px solid rgba(0,0,0, 0.12); color: #777; font-size: 16px;" }, content = field.label .. ":" }
280 slot.put(" &nbsp; ")
281 ui.field.select{
282 container_attr = { style = "display: inline-block; " },
283 foreign_records = units,
284 foreign_id = "id",
285 foreign_name = "name",
286 name = "verification_data_" .. field.name,
287 value = tonumber(request.get_param{ name = "verification_data_" .. field.name })
288 }
289 slot.put("<br />")
290 else
291 if field.name == "mobile_phone" then
292 if config.self_registration.lang ~= "en" then
293 ui.tag{ content = "+39" }
294 slot.put(" ")
295 end
296 end
297 local label = field.label
298 if field.optional then
299 label = label .. config.self_registration.optional_field_indicator
300 end
301 ui.field.text{
302 container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" .. class },
303 attr = { id = "lf-register__data_" .. field.name, class = "mdl-textfield__input" },
304 label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__data" .. field.name },
305 label = label,
306 name = "verification_data_" .. field.name,
307 value = request.get_param{ name = "verification_data_" .. field.name }
308 }
309 end
310 slot.put("<br />")
311 end
312 end

Impressum / About Us