Use a select2 box for looking to instructeurs

This commit is contained in:
simon lehericey 2019-11-04 14:49:53 +01:00
parent 9fb72ea8e6
commit 9ca026a630
10 changed files with 136 additions and 35 deletions

View file

@ -1,6 +1,13 @@
import $ from 'jquery';
import 'select2';
const optionTemplate = email =>
$(
'<span class="custom-select2-option"><span class="icon person"></span>' +
email.text +
'</span>'
);
addEventListener('ds:page:update', () => {
$('select.select2').select2({
language: 'fr',
@ -20,4 +27,20 @@ addEventListener('ds:page:update', () => {
maximumSelectionLength: '30',
width: '300px'
});
$('select.select2-limited.select-instructeurs').select2({
language: 'fr',
dropdownParent: $('.instructeur-wrapper'),
placeholder: 'Saisir ladresse email de linstructeur',
tags: true,
tokenSeparators: [',', ' '],
templateResult: optionTemplate,
templateSelection: function(email) {
return $(
'<span class="custom-select2-option"><span class="icon person"></span>' +
email.text +
'</span>'
);
}
});
});