prettier refacor

FIX: missing imports
This commit is contained in:
Joaquin Pereyra 2025-06-24 15:29:50 -03:00
parent 175ae7dd23
commit 6e0d82e4f9
5 changed files with 23 additions and 36 deletions

View file

@ -1,4 +1,6 @@
import DHApplicationMixin from "./application-mixin.mjs"; import DHApplicationMixin from "./application-mixin.mjs";
import { actionsTypes } from "../../../data/_module.mjs";
import DHActionConfig from "../../config/Action.mjs";
const { ItemSheetV2 } = foundry.applications.sheets; 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"] * @param {HTMLElement} _button - The capturing HTML element which defines the [data-action="addAction"]
*/ */
static async #addAction(_event, _button) { static async #addAction(_event, _button) {
const actionType = await DHBaseItemSheet.selectActionType(), const actionType = await DHBaseItemSheet.selectActionType()
actionIndexes = this.document.system.actions.map(x => x._id.split('-')[2]).sort((a, b) => a - b);
try { try {
const cls = actionsTypes[actionType?.type] ?? actionsTypes.attack, const cls = actionsTypes[actionType?.type] ?? actionsTypes.attack,
action = new cls( action = new cls(
{ {
// id: `${this.document.id}-Action-${actionIndexes.length > 0 ? actionIndexes[0] + 1 : 1}`
_id: foundry.utils.randomID(), _id: foundry.utils.randomID(),
type: actionType.type, type: actionType.type,
name: game.i18n.localize(SYSTEM.ACTIONS.actionTypes[actionType.type].name), 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 this.document.update({ 'system.actions': [...this.document.system.actions, action] });
await new DHActionConfig(this.document.system.actions[this.document.system.actions.length - 1]).render( await new DHActionConfig(this.document.system.actions[this.document.system.actions.length - 1]).render({force: true});
true
);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }

View file

@ -48,8 +48,8 @@ export default class ArmorSheet extends DHBaseItemSheet {
* Callback function used by `tagifyElement`. * Callback function used by `tagifyElement`.
* @param {Array<Object>} selectedOptions - The currently selected tag objects. * @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 })) }); await this.document.update({ 'system.features': selectedOptions.map(x => ({ value: x.value })) });
this.render({force: false, parts: ["settings"]}); this.render({ force: false, parts: ['settings'] });
} }
} }

View file

@ -42,25 +42,19 @@ export default class FeatureSheet extends DHBaseItemSheet {
/**@override */ /**@override */
static TABS = { static TABS = {
primary: { primary: {
tabs: [ tabs: [{ id: 'description' }, { id: 'actions' }, { id: 'settings' }, { id: 'effects' }],
{ id: 'description' }, initial: 'description',
{ id: 'actions' }, labelPrefix: 'DAGGERHEART.Sheets.TABS'
{ id: 'settings' },
{ id: 'effects' }
],
initial: "description",
labelPrefix: "DAGGERHEART.Sheets.TABS"
} }
}; };
/**@inheritdoc*/ /**@inheritdoc*/
_attachPartListeners(partId, htmlElement, options) { _attachPartListeners(partId, htmlElement, options) {
super._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)); htmlElement.querySelector('.effect-select')?.addEventListener('change', this._effectSelect.bind(this));
} }
/** /**
* Handles selection of a new effect type. * Handles selection of a new effect type.
* @param {Event} event - Change Event * @param {Event} event - Change Event
@ -68,7 +62,7 @@ export default class FeatureSheet extends DHBaseItemSheet {
_effectSelect(event) { _effectSelect(event) {
const value = event.currentTarget.value; const value = event.currentTarget.value;
this._selectedEffectType = value; this._selectedEffectType = value;
this.render({ parts: ["effects"] }); this.render({ parts: ['effects'] });
} }
/**@inheritdoc */ /**@inheritdoc */
@ -83,12 +77,11 @@ export default class FeatureSheet extends DHBaseItemSheet {
return context; return context;
} }
/** /**
* Adds a new effect to the item, based on the selected effect type. * Adds a new effect to the item, based on the selected effect type.
* @param {PointerEvent} _event - The originating click event * @param {PointerEvent} _event - The originating click event
* @param {HTMLElement} _target - The capturing HTML element which defines the [data-action] * @param {HTMLElement} _target - The capturing HTML element which defines the [data-action]
* @returns * @returns
*/ */
static async addEffect(_event, _target) { static async addEffect(_event, _target) {
const type = this._selectedEffectType; const type = this._selectedEffectType;
@ -107,7 +100,7 @@ export default class FeatureSheet extends DHBaseItemSheet {
* Removes an effect from the item. * Removes an effect from the item.
* @param {PointerEvent} _event - The originating click event * @param {PointerEvent} _event - The originating click event
* @param {HTMLElement} target - The capturing HTML element which defines the [data-action] * @param {HTMLElement} target - The capturing HTML element which defines the [data-action]
* @returns * @returns
*/ */
static async removeEffect(_event, target) { static async removeEffect(_event, target) {
const path = `system.effects.-=${target.dataset.effect}`; const path = `system.effects.-=${target.dataset.effect}`;

View file

@ -11,7 +11,7 @@ export default class SubclassSheet extends DHBaseItemSheet {
addFeature: this.addFeature, addFeature: this.addFeature,
editFeature: this.editFeature, editFeature: this.editFeature,
deleteFeature: this.deleteFeature deleteFeature: this.deleteFeature
}, }
}; };
static PARTS = { static PARTS = {
@ -31,15 +31,11 @@ export default class SubclassSheet extends DHBaseItemSheet {
/** @inheritdoc */ /** @inheritdoc */
static TABS = { static TABS = {
primary: { primary: {
tabs: [ tabs: [{ id: 'description' }, { id: 'features' }, { id: 'settings' }],
{ id: 'description' }, initial: 'description',
{ id: 'features' }, labelPrefix: 'DAGGERHEART.Sheets.TABS'
{ id: 'settings' }
],
initial: "description",
labelPrefix: "DAGGERHEART.Sheets.TABS"
} }
} };
static addFeature(_, target) { static addFeature(_, target) {
if (target.dataset.type === 'action') this.addAction(target.dataset.level); if (target.dataset.type === 'action') this.addAction(target.dataset.level);
@ -58,9 +54,9 @@ export default class SubclassSheet extends DHBaseItemSheet {
async #selectActionType() { async #selectActionType() {
const content = await foundry.applications.handlebars.renderTemplate( const content = await foundry.applications.handlebars.renderTemplate(
'systems/daggerheart/templates/views/actionType.hbs', 'systems/daggerheart/templates/views/actionType.hbs',
{ types: SYSTEM.ACTIONS.actionTypes } { types: SYSTEM.ACTIONS.actionTypes }
), ),
title = 'Select Action Type', title = 'Select Action Type',
type = 'form', type = 'form',
data = {}; data = {};

View file

@ -50,6 +50,6 @@ export default class WeaponSheet extends DHBaseItemSheet {
*/ */
static async onFeatureSelect(selectedOptions) { static async onFeatureSelect(selectedOptions) {
await this.document.update({ 'system.features': selectedOptions.map(x => ({ value: x.value })) }); await this.document.update({ 'system.features': selectedOptions.map(x => ({ value: x.value })) });
this.render({ force: false, parts: ["settings"] }); this.render({ force: false, parts: ['settings'] });
} }
} }