Arbre de conteneurs et recherche améliorée #546

Merged
uberwald merged 2 commits from VincentVk/foundryvtt-reve-de-dragon:v1.5 into v1.5 2022-08-27 19:11:56 +02:00
2 changed files with 36 additions and 10 deletions
Showing only changes of commit 82115ed8d7 - Show all commits

View File

@ -37,8 +37,7 @@ export class RdDActorSheet extends ActorSheet {
/* -------------------------------------------- */
async getData() {
const objectData = Misc.data(this.object);
//this.actor.checkMonnaiePresence(this.actor.data.items); // Always check
this.timerRecherche = undefined;
let formData = {
title: this.title,
@ -78,8 +77,8 @@ export class RdDActorSheet extends ActorSheet {
};
formData.competences.forEach(item => {
item.visible = this.options.cherchercompetence
? RdDItemCompetence.nomContientTexte(item, this.options.cherchercompetence)
item.visible = this.options.recherche
? RdDItemCompetence.nomContientTexte(item, this.options.recherche.text)
: (!this.options.showCompNiveauBase || !RdDItemCompetence.isNiveauBase(item));
RdDItemCompetence.levelUp(item, formData.data.compteurs.experience.value);
});
@ -424,12 +423,28 @@ export class RdDActorSheet extends ActorSheet {
this.options.editCaracComp = !this.options.editCaracComp;
this.render(true);
});
html.find('.cherchercompetence').change(async event => {
this.options.cherchercompetence = event.currentTarget.value;
html.find('.recherche')
.each((index, field) => {
if (this.options.recherche) {
field.focus();
field.setSelectionRange(this.options.recherche.start, this.options.recherche.end);
}
})
.keyup(async event => {
this.options.recherche = this._optionRecherche(event.currentTarget)
if (this.timerRecherche) {
clearTimeout(this.timerRecherche);
}
this.timerRecherche = setTimeout(() => {
this.timerRecherche = undefined;
this.render(true);
});
}, 500);
})
.change(async event =>
this.options.recherche = this._optionRecherche(event.currentTarget)
);
html.find('.vue-detaillee').click(async event => {
console.log("CONTROLS", this.options.vueDetaillee)
this.options.vueDetaillee = !this.options.vueDetaillee;
this.render(true);
});
@ -515,6 +530,17 @@ export class RdDActorSheet extends ActorSheet {
});
}
_optionRecherche(target) {
if (!target.value?.length){
return undefined;
}
return {
text: target.value,
start: target.selectionStart,
end: target.selectionEnd,
};
}
_getEventArmeCombat(event) {
const li = $(event.currentTarget)?.parents(".item");
let armeName = li.data("arme-name");

View File

@ -217,7 +217,7 @@
{{#if options.editCaracComp}}Verrouiller{{else}}Déverrouiller{{/if}}</a></span>
<span class="flexrow">
<i class="fas fa-search"></i>
<input class="cherchercompetence" type="text" value="{{options.cherchercompetence}}" name="cherchercompetence"
<input class="recherche" type="text" value="{{options.recherche.text}}" name="recherche"
size="8" data-dtype="String" placeholder="chercher"/>
<span></span>
</span>