diff --git a/module/applications/sheets/api/base-item.mjs b/module/applications/sheets/api/base-item.mjs index e6fcf26a..b85f9696 100644 --- a/module/applications/sheets/api/base-item.mjs +++ b/module/applications/sheets/api/base-item.mjs @@ -1,4 +1,6 @@ import DHApplicationMixin from "./application-mixin.mjs"; +import { actionsTypes } from "../../../data/_module.mjs"; +import DHActionConfig from "../../config/Action.mjs"; const { ItemSheetV2 } = foundry.applications.sheets; @@ -77,13 +79,11 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) { * @param {HTMLElement} _button - The capturing HTML element which defines the [data-action="addAction"] */ static async #addAction(_event, _button) { - const actionType = await DHBaseItemSheet.selectActionType(), - actionIndexes = this.document.system.actions.map(x => x._id.split('-')[2]).sort((a, b) => a - b); + const actionType = await DHBaseItemSheet.selectActionType() try { const cls = actionsTypes[actionType?.type] ?? actionsTypes.attack, action = new cls( { - // id: `${this.document.id}-Action-${actionIndexes.length > 0 ? actionIndexes[0] + 1 : 1}` _id: foundry.utils.randomID(), type: actionType.type, name: game.i18n.localize(SYSTEM.ACTIONS.actionTypes[actionType.type].name), @@ -94,9 +94,7 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) { } ); await this.document.update({ 'system.actions': [...this.document.system.actions, action] }); - await new DHActionConfig(this.document.system.actions[this.document.system.actions.length - 1]).render( - true - ); + await new DHActionConfig(this.document.system.actions[this.document.system.actions.length - 1]).render({force: true}); } catch (error) { console.log(error); } diff --git a/module/applications/sheets/items/armor.mjs b/module/applications/sheets/items/armor.mjs index 4cc05fe2..4098d376 100644 --- a/module/applications/sheets/items/armor.mjs +++ b/module/applications/sheets/items/armor.mjs @@ -48,8 +48,8 @@ export default class ArmorSheet extends DHBaseItemSheet { * Callback function used by `tagifyElement`. * @param {Array} selectedOptions - The currently selected tag objects. */ - static async onFeatureSelect(selectedOptions ) { - await this.document.update({ 'system.features': selectedOptions .map(x => ({ value: x.value })) }); - this.render({force: false, parts: ["settings"]}); + static async onFeatureSelect(selectedOptions) { + await this.document.update({ 'system.features': selectedOptions.map(x => ({ value: x.value })) }); + this.render({ force: false, parts: ['settings'] }); } } diff --git a/module/applications/sheets/items/feature.mjs b/module/applications/sheets/items/feature.mjs index c312b7b6..077186f1 100644 --- a/module/applications/sheets/items/feature.mjs +++ b/module/applications/sheets/items/feature.mjs @@ -42,25 +42,19 @@ export default class FeatureSheet extends DHBaseItemSheet { /**@override */ static TABS = { primary: { - tabs: [ - { id: 'description' }, - { id: 'actions' }, - { id: 'settings' }, - { id: 'effects' } - ], - initial: "description", - labelPrefix: "DAGGERHEART.Sheets.TABS" + tabs: [{ id: 'description' }, { id: 'actions' }, { id: 'settings' }, { id: 'effects' }], + initial: 'description', + labelPrefix: 'DAGGERHEART.Sheets.TABS' } }; /**@inheritdoc*/ _attachPartListeners(partId, htmlElement, options) { super._attachPartListeners(partId, htmlElement, options); - if (partId === "effects") + if (partId === 'effects') htmlElement.querySelector('.effect-select')?.addEventListener('change', this._effectSelect.bind(this)); } - /** * Handles selection of a new effect type. * @param {Event} event - Change Event @@ -68,7 +62,7 @@ export default class FeatureSheet extends DHBaseItemSheet { _effectSelect(event) { const value = event.currentTarget.value; this._selectedEffectType = value; - this.render({ parts: ["effects"] }); + this.render({ parts: ['effects'] }); } /**@inheritdoc */ @@ -83,12 +77,11 @@ export default class FeatureSheet extends DHBaseItemSheet { return context; } - /** * Adds a new effect to the item, based on the selected effect type. * @param {PointerEvent} _event - The originating click event * @param {HTMLElement} _target - The capturing HTML element which defines the [data-action] - * @returns + * @returns */ static async addEffect(_event, _target) { const type = this._selectedEffectType; @@ -107,7 +100,7 @@ export default class FeatureSheet extends DHBaseItemSheet { * Removes an effect from the item. * @param {PointerEvent} _event - The originating click event * @param {HTMLElement} target - The capturing HTML element which defines the [data-action] - * @returns + * @returns */ static async removeEffect(_event, target) { const path = `system.effects.-=${target.dataset.effect}`; diff --git a/module/applications/sheets/items/subclass.mjs b/module/applications/sheets/items/subclass.mjs index 823a953a..1aeb6063 100644 --- a/module/applications/sheets/items/subclass.mjs +++ b/module/applications/sheets/items/subclass.mjs @@ -11,7 +11,7 @@ export default class SubclassSheet extends DHBaseItemSheet { addFeature: this.addFeature, editFeature: this.editFeature, deleteFeature: this.deleteFeature - }, + } }; static PARTS = { @@ -31,15 +31,11 @@ export default class SubclassSheet extends DHBaseItemSheet { /** @inheritdoc */ static TABS = { primary: { - tabs: [ - { id: 'description' }, - { id: 'features' }, - { id: 'settings' } - ], - initial: "description", - labelPrefix: "DAGGERHEART.Sheets.TABS" + tabs: [{ id: 'description' }, { id: 'features' }, { id: 'settings' }], + initial: 'description', + labelPrefix: 'DAGGERHEART.Sheets.TABS' } - } + }; static addFeature(_, target) { if (target.dataset.type === 'action') this.addAction(target.dataset.level); @@ -58,9 +54,9 @@ export default class SubclassSheet extends DHBaseItemSheet { async #selectActionType() { const content = await foundry.applications.handlebars.renderTemplate( - 'systems/daggerheart/templates/views/actionType.hbs', - { types: SYSTEM.ACTIONS.actionTypes } - ), + 'systems/daggerheart/templates/views/actionType.hbs', + { types: SYSTEM.ACTIONS.actionTypes } + ), title = 'Select Action Type', type = 'form', data = {}; diff --git a/module/applications/sheets/items/weapon.mjs b/module/applications/sheets/items/weapon.mjs index 70f82f68..ab018943 100644 --- a/module/applications/sheets/items/weapon.mjs +++ b/module/applications/sheets/items/weapon.mjs @@ -50,6 +50,6 @@ export default class WeaponSheet extends DHBaseItemSheet { */ static async onFeatureSelect(selectedOptions) { await this.document.update({ 'system.features': selectedOptions.map(x => ({ value: x.value })) }); - this.render({ force: false, parts: ["settings"] }); + this.render({ force: false, parts: ['settings'] }); } }