liquid_feedback_frontend

annotate app/main/registration_admin/verification.lua @ 1455:24dc7bd75d0a

New layout for admin member edit view
author bsw
date Thu Oct 18 17:23:45 2018 +0200 (2018-10-18)
parents 627ab8104582
children 63ce1a5c05c1
rev   line source
bsw/jbe@1309 1 local verification = Verification:by_id(param.get_id())
bsw/jbe@1309 2 local data = verification.verification_data or verification.request_data
bsw/jbe@1309 3
bsw/jbe@1309 4 local identification = config.self_registration.identification_func(data)
bsw/jbe@1309 5 local member
bsw/jbe@1309 6 if verification.verified_member_id then
bsw/jbe@1309 7 member = Member:by_id(verification.verified_member_id)
bsw/jbe@1309 8 identification = member.identification
bsw/jbe@1309 9 end
bsw/jbe@1309 10
bsw/jbe@1309 11 local group, title, view
bsw/jbe@1309 12 if verification.verified_member_id then
bsw/jbe@1309 13 if member.deleted then
bsw/jbe@1309 14 group = _"Cancelled accounts"
bsw/jbe@1309 15 title = _"Cancelled account"
bsw/jbe@1309 16 view = "verification_cancelled"
bsw/jbe@1309 17 else
bsw/jbe@1309 18 group = _"Accredited users"
bsw/jbe@1309 19 title = member.identification
bsw/jbe@1309 20 view = "verification_accredited"
bsw/jbe@1309 21 end
bsw/jbe@1309 22 elseif verification.denied then
bsw/jbe@1309 23 group = "Rejected requests"
bsw/jbe@1309 24 title = _"Rejected request"
bsw/jbe@1309 25 view = "verification_rejected"
bsw/jbe@1309 26 else
bsw/jbe@1309 27 group = "Open requests"
bsw/jbe@1309 28 title = _"Open request"
bsw/jbe@1309 29 view = "verification_requests"
bsw/jbe@1309 30 end
bsw/jbe@1309 31
bsw/jbe@1309 32
bsw/jbe@1309 33 ui.title(function()
bsw@1326 34 ui.link { module = "registration_admin", view = "index", content = _"User management" }
bsw/jbe@1309 35 slot.put ( " » " )
bsw/jbe@1309 36 ui.link { module = "registration_admin", view = view, content = group }
bsw/jbe@1309 37 slot.put ( " » " )
bsw/jbe@1309 38 ui.tag { tag = "span", content = title }
bsw/jbe@1309 39 end)
bsw@1326 40 app.html_title.title = _"User management"
bsw/jbe@1309 41
bsw/jbe@1309 42 ui.container{ attr = { class = "mdl-grid" }, content = function()
bsw/jbe@1309 43 ui.container{ attr = { class = "mdl-cell mdl-cell--12-col" }, content = function()
bsw/jbe@1309 44 ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
bsw/jbe@1309 45 ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
bsw/jbe@1309 46 ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = title }
bsw/jbe@1309 47 end }
bsw/jbe@1309 48
bsw/jbe@1309 49
bsw/jbe@1309 50 ui.form{
bsw/jbe@1309 51 module = "registration_admin", action = "update_verification", id = verification.id,
bsw@1445 52 routing = { ok = { mode = "redirect", module = "registration_admin", view = "index" } },
bsw/jbe@1309 53 record = data,
bsw/jbe@1309 54 content = function()
bsw/jbe@1309 55
bsw/jbe@1309 56 if not verification.verified_member_id then
bsw/jbe@1309 57 ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function()
bsw/jbe@1309 58 ui.container{ content = verification.comment and verification.comment:gsub("///", " / ") or ""}
bsw/jbe@1309 59 end }
bsw/jbe@1309 60 end
bsw/jbe@1309 61
bsw/jbe@1309 62 ui.container{ attr = { class = "mdl-card__content" }, content = function()
bsw/jbe@1309 63
bsw/jbe@1309 64 for i, field in ipairs(config.self_registration.fields) do
bsw/jbe@1309 65 ui.container{ content = function()
bsw@1335 66 if field.type == "image" then
bsw@1345 67 ui.link{ content = field.label, module = "registration_admin", view = "verification_image", id = verification.request_data[field.name], params = { field = i }, attr = { target = "_blank" } }
bsw@1347 68 elseif field.name == "unit" then
bsw@1347 69 local units_selector = Unit:new_selector()
bsw@1347 70 :add_where{ "active" }
bsw@1442 71 :add_order_by("name")
bsw@1347 72 if field.where then
bsw@1347 73 units_selector:add_where(field.where)
bsw@1347 74 end
bsw@1350 75 local units = {}
bsw@1347 76 if field.optional then
bsw@1347 77 table.insert(units, {
bsw@1347 78 id = "",
bsw@1347 79 name = _"None"
bsw@1347 80 })
bsw@1347 81 end
bsw@1351 82 for i_unit, unit in ipairs(units_selector:exec()) do
bsw@1350 83 table.insert(units, unit)
bsw@1350 84 end
bsw@1347 85 ui.field.select{
bsw@1442 86 container_attr = { style = "display: inline-block;" },
bsw@1347 87 label = field.label,
bsw@1347 88 foreign_records = units,
bsw@1347 89 foreign_id = "id",
bsw@1347 90 foreign_name = "name",
bsw@1350 91 name = field.name,
bsw@1350 92 value = tonumber(data[field.name])
bsw@1347 93 }
bsw@1439 94 local requested_unit = Unit:by_id(tonumber(verification.request_data.unit))
bsw@1441 95 ui.tag{ content = requested_unit and requested_unit.name or "-" }
bsw@1360 96 elseif field.name == "sequential_number" then
bsw@1361 97 ui.tag{ tag = "label", content = field.label }
bsw@1439 98 slot.put(" ")
bsw@1361 99 ui.tag{ tag = "span", content = data.sequential_number or _"None yet" }
bsw@1335 100 else
bsw@1335 101 ui.field.text{
bsw@1335 102 container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" },
bsw@1335 103 attr = { id = "lf-register__data_" .. field.name, class = "mdl-textfield__input" },
bsw@1335 104 label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__data" .. field.name },
bsw@1335 105 label = field.label,
bsw@1335 106 name = field.name
bsw@1335 107 }
bsw@1338 108 ui.tag{ content = verification.request_data[field.name] }
bsw@1335 109 end
bsw/jbe@1309 110 end }
bsw/jbe@1309 111 end
bsw/jbe@1309 112
bsw/jbe@1309 113 ui.field.text{
bsw/jbe@1309 114 container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label", style = "width: 30em;" },
bsw/jbe@1309 115 attr = { id = "lf-register__data_identification", class = "mdl-textfield__input" },
bsw/jbe@1309 116 label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__data_identification" },
bsw/jbe@1309 117 label = "Identification",
bsw/jbe@1309 118 name = "identification",
bsw/jbe@1309 119 value = identification
bsw/jbe@1309 120 }
bsw/jbe@1309 121
bsw/jbe@1309 122 end }
bsw/jbe@1309 123
bsw/jbe@1309 124 ui.container{ attr = { class = "mdl-card__actions mdl-card--border" }, content = function()
bsw/jbe@1309 125
bsw/jbe@1309 126 if verification.denied then
bsw/jbe@1309 127 ui.link{ attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, module = "registration_admin", view = view, content = "Back" }
bsw/jbe@1309 128 elseif verification.verified_member_id then
bsw/jbe@1309 129 ui.submit{ attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, value = "Save personal data" }
bsw/jbe@1309 130 slot.put("   ")
bsw/jbe@1309 131 if not member.activated then
bsw/jbe@1309 132 ui.submit{ name = "invite", attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, value = "Send email invitation again" }
bsw/jbe@1309 133 slot.put("   ")
bsw/jbe@1309 134 end
bsw@1444 135 ui.link{ attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, module = "registration_admin", view = view, content = "Back" }
bsw@1443 136 slot.put("   ")
bsw@1444 137 ui.link{ attr = { class = "mdl-button mdl-js-button" }, module = "admin", view = "member_edit", id = member.id, content = "User account" }
bsw/jbe@1309 138 slot.put("   ")
bsw/jbe@1309 139 ui.submit{ name = "cancel", attr = { class = "mdl-button mdl-js-button" }, value = _"Delete account" }
bsw/jbe@1309 140 else
bsw/jbe@1309 141 ui.submit{ name = "accredit", attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, value = "Accredit user" }
bsw/jbe@1309 142 slot.put("   ")
bsw/jbe@1309 143 ui.submit{ attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, value = "Save personal data" }
bsw/jbe@1309 144 slot.put("   ")
bsw/jbe@1309 145 ui.link{ attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, module = "registration_admin", view = view, content = "Back" }
bsw/jbe@1309 146 slot.put("   ")
bsw/jbe@1309 147 ui.submit{ name = "drop", attr = { class = "mdl-button mdl-js-button" }, value = "Reject request" }
bsw/jbe@1309 148 end
bsw/jbe@1309 149 end }
bsw/jbe@1309 150
bsw/jbe@1309 151 end
bsw/jbe@1309 152 }
bsw/jbe@1309 153 end }
bsw/jbe@1309 154
bsw/jbe@1309 155 local verifications = Verification:new_selector()
bsw/jbe@1309 156 :join("member", nil, "member.id = verification.verified_member_id")
bsw/jbe@1309 157 :add_where{ "member.identification = ?", identification }
bsw/jbe@1309 158 :add_where{ "verification.id <> ?", verification.id }
bsw/jbe@1309 159 :exec()
bsw/jbe@1309 160
bsw/jbe@1309 161 if #verifications > 0 then
bsw/jbe@1309 162
bsw/jbe@1309 163 ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
bsw/jbe@1309 164 ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
bsw/jbe@1309 165 ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = function()
bsw/jbe@1309 166 ui.tag{ content = _"Same identification" }
bsw/jbe@1309 167 end }
bsw/jbe@1309 168 end }
bsw/jbe@1309 169 ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function()
bsw/jbe@1309 170 execute.view{ module = "registration_admin", view = "_verification_list", params = { verifications = verifications } }
bsw/jbe@1309 171 end }
bsw/jbe@1309 172 end }
bsw/jbe@1309 173 end
bsw/jbe@1309 174
bsw/jbe@1309 175 for i, field_name in ipairs(config.self_registration.match_fields) do
bsw/jbe@1309 176 local field
bsw/jbe@1309 177 for j, f in ipairs(config.self_registration.fields) do
bsw/jbe@1309 178 if f.name == field_name then
bsw/jbe@1309 179 field = f
bsw/jbe@1309 180 end
bsw/jbe@1309 181 end
bsw/jbe@1309 182 local verifications = Verification:new_selector()
bsw/jbe@1309 183 :add_where("verified_member_id NOTNULL")
bsw/jbe@1309 184 :add_where{ "lower(request_data->>'" .. field.name .. "') = lower(?)", data[field.name] }
bsw/jbe@1309 185 :add_where{ "verification.id <> ?", verification.id }
bsw/jbe@1309 186 :exec()
bsw/jbe@1309 187
bsw/jbe@1309 188 if #verifications > 0 then
bsw/jbe@1309 189 ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
bsw/jbe@1309 190 ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
bsw/jbe@1309 191 ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = function()
bsw/jbe@1309 192 ui.tag{ content = _"Same " .. field.label }
bsw/jbe@1309 193 end }
bsw/jbe@1309 194 end }
bsw/jbe@1309 195 ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function()
bsw/jbe@1309 196 execute.view{ module = "registration_admin", view = "_verification_list", params = { verifications = verifications } }
bsw/jbe@1309 197 end }
bsw/jbe@1309 198 end }
bsw/jbe@1309 199 end
bsw/jbe@1309 200 end
bsw/jbe@1309 201
bsw/jbe@1309 202 end }
bsw/jbe@1309 203 end }
bsw/jbe@1309 204

Impressum / About Us