From 67631a46df493235d27cdd31b65d2c579dd6e53c Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 6 May 2021 21:34:07 +0200 Subject: [PATCH] Fix error changement categorie --- module/item-sheet.js | 16 +++++++++------- module/item.js | 4 ++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/module/item-sheet.js b/module/item-sheet.js index c8d20b98..b691fc6c 100644 --- a/module/item-sheet.js +++ b/module/item-sheet.js @@ -105,9 +105,9 @@ export class RdDItemSheet extends ItemSheet { // Everything below here is only needed if the sheet is editable if (!this.options.editable) return; + // Select competence categorie - html.find(".categorie").on("click", this._onClickSelectCategorie.bind(this) ); - html.find(".categoriepotion").on("click", this.render(true) ); + html.find(".categorie").change(event => this._onSelectCategorie(event)); html.find('.sheet-competence-xp').change((event) => { if ( this.object.data.type == 'competence') { @@ -153,12 +153,14 @@ export class RdDItemSheet extends ItemSheet { } /* -------------------------------------------- */ - async _onClickSelectCategorie(event) { + async _onSelectCategorie(event) { event.preventDefault(); - - let level = RdDItemCompetence.getNiveauBase(event.currentTarget.value); - Misc.templateData(this.object).base = level; - $("#base").val( level ); + + if (this.object.isCompetence()){ + let level = RdDItemCompetence.getNiveauBase(event.currentTarget.value); + Misc.templateData(this.object).base = level; + $("#base").val(level); + } } /* -------------------------------------------- */ diff --git a/module/item.js b/module/item.js index cffc0737..b1de3222 100644 --- a/module/item.js +++ b/module/item.js @@ -17,6 +17,10 @@ export class RdDItem extends Item { return typesObjetsOeuvres; } + isCompetence() { + return Misc.data(this).type == 'competence'; + } + isConteneur() { return Misc.data(this).type == 'conteneur'; }