2018-08-09 11:53:59 +02:00
|
|
|
|
import $ from 'jquery';
|
2018-08-22 14:47:56 +02:00
|
|
|
|
import 'select2';
|
2020-01-14 18:46:07 +01:00
|
|
|
|
|
|
|
|
|
const language = {
|
2020-04-30 15:42:29 +02:00
|
|
|
|
errorLoading: function () {
|
2020-01-14 18:46:07 +01:00
|
|
|
|
return 'Les résultats ne peuvent pas être chargés.';
|
|
|
|
|
},
|
2020-04-30 15:42:29 +02:00
|
|
|
|
inputTooLong: function (args) {
|
2020-01-14 18:46:07 +01:00
|
|
|
|
var overChars = args.input.length - args.maximum;
|
|
|
|
|
|
|
|
|
|
return 'Supprimez ' + overChars + ' caractère' + (overChars > 1 ? 's' : '');
|
|
|
|
|
},
|
2020-04-30 15:42:29 +02:00
|
|
|
|
inputTooShort: function (args) {
|
2020-01-14 18:46:07 +01:00
|
|
|
|
var remainingChars = args.minimum - args.input.length;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
'Saisissez au moins ' +
|
|
|
|
|
remainingChars +
|
|
|
|
|
' caractère' +
|
|
|
|
|
(remainingChars > 1 ? 's' : '')
|
|
|
|
|
);
|
|
|
|
|
},
|
2020-04-30 15:42:29 +02:00
|
|
|
|
loadingMore: function () {
|
2020-01-14 18:46:07 +01:00
|
|
|
|
return 'Chargement de résultats supplémentaires…';
|
|
|
|
|
},
|
2020-04-30 15:42:29 +02:00
|
|
|
|
maximumSelected: function (args) {
|
2020-01-14 18:46:07 +01:00
|
|
|
|
return (
|
|
|
|
|
'Vous pouvez seulement sélectionner ' +
|
|
|
|
|
args.maximum +
|
|
|
|
|
' élément' +
|
|
|
|
|
(args.maximum > 1 ? 's' : '')
|
|
|
|
|
);
|
|
|
|
|
},
|
2020-04-30 15:42:29 +02:00
|
|
|
|
noResults: function () {
|
2020-01-14 18:46:07 +01:00
|
|
|
|
return 'Aucun résultat trouvé';
|
|
|
|
|
},
|
2020-04-30 15:42:29 +02:00
|
|
|
|
searching: function () {
|
2020-01-14 18:46:07 +01:00
|
|
|
|
return 'Recherche en cours…';
|
|
|
|
|
},
|
2020-04-30 15:42:29 +02:00
|
|
|
|
removeAllItems: function () {
|
2020-01-14 18:46:07 +01:00
|
|
|
|
return 'Supprimer tous les éléments';
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const baseOptions = {
|
|
|
|
|
language,
|
|
|
|
|
width: '100%'
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const templateOption = ({ text }) =>
|
2019-11-04 14:49:53 +01:00
|
|
|
|
$(
|
2020-01-14 18:46:07 +01:00
|
|
|
|
`<span class="custom-select2-option"><span class="icon person"></span>${text}</span>`
|
2019-11-04 14:49:53 +01:00
|
|
|
|
);
|
|
|
|
|
|
2019-08-01 15:22:37 +02:00
|
|
|
|
addEventListener('ds:page:update', () => {
|
2020-01-14 18:46:07 +01:00
|
|
|
|
$('select.select2').select2(baseOptions);
|
2018-07-12 11:50:47 +02:00
|
|
|
|
|
2018-09-10 17:52:29 +02:00
|
|
|
|
$('.columns-form select.select2-limited').select2({
|
2020-01-14 18:46:07 +01:00
|
|
|
|
width: '300px',
|
2018-07-12 11:50:47 +02:00
|
|
|
|
placeholder: 'Sélectionnez des colonnes',
|
2020-01-14 18:46:07 +01:00
|
|
|
|
maximumSelectionLength: '5'
|
2018-07-12 11:50:47 +02:00
|
|
|
|
});
|
2018-09-10 17:52:49 +02:00
|
|
|
|
|
|
|
|
|
$('.recipients-form select.select2-limited').select2({
|
2020-01-14 18:46:07 +01:00
|
|
|
|
language,
|
|
|
|
|
width: '300px',
|
2018-09-10 17:52:49 +02:00
|
|
|
|
placeholder: 'Sélectionnez des instructeurs',
|
2020-01-14 18:46:07 +01:00
|
|
|
|
maximumSelectionLength: '30'
|
2018-09-10 17:52:49 +02:00
|
|
|
|
});
|
2019-11-04 14:49:53 +01:00
|
|
|
|
|
|
|
|
|
$('select.select2-limited.select-instructeurs').select2({
|
2020-01-14 18:46:07 +01:00
|
|
|
|
language,
|
2019-11-04 14:49:53 +01:00
|
|
|
|
dropdownParent: $('.instructeur-wrapper'),
|
|
|
|
|
placeholder: 'Saisir l’adresse email de l’instructeur',
|
|
|
|
|
tags: true,
|
|
|
|
|
tokenSeparators: [',', ' '],
|
2020-01-14 18:46:07 +01:00
|
|
|
|
templateResult: templateOption,
|
|
|
|
|
templateSelection: templateOption
|
2019-11-04 14:49:53 +01:00
|
|
|
|
});
|
2018-07-12 11:50:47 +02:00
|
|
|
|
});
|