Indiquer si aucun élément n'est trouvé

This commit is contained in:
Vincent Vandemeulebrouck 2021-11-10 22:46:33 +01:00
parent 527ff0992e
commit 42716dcadb

View File

@ -144,9 +144,13 @@ export class Misc {
/* -------------------------------------------- */
static findFirstLike(value, elements, mapper = it=>it.name, description = 'valeurs') {
if (!value) {
return undefined;
}
value = Grammar.toLowerCaseNoAccent(value);
const subset = elements.filter(it => Grammar.toLowerCaseNoAccent(mapper(it)).includes(value));
if (subset.length == 0) {
ui.notifications.info(`Pas de ${description} correspondant à ${value}`);
return undefined;
}
let single = subset.find(it => Grammar.toLowerCaseNoAccent(mapper(it)) == value);