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 { 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);
}

View file

@ -48,8 +48,8 @@ export default class ArmorSheet extends DHBaseItemSheet {
* Callback function used by `tagifyElement`.
* @param {Array<Object>} 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'] });
}
}

View file

@ -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}`;

View file

@ -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 = {};

View file

@ -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'] });
}
}