mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-09 20:51:21 +01:00
Dialog setup
This commit is contained in:
parent
97f8da69cd
commit
80c347471b
19 changed files with 473 additions and 14 deletions
62
module/applications/sheets/items/beastform.mjs
Normal file
62
module/applications/sheets/items/beastform.mjs
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
import DHBaseItemSheet from '../api/base-item.mjs';
|
||||
|
||||
export default class BeastformSheet extends DHBaseItemSheet {
|
||||
/**@inheritdoc */
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: ['beastform'],
|
||||
dragDrop: [{ dragSelector: null, dropSelector: '.drop-section' }],
|
||||
actions: {
|
||||
editFeature: this.editFeature,
|
||||
removeFeature: this.removeFeature
|
||||
}
|
||||
};
|
||||
|
||||
/**@override */
|
||||
static PARTS = {
|
||||
header: { template: 'systems/daggerheart/templates/sheets/items/beastform/header.hbs' },
|
||||
tabs: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs' },
|
||||
settings: { template: 'systems/daggerheart/templates/sheets/items/beastform/settings.hbs' },
|
||||
features: {
|
||||
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-features.hbs',
|
||||
scrollable: ['.features']
|
||||
}
|
||||
};
|
||||
|
||||
static TABS = {
|
||||
primary: {
|
||||
tabs: [{ id: 'settings' }, { id: 'features' }],
|
||||
initial: 'settings',
|
||||
labelPrefix: 'DAGGERHEART.Sheets.TABS'
|
||||
}
|
||||
};
|
||||
|
||||
/**@inheritdoc */
|
||||
async _preparePartContext(partId, context) {
|
||||
await super._preparePartContext(partId, context);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
static editFeature(event) {
|
||||
const target = event.target.closest('[data-action="editFeature"]');
|
||||
const feature = this.document.system.features[target.dataset.index];
|
||||
feature.sheet.render(true);
|
||||
}
|
||||
|
||||
static async removeFeature(_, target) {
|
||||
const current = this.document.system.features.map(x => x.uuid);
|
||||
await this.document.update({
|
||||
'system.features': current.filter((_, index) => index !== Number(target.dataset.index))
|
||||
});
|
||||
this.render();
|
||||
}
|
||||
|
||||
async _onDrop(event) {
|
||||
const data = TextEditor.getDragEventData(event);
|
||||
const item = await fromUuid(data.uuid);
|
||||
if (item.type === 'feature') {
|
||||
const current = this.document.system.features.map(x => x.uuid);
|
||||
await this.document.update({ 'system.features': [...current, item.uuid] });
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue