mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
* FIX: Add enritch to HTMLField FIX: Remove no-HTMLField from Manifest FIX: Convert Scar's HTMLField to StringField FIX: Remove unused HTMLField * REMOVE unused hanldebars helpers * FEAT: add inventory-fieldset-items-V2 and inventory-item-V2 partials for Actors * FIX showLabels to hideTags * FEAT: add template to items sheet * FEAT: add effects tabs on ItemSheet * FEAT: add context menus for all inventory-items * FEAT: add resources to inventory-item template * FEAT: add enritch on inventory-item description FEAT: add extensible behavior on inventory-item-content FEAT: add fade effect on item-img to roll-itmg * FEAT: add eritch to NPC description FIX: missing htmlFieldss on manfiest FIX: add misisng localizations * FIX_ minor fixes * Little resource fix. Noone will notice ._. * FIX: remove default list styles FIX: .extended css reduce max-height, shorten animation duration to 0.5s, and set overflow to auto. FIX: set enriched=notes.enriche on notes.hbs FIX: set experience.value on sidebar.hbs FIX: move tooltip from item-img to img-portrait on inventory-item-V2.hbs REMOVE: unused files --------- Co-authored-by: Joaquin Pereyra <joaquinpereyra98@users.noreply.github.com> Co-authored-by: WBHarry <williambjrklund@gmail.com>
82 lines
3.1 KiB
JavaScript
82 lines
3.1 KiB
JavaScript
import DHHeritageSheet from '../api/heritage-sheet.mjs';
|
|
|
|
export default class AncestrySheet extends DHHeritageSheet {
|
|
/**@inheritdoc */
|
|
static DEFAULT_OPTIONS = {
|
|
classes: ['ancestry'],
|
|
actions: {
|
|
editFeature: AncestrySheet.#editFeature,
|
|
removeFeature: AncestrySheet.#removeFeature
|
|
},
|
|
dragDrop: [{ dragSelector: null, dropSelector: '.tab.features .drop-section' }]
|
|
};
|
|
|
|
/**@inheritdoc */
|
|
static PARTS = {
|
|
header: { template: 'systems/daggerheart/templates/sheets/items/ancestry/header.hbs' },
|
|
...super.PARTS,
|
|
features: { template: 'systems/daggerheart/templates/sheets/items/ancestry/features.hbs' }
|
|
};
|
|
|
|
/* -------------------------------------------- */
|
|
/* Application Clicks Actions */
|
|
/* -------------------------------------------- */
|
|
|
|
/**
|
|
* Edit an existing feature on the item
|
|
* @type {ApplicationClickAction}
|
|
*/
|
|
static async #editFeature(_event, button) {
|
|
const target = button.closest('.feature-item');
|
|
const feature = this.document.system[`${target.dataset.type}Feature`];
|
|
if (!feature || Object.keys(feature).length === 0) {
|
|
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.featureIsMissing'));
|
|
return;
|
|
}
|
|
|
|
feature.sheet.render(true);
|
|
}
|
|
|
|
/**
|
|
* Remove a feature from the item.
|
|
* @type {ApplicationClickAction}
|
|
*/
|
|
static async #removeFeature(event, button) {
|
|
event.stopPropagation();
|
|
const target = button.closest('.feature-item');
|
|
const feature = this.document.system[`${target.dataset.type}Feature`];
|
|
|
|
if (feature) await feature.update({ 'system.subType': null });
|
|
await this.document.update({
|
|
'system.features': this.document.system.features.filter(x => x && x.uuid !== feature.uuid).map(x => x.uuid)
|
|
});
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
/* Application Drag/Drop */
|
|
/* -------------------------------------------- */
|
|
|
|
/**
|
|
* On drop on the item.
|
|
* @param {DragEvent} event - The drag event
|
|
*/
|
|
async _onDrop(event) {
|
|
event.stopPropagation();
|
|
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event);
|
|
|
|
const item = await fromUuid(data.uuid);
|
|
if (item?.type === 'feature') {
|
|
const subType = event.target.closest('.primary-feature') ? 'primary' : 'secondary';
|
|
if (item.system.subType && item.system.subType !== CONFIG.DH.ITEM.featureSubTypes[subType]) {
|
|
const error = subType === 'primary' ? 'featureNotPrimary' : 'featureNotSecondary';
|
|
ui.notifications.warn(game.i18n.localize(`DAGGERHEART.UI.Notifications.${error}`));
|
|
return;
|
|
}
|
|
|
|
await item.update({ 'system.subType': subType });
|
|
await this.document.update({
|
|
'system.features': [...this.document.system.features.map(x => x.uuid), item.uuid]
|
|
});
|
|
}
|
|
}
|
|
}
|