mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-06-06 12:54:16 +02:00
Some checks failed
Project CI / build (24.x) (push) Has been cancelled
* Initial thoughts * . * Fixed linting * Continue work on updating identifier * Change to uuid approach * Localization and minor fix * Fixed CompendiumBrowser Class filter for Subclass view * Fixed the class name display in the subclass view * Improved missing class visual for subclass * Fixed character creation * Rerender class sheets when subclass link is changed * Use compendium source over actual uuid in search --------- Co-authored-by: Carlos Fernandez <cfern1990@gmail.com>
75 lines
2.7 KiB
JavaScript
75 lines
2.7 KiB
JavaScript
import DHBaseItemSheet from '../api/base-item.mjs';
|
|
|
|
export default class SubclassSheet extends DHBaseItemSheet {
|
|
/**@inheritdoc */
|
|
static DEFAULT_OPTIONS = {
|
|
classes: ['subclass'],
|
|
position: { width: 600 },
|
|
window: { resizable: true }
|
|
};
|
|
|
|
/**@override */
|
|
static PARTS = {
|
|
header: { template: 'systems/daggerheart/templates/sheets/items/subclass/header.hbs' },
|
|
tabs: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs' },
|
|
description: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-description.hbs' },
|
|
features: {
|
|
template: 'systems/daggerheart/templates/sheets/items/subclass/features.hbs',
|
|
scrollable: ['.features']
|
|
},
|
|
settings: {
|
|
template: 'systems/daggerheart/templates/sheets/items/subclass/settings.hbs',
|
|
scrollable: ['.settings']
|
|
},
|
|
effects: {
|
|
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-effects.hbs',
|
|
scrollable: ['.effects']
|
|
}
|
|
};
|
|
|
|
/** @inheritdoc */
|
|
static TABS = {
|
|
primary: {
|
|
tabs: [{ id: 'description' }, { id: 'features' }, { id: 'settings' }, { id: 'effects' }],
|
|
initial: 'description',
|
|
labelPrefix: 'DAGGERHEART.GENERAL.Tabs'
|
|
}
|
|
};
|
|
|
|
/**@inheritdoc */
|
|
get relatedDocs() {
|
|
return this.document.system.features.map(x => x.item);
|
|
}
|
|
|
|
async _prepareContext(options) {
|
|
const context = await super._prepareContext(options);
|
|
if (this.document.system.linkedClass) {
|
|
const classData = await fromUuid(this.document.system.linkedClass);
|
|
context.class = classData ?? {
|
|
name: _loc('DAGGERHEART.GENERAL.missingX', { x: _loc('TYPES.Item.class') }),
|
|
missing: true
|
|
};
|
|
}
|
|
return context;
|
|
}
|
|
|
|
async _onDrop(event) {
|
|
event.stopPropagation();
|
|
const data = TextEditor.getDragEventData(event);
|
|
const item = await fromUuid(data.uuid);
|
|
const itemType = data.type === 'ActiveEffect' ? data.type : item.type;
|
|
if (itemType === 'class') {
|
|
const uuid = item._stats.compendiumSource ?? item.uuid;
|
|
if (this.document.system.linkedClass !== uuid) {
|
|
await this.document.update({ 'system.linkedClass': uuid });
|
|
// Re-render all class sheets for instant feedback
|
|
for (const app of foundry.applications.instances.values()) {
|
|
if (app.document?.type === 'class') app.render();
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
return super._onDrop(event);
|
|
}
|
|
}
|