Recherche dans les commerces
This commit is contained in:
@ -52,28 +52,28 @@ export class RdDBaseActorSheet extends ActorSheet {
|
||||
|
||||
this.objetVersConteneur = RdDUtility.buildArbreDeConteneurs(formData.conteneurs, formData.objets);
|
||||
formData.conteneurs = RdDUtility.conteneursRacine(formData.conteneurs);
|
||||
this._appliquerRechercheObjets(formData.objets, formData.conteneurs, this.options.recherche);
|
||||
this._appliquerRechercheObjets(formData.objets, formData.conteneurs);
|
||||
return formData;
|
||||
}
|
||||
|
||||
_appliquerRechercheObjets(objets, conteneurs, recherche) {
|
||||
if (recherche) {
|
||||
this._setConteneursVisibles(objets, conteneurs);
|
||||
_appliquerRechercheObjets(objets, conteneurs) {
|
||||
if (this.options.recherche?.text) {
|
||||
const recherche = this.options.recherche;
|
||||
const allVisible = objets.filter(it => it.isNomTypeLike(recherche.text)).map(it => it.id);
|
||||
let addVisible = conteneurs.filter(it => it.isNomTypeLike(recherche.text)).map(it => it.id)
|
||||
do {
|
||||
allVisible.push(...addVisible)
|
||||
const parentsIds = conteneurs.filter(it => it.system.contenu.find(id => allVisible.includes(id))).map(it => it.id)
|
||||
addVisible = parentsIds.filter(id => !allVisible.includes(id))
|
||||
}
|
||||
while (addVisible.length > 0)
|
||||
objets.forEach(it => it.system.isHidden = !allVisible.includes(it.id))
|
||||
conteneurs.forEach(it => it.system.isHidden = !allVisible.includes(it.id))
|
||||
}
|
||||
}
|
||||
|
||||
_setConteneursVisibles(objets, conteneurs) {
|
||||
const recherche = this.options.recherche;
|
||||
const allVisible = objets.filter(it => it.isNomTypeLike(recherche.text)).map(it => it.id);
|
||||
let addVisible = conteneurs.filter(it => it.isNomTypeLike(recherche.text)).map(it => it.id)
|
||||
do {
|
||||
allVisible.push(...addVisible)
|
||||
const parentsIds = conteneurs.filter(it => it.system.contenu.find(id => allVisible.includes(id))).map(it => it.id)
|
||||
addVisible = parentsIds.filter(id => !allVisible.includes(id))
|
||||
else {
|
||||
objets.forEach(it => it.system.isHidden = false)
|
||||
conteneurs.forEach(it => it.system.isHidden = false)
|
||||
}
|
||||
while (addVisible.length > 0)
|
||||
objets.forEach(it => it.system.isHidden = !allVisible.includes(it.id))
|
||||
conteneurs.forEach(it => it.system.isHidden = !allVisible.includes(it.id))
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -164,12 +164,8 @@ export class RdDBaseActorSheet extends ActorSheet {
|
||||
.each((index, field) => {
|
||||
this._rechercheSelectArea(field);
|
||||
})
|
||||
.keyup(async event => {
|
||||
this._rechercherKeyup(event);
|
||||
})
|
||||
.change(async event =>
|
||||
this.options.recherche = this._optionRecherche(event.currentTarget)
|
||||
);
|
||||
.keyup(async event => this._rechercherKeyup(event))
|
||||
.change(async event => this._rechercherKeyup(event));
|
||||
}
|
||||
|
||||
_rechercherKeyup(event) {
|
||||
|
Reference in New Issue
Block a user