mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-15 13:11:08 +01:00
FEAT: add tafify config on DHApplicationMixin
This commit is contained in:
parent
61ea8b85fb
commit
474177f7d0
3 changed files with 89 additions and 38 deletions
|
|
@ -1,11 +1,17 @@
|
|||
import DHBaseItemSheet from '../api/base-item.mjs';
|
||||
import { tagifyElement } from '../../../helpers/utils.mjs';
|
||||
|
||||
export default class ArmorSheet extends DHBaseItemSheet {
|
||||
/**@inheritdoc */
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: ['armor'],
|
||||
dragDrop: [{ dragSelector: null, dropSelector: null }]
|
||||
dragDrop: [{ dragSelector: null, dropSelector: null }],
|
||||
tagifyConfigs: [
|
||||
{
|
||||
selector: '.features-input',
|
||||
options: () => CONFIG.daggerheart.ITEM.armorFeatures,
|
||||
callback: ArmorSheet.#onFeatureSelect
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
/**@override */
|
||||
|
|
@ -36,20 +42,11 @@ export default class ArmorSheet extends DHBaseItemSheet {
|
|||
return context;
|
||||
}
|
||||
|
||||
/**@inheritdoc */
|
||||
_attachPartListeners(partId, htmlElement, options) {
|
||||
super._attachPartListeners(partId, htmlElement, options);
|
||||
|
||||
const featureInput = htmlElement.querySelector('.features-input');
|
||||
tagifyElement(featureInput, CONFIG.daggerheart.ITEM.armorFeatures, ArmorSheet.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