backoffice: display user infos in autocomplete (#49039)

This commit is contained in:
Lauréline Guérin 2021-03-26 14:18:23 +01:00
parent ca2d3974a3
commit 45d974ca57
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
1 changed files with 30 additions and 1 deletions

View File

@ -157,7 +157,36 @@ $(function() {
},
url: '/api/users/'
},
placeholder: '-'
placeholder: '-',
templateResult: function (state) {
console.log(state);
if (!state.id) {
return state.text;
}
var details = '';
if (state.user_email) {
details += ' ' + state.user_email;
}
if (state.user_var_phone) {
details += ' 📞 ' + state.user_var_phone;
}
if (state.user_var_mobile) {
details += ' 📱 ' + state.user_var_mobile;
}
if (state.user_var_address || state.user_var_zipcode || state.user_var_city) {
details += ' 📨';
}
if (state.user_var_address) {
details += ' ' + state.user_var_address;
}
if (state.user_var_zipcode) {
details += ' ' + state.user_var_zipcode;
}
if (state.user_var_city) {
details += ' ' + state.user_var_city;
}
return $('<span>' + state.text + '</span><br /><span>' + details + '</span>');
}
}
if ($('div.submit-user-selection').length) {
$('div.submit-user-selection select').select2(select2_options);