Recherche dans les commerces
This commit is contained in:
parent
c6c0dd43fd
commit
1a346a21c3
@ -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) {
|
||||
|
@ -1,3 +1,4 @@
|
||||
{{#unless item.system.isHidden}}
|
||||
{{#if (ne item.type 'monnaie')}}
|
||||
<li class="item flexrow list-item" data-item-id="{{item._id}}" draggable="true">
|
||||
<span class="equipement-nom {{#if (eq item.type 'conteneur')}}conteneur-name{{/if}} ">
|
||||
@ -57,3 +58,4 @@
|
||||
</span>
|
||||
</li>
|
||||
{{/if}}
|
||||
{{/unless}}
|
@ -4,6 +4,9 @@
|
||||
<a class="chat-card-button creer-un-objet">Nouvel objet</a>
|
||||
<a class="chat-card-button nettoyer-conteneurs">Tout vider</a>
|
||||
{{/if}}
|
||||
<span class="embed-inline">
|
||||
<input class="recherche flex-grow" type="text" value="{{options.recherche.text}}" name="recherche" size="8" data-dtype="String" placeholder=""/>
|
||||
</span>
|
||||
|
||||
{{#unless system.illimite}}
|
||||
{{#if calc.surEncombrementMessage}}<b>{{calc.surEncombrementMessage}}</b> ‐{{/if}}
|
||||
|
Loading…
Reference in New Issue
Block a user