liquid_feedback_frontend

annotate app/main/registration/_register_form.lua @ 1399:20c293c7b78e

Changed style of register image upload 9
author bsw
date Mon Aug 13 19:36:00 2018 +0200 (2018-08-13)
parents 94941b0297d8
children e8e4396fd73c
rev   line source
bsw/jbe@1309 1 for i, field in ipairs(config.self_registration.fields) do
bsw/jbe@1309 2 local class = ""
bsw/jbe@1309 3 local field_error = slot.get_content("self_registration__invalid_" .. field.name)
bsw/jbe@1309 4 if field_error == "" then
bsw/jbe@1309 5 field_error = nil
bsw/jbe@1309 6 end
bsw/jbe@1309 7 if field_error then
bsw/jbe@1309 8 class = " is-invalid"
bsw/jbe@1309 9 end
bsw@1359 10 if not field.internal then
bsw@1359 11 if field.name == "date_of_birth" then
bsw@1359 12 local label = field.label
bsw@1359 13 if field.optional then
bsw@1359 14 label = label .. config.self_registration.optional_field_indicator
bsw@1359 15 end
bsw@1359 16 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 .. ":" }
bsw@1359 17 slot.put("   ")
bsw@1359 18 local days = { { id = 0, name = _"day" } }
bsw@1359 19 for i = 1, 31 do
bsw@1359 20 table.insert(days, { id = i, name = i })
bsw@1359 21 end
bsw@1359 22 local months = {
bsw/jbe@1309 23 { id = 0, name = _"month" },
bsw@1359 24 { id = 1, name = "gennaio" },
bsw@1359 25 { id = 2, name = "febbraio" },
bsw@1359 26 { id = 3, name = "marzo" },
bsw@1359 27 { id = 4, name = "aprile" },
bsw@1359 28 { id = 5, name = "maggio" },
bsw@1359 29 { id = 6, name = "giugno" },
bsw@1359 30 { id = 7, name = "luglio" },
bsw@1359 31 { id = 8, name = "agosto" },
bsw@1359 32 { id = 9, name = "settembre" },
bsw@1359 33 { id = 10, name = "ottobre" },
bsw@1359 34 { id = 11, name = "novembre" },
bsw@1359 35 { id = 12, name = "dicembre" },
bsw@1359 36 }
bsw@1359 37 if config.self_registration.lang == "en" then
bsw@1359 38 months = {
bsw@1359 39 { id = 0, name = _"month" },
bsw@1359 40 { id = 1, name = "January" },
bsw@1359 41 { id = 2, name = "February" },
bsw@1359 42 { id = 3, name = "March" },
bsw@1359 43 { id = 4, name = "April" },
bsw@1359 44 { id = 5, name = "May" },
bsw@1359 45 { id = 6, name = "June" },
bsw@1359 46 { id = 7, name = "July" },
bsw@1359 47 { id = 8, name = "August" },
bsw@1359 48 { id = 9, name = "September" },
bsw@1359 49 { id = 10, name = "October" },
bsw@1359 50 { id = 11, name = "November" },
bsw@1359 51 { id = 12, name = "December" },
bsw@1359 52 }
bsw@1359 53 end
bsw@1359 54 local years = { { id = 0, name = _"year" } }
bsw@1359 55 for i = 2002, 1900, -1 do
bsw@1359 56 table.insert(years, { id = i, name = i })
bsw@1359 57 end
bsw@1359 58 ui.field.select{
bsw@1359 59 container_attr = { style = "display: inline-block; " },
bsw@1359 60 attr = { class = class },
bsw@1359 61 foreign_records = days,
bsw@1359 62 foreign_id = "id",
bsw@1359 63 foreign_name = "name",
bsw@1359 64 name = "verification_data_" .. field.name .. "_day",
bsw@1359 65 value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_day" })
bsw@1359 66 }
bsw@1359 67 slot.put("   ")
bsw@1359 68 ui.field.select{
bsw@1359 69 container_attr = { style = "display: inline-block; " },
bsw@1359 70 attr = { class = class },
bsw@1359 71 foreign_records = months,
bsw@1359 72 foreign_id = "id",
bsw@1359 73 foreign_name = "name",
bsw@1359 74 name = "verification_data_" .. field.name .. "_month",
bsw@1359 75 value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_month" })
bsw@1359 76 }
bsw@1359 77 slot.put("   ")
bsw@1359 78 ui.field.select{
bsw@1359 79 container_attr = { style = "display: inline-block; " },
bsw@1359 80 attr = { class = class },
bsw@1359 81 foreign_records = years,
bsw@1359 82 foreign_id = "id",
bsw@1359 83 foreign_name = "name",
bsw@1359 84 name = "verification_data_" .. field.name .. "_year",
bsw@1359 85 value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_year" })
bsw@1359 86 }
bsw@1359 87 slot.put("<br />")
bsw@1377 88
bsw@1377 89 elseif field.type == "dropdown" then
bsw@1380 90 local options = { { id = "", name = "" } }
bsw@1377 91 for i_options, option in ipairs(field.options) do
bsw@1377 92 table.insert(options, option)
bsw@1377 93 end
bsw@1380 94 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 .. ":" }
bsw@1380 95 slot.put(" &nbsp; ")
bsw@1377 96 ui.field.select{
bsw@1377 97 container_attr = { style = "display: inline-block; " },
bsw@1377 98 attr = { class = class },
bsw@1377 99 foreign_records = options,
bsw@1377 100 foreign_id = "id",
bsw@1377 101 foreign_name = "name",
bsw@1377 102 name = "verification_data_" .. field.name,
bsw@1377 103 value = tonumber(request.get_param{ name = "verification_data_" .. field.name })
bsw@1377 104 }
bsw@1381 105 slot.put("<br />")
bsw@1377 106
bsw@1359 107 elseif field.type == "image" then
bsw@1386 108 slot.put("<br />")
bsw@1392 109 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 .. ":" }
bsw@1392 110 slot.put("<br />")
bsw@1391 111 ui.script{ script = [[
bsw@1391 112 function getFile(){
bsw@1392 113 document.getElementById("fileInput").click();
bsw@1391 114 }
bsw@1391 115 function fileChoosen(obj){
bsw@1391 116 var file = obj.value;
bsw@1391 117 var fileName = file.split("\\");
bsw@1399 118 var checked = false;
bsw@1399 119 var label = "]] .. field.upload_label .. [[";
bsw@1398 120 if (fileName.length > 0) {
bsw@1398 121 checked = true;
bsw@1398 122 label = fileName[fileName.length-1];
bsw@1398 123 }
bsw@1399 124 document.getElementById("fileCheckbox").checked = checked;
bsw@1399 125 document.getElementById("fileBtn").innerHTML = label;
bsw@1391 126 event.preventDefault();
bsw@1391 127 }
bsw@1391 128 ]] }
bsw@1393 129 ui.tag{ tag = "input", attr = { id = "fileInput", style = "display: none;", type = "file", name = "verification_data_" .. field.name, onchange = "fileChoosen(this);" } }
bsw@1396 130 ui.tag{ tag = "label", attr = {
bsw@1396 131 class = "mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect",
bsw@1396 132 style = "display: inline;",
bsw@1396 133 },
bsw@1396 134 content = function()
bsw@1396 135 ui.tag{
bsw@1396 136 tag = "input",
bsw@1396 137 attr = {
bsw@1396 138 type = "checkbox",
bsw@1396 139 class = "mdl-checkbox__input",
bsw@1396 140 id = "fileCheckbox",
bsw@1396 141 style = "float: left;",
bsw@1396 142 onclick = "getFile();"
bsw@1396 143 }
bsw@1396 144 }
bsw@1396 145 ui.tag{
bsw@1396 146 attr = { id = "fileBtn", class = "mdl-checkbox__label", onclick = "getFile();" },
bsw@1396 147 content = field.upload_label
bsw@1396 148 }
bsw@1397 149 end
bsw@1395 150 }
bsw@1367 151 if field.optional_checkbox then
bsw@1391 152 slot.put(" &nbsp; ")
bsw@1375 153 ui.tag{ tag = "label", attr = {
bsw@1375 154 class = "mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect",
bsw@1394 155 style = "display: inline;",
bsw@1375 156 ["for"] = "verification_data_" .. field.name .. "_optout"
bsw@1375 157 },
bsw@1375 158 content = function()
bsw@1375 159 ui.tag{
bsw@1375 160 tag = "input",
bsw@1375 161 attr = {
bsw@1375 162 type = "checkbox",
bsw@1375 163 class = "mdl-checkbox__input",
bsw@1375 164 id = "verification_data_" .. field.name .. "_optout",
bsw@1375 165 name = "verification_data_" .. field.name .. "_optout",
bsw@1375 166 value = "1",
bsw@1375 167 style = "float: left;",
bsw@1375 168 checked = request.get_param{ name = "verification_data_" .. field.name .. "_optout" } and "checked" or nil,
bsw@1375 169 }
bsw@1375 170 }
bsw@1375 171 ui.tag{
bsw@1375 172 attr = { class = "mdl-checkbox__label" },
bsw@1375 173 content = field.optional_checkbox
bsw@1375 174 }
bsw@1375 175 end
bsw@1375 176 }
bsw@1367 177 end
bsw@1359 178
bsw@1359 179 elseif field.name == "unit" then
bsw@1359 180 local units_selector = Unit:new_selector()
bsw@1359 181 :add_where{ "active" }
bsw@1359 182 if field.where then
bsw@1359 183 units_selector:add_where(field.where)
bsw@1359 184 end
bsw@1359 185 local units = {}
bsw@1359 186 if field.optional then
bsw@1359 187 table.insert(units, {
bsw@1359 188 id = "",
bsw@1359 189 name = _"None"
bsw@1359 190 })
bsw@1359 191 end
bsw@1359 192 for i_unit, unit in ipairs(units_selector:exec()) do
bsw@1359 193 table.insert(units, unit)
bsw@1359 194 end
bsw@1382 195 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 .. ":" }
bsw@1382 196 slot.put(" &nbsp; ")
bsw@1359 197 ui.field.select{
bsw@1383 198 container_attr = { style = "display: inline-block; " },
bsw@1359 199 foreign_records = units,
bsw@1359 200 foreign_id = "id",
bsw@1359 201 foreign_name = "name",
bsw@1359 202 name = "verification_data_" .. field.name,
bsw@1359 203 value = tonumber(request.get_param{ name = "verification_data_" .. field.name })
bsw@1359 204 }
bsw@1386 205 slot.put("<br />")
bsw@1359 206 else
bsw@1359 207 if field.name == "mobile_phone" then
bsw@1359 208 if config.self_registration.lang ~= "en" then
bsw@1359 209 ui.tag{ content = "+39" }
bsw@1359 210 slot.put(" ")
bsw@1359 211 end
bsw@1359 212 end
bsw@1359 213 ui.field.text{
bsw@1359 214 container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" .. class },
bsw@1359 215 attr = { id = "lf-register__data_" .. field.name, class = "mdl-textfield__input" },
bsw@1359 216 label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__data" .. field.name },
bsw@1359 217 label = field.label,
bsw@1359 218 name = "verification_data_" .. field.name,
bsw@1359 219 value = request.get_param{ name = "verification_data_" .. field.name }
bsw/jbe@1309 220 }
bsw/jbe@1309 221 end
bsw@1327 222 slot.put("<br />")
bsw/jbe@1309 223 end
bsw/jbe@1309 224 end

Impressum / About Us