FIX: class tagify selector

FEAT: add tagifyCOnfig on weapon sheet
FIX: prettier format
This commit is contained in:
Joaquin Pereyra 2025-06-25 15:20:01 -03:00
parent 474177f7d0
commit 5eab093ac4
8 changed files with 30 additions and 166 deletions

View file

@ -1,11 +1,16 @@
import DHBaseItemSheet from '../api/base-item.mjs';
import { weaponFeatures } from '../../../config/itemConfig.mjs';
import { tagifyElement } from '../../../helpers/utils.mjs';
export default class WeaponSheet extends DHBaseItemSheet {
/**@inheritdoc */
static DEFAULT_OPTIONS = {
classes: ['weapon']
classes: ['weapon'],
tagifyConfigs: [
{
selector: '.features-input',
choices: () => CONFIG.daggerheart.ITEM.weaponFeatures,
callback: WeaponSheet.#onFeatureSelect
}
]
};
/**@override */
@ -36,20 +41,11 @@ export default class WeaponSheet extends DHBaseItemSheet {
return context;
}
/**@inheritdoc */
_attachPartListeners(partId, htmlElement, options) {
super._attachPartListeners(partId, htmlElement, options);
const featureInput = htmlElement.querySelector('.features-input');
tagifyElement(featureInput, weaponFeatures, WeaponSheet.onFeatureSelect.bind(this));
}
/**
* Callback function used by `tagifyElement`.
* @param {Array<Object>} selectedOptions - The currently selected tag objects.
*/
static async onFeatureSelect(selectedOptions) {
static async #onFeatureSelect(selectedOptions) {
await this.document.update({ 'system.features': selectedOptions.map(x => ({ value: x.value })) });
this.render({ force: false, parts: ['settings'] });
}
}