From 1bec52371a5bf395330a8e5f6184236440fb397b Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Fri, 26 Nov 2021 01:02:44 +0100 Subject: [PATCH] =?UTF-8?q?Recherche=20de=20comp=C3=A9tence?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Filtrage des compétences contenant le texte saisi --- module/actor-sheet.js | 8 +++++++- module/item-competence.js | 4 ++++ templates/actor-sheet.html | 12 +++++++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 1eec4a57..53e04120 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -78,7 +78,9 @@ export class RdDActorSheet extends ActorSheet { formData.calc.surEncombrementMessage = (formData.data.compteurs.surenc.value < 0) ? "Sur-Encombrement!" : ""; formData.competences.forEach(item => { - item.visible = !this.options.showCompNiveauBase || !RdDItemCompetence.isNiveauBase(item); + item.visible = this.options.cherchercompetence + ? RdDItemCompetence.nomContientTexte(item, this.options.cherchercompetence) + : ( !this.options.showCompNiveauBase || !RdDItemCompetence.isNiveauBase(item) ); RdDItemCompetence.levelUp(item, formData.data.compteurs.experience.value); }); @@ -421,6 +423,10 @@ 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; + this.render(true); + }); html.find('.vue-detaillee').click(async event => { console.log("CONTROLS", this.options.vueDetaillee) this.options.vueDetaillee = !this.options.vueDetaillee; diff --git a/module/item-competence.js b/module/item-competence.js index 8abae8cf..268e4116 100644 --- a/module/item-competence.js +++ b/module/item-competence.js @@ -201,6 +201,10 @@ export class RdDItemCompetence extends Item { return Number(itemData.data.niveau) != RdDItemCompetence.getNiveauBase(itemData.data.categorie); } + static nomContientTexte(itemData, texte) { + return Grammar.toLowerCaseNoAccent(itemData.name).includes(Grammar.toLowerCaseNoAccent(texte)) + } + /* -------------------------------------------- */ static isNiveauBase(itemData) { return Number(itemData.data.niveau) == RdDItemCompetence.getNiveauBase(itemData.data.categorie); diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index d4884cb3..2fc58ae1 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -208,10 +208,16 @@ {{!-- Compétences Tab --}}
-
+
blocker/débloquer{{#if options.editCaracComp}}Verrouiller{{else}}Déverrouiller{{/if}} + src="systems/foundryvtt-reve-de-dragon/icons/{{#if options.editCaracComp}}unlocked.svg{{else}}locked.svg{{/if}}" alt="blocker/débloquer"> + {{#if options.editCaracComp}}Verrouiller{{else}}Déverrouiller{{/if}} + + + + + filter/montrer tout {{#if options.showCompNiveauBase}}Montrer tout{{else}}Filtrer{{/if}}