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);
|
this.objetVersConteneur = RdDUtility.buildArbreDeConteneurs(formData.conteneurs, formData.objets);
|
||||||
formData.conteneurs = RdDUtility.conteneursRacine(formData.conteneurs);
|
formData.conteneurs = RdDUtility.conteneursRacine(formData.conteneurs);
|
||||||
this._appliquerRechercheObjets(formData.objets, formData.conteneurs, this.options.recherche);
|
this._appliquerRechercheObjets(formData.objets, formData.conteneurs);
|
||||||
return formData;
|
return formData;
|
||||||
}
|
}
|
||||||
|
|
||||||
_appliquerRechercheObjets(objets, conteneurs, recherche) {
|
_appliquerRechercheObjets(objets, conteneurs) {
|
||||||
if (recherche) {
|
if (this.options.recherche?.text) {
|
||||||
this._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))
|
||||||
|
}
|
||||||
|
while (addVisible.length > 0)
|
||||||
|
objets.forEach(it => it.system.isHidden = !allVisible.includes(it.id))
|
||||||
|
conteneurs.forEach(it => it.system.isHidden = !allVisible.includes(it.id))
|
||||||
}
|
}
|
||||||
}
|
else {
|
||||||
|
objets.forEach(it => it.system.isHidden = false)
|
||||||
_setConteneursVisibles(objets, conteneurs) {
|
conteneurs.forEach(it => it.system.isHidden = false)
|
||||||
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))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -164,12 +164,8 @@ export class RdDBaseActorSheet extends ActorSheet {
|
|||||||
.each((index, field) => {
|
.each((index, field) => {
|
||||||
this._rechercheSelectArea(field);
|
this._rechercheSelectArea(field);
|
||||||
})
|
})
|
||||||
.keyup(async event => {
|
.keyup(async event => this._rechercherKeyup(event))
|
||||||
this._rechercherKeyup(event);
|
.change(async event => this._rechercherKeyup(event));
|
||||||
})
|
|
||||||
.change(async event =>
|
|
||||||
this.options.recherche = this._optionRecherche(event.currentTarget)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_rechercherKeyup(event) {
|
_rechercherKeyup(event) {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
{{#unless item.system.isHidden}}
|
||||||
{{#if (ne item.type 'monnaie')}}
|
{{#if (ne item.type 'monnaie')}}
|
||||||
<li class="item flexrow list-item" data-item-id="{{item._id}}" draggable="true">
|
<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}} ">
|
<span class="equipement-nom {{#if (eq item.type 'conteneur')}}conteneur-name{{/if}} ">
|
||||||
@ -57,3 +58,4 @@
|
|||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{/unless}}
|
@ -4,6 +4,9 @@
|
|||||||
<a class="chat-card-button creer-un-objet">Nouvel objet</a>
|
<a class="chat-card-button creer-un-objet">Nouvel objet</a>
|
||||||
<a class="chat-card-button nettoyer-conteneurs">Tout vider</a>
|
<a class="chat-card-button nettoyer-conteneurs">Tout vider</a>
|
||||||
{{/if}}
|
{{/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}}
|
{{#unless system.illimite}}
|
||||||
{{#if calc.surEncombrementMessage}}<b>{{calc.surEncombrementMessage}}</b> ‐{{/if}}
|
{{#if calc.surEncombrementMessage}}<b>{{calc.surEncombrementMessage}}</b> ‐{{/if}}
|
||||||
|
Loading…
Reference in New Issue
Block a user