Indiquer si aucun élément n'est trouvé
This commit is contained in:
parent
527ff0992e
commit
42716dcadb
@ -144,9 +144,13 @@ export class Misc {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static findFirstLike(value, elements, mapper = it=>it.name, description = 'valeurs') {
|
static findFirstLike(value, elements, mapper = it=>it.name, description = 'valeurs') {
|
||||||
|
if (!value) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
value = Grammar.toLowerCaseNoAccent(value);
|
value = Grammar.toLowerCaseNoAccent(value);
|
||||||
const subset = elements.filter(it => Grammar.toLowerCaseNoAccent(mapper(it)).includes(value));
|
const subset = elements.filter(it => Grammar.toLowerCaseNoAccent(mapper(it)).includes(value));
|
||||||
if (subset.length == 0) {
|
if (subset.length == 0) {
|
||||||
|
ui.notifications.info(`Pas de ${description} correspondant à ${value}`);
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
let single = subset.find(it => Grammar.toLowerCaseNoAccent(mapper(it)) == value);
|
let single = subset.find(it => Grammar.toLowerCaseNoAccent(mapper(it)) == value);
|
||||||
|
Loading…
Reference in New Issue
Block a user