mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-15 13:11:08 +01:00
FIX: class tagify selector
FEAT: add tagifyCOnfig on weapon sheet FIX: prettier format
This commit is contained in:
parent
474177f7d0
commit
5eab093ac4
8 changed files with 30 additions and 166 deletions
|
|
@ -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'] });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue