mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-18 07:59:03 +01:00
Remade apps handling
This commit is contained in:
parent
967b3ba2ab
commit
7ff7f718ed
7 changed files with 72 additions and 13 deletions
|
|
@ -108,6 +108,13 @@ export default function DHApplicationMixin(Base) {
|
|||
tagifyConfigs: []
|
||||
};
|
||||
|
||||
/**
|
||||
* Related documents that should cause a rerender of this application when updated.
|
||||
*/
|
||||
get relatedDocs() {
|
||||
return [];
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**@inheritdoc */
|
||||
|
|
@ -118,9 +125,17 @@ export default function DHApplicationMixin(Base) {
|
|||
/**@inheritdoc */
|
||||
async _onFirstRender(context, options) {
|
||||
await super._onFirstRender(context, options);
|
||||
this.relatedDocs.map(doc => (doc.apps[this.id] = this));
|
||||
|
||||
if (!!this.options.contextMenus.length) this._createContextMenus();
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
_onClose(options) {
|
||||
super._onClose(options);
|
||||
this.relatedDocs.map(doc => delete doc.apps[this.id]);
|
||||
}
|
||||
|
||||
/**@inheritdoc */
|
||||
async _onRender(context, options) {
|
||||
await super._onRender(context, options);
|
||||
|
|
@ -511,19 +526,7 @@ export default function DHApplicationMixin(Base) {
|
|||
*/
|
||||
static async #editDoc(_event, target) {
|
||||
const doc = getDocFromElement(target);
|
||||
if (doc) {
|
||||
const appId = this.element.id;
|
||||
doc.apps[appId] = this;
|
||||
const app = await doc.sheet.render({ force: true });
|
||||
app.addEventListener(
|
||||
'close',
|
||||
() => {
|
||||
delete doc.apps[appId];
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (doc) return doc.sheet.render({ force: true });
|
||||
|
||||
// TODO: REDO this
|
||||
const { actionId } = target.closest('[data-action-id]').dataset;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,11 @@ export default class AncestrySheet extends DHHeritageSheet {
|
|||
features: { template: 'systems/daggerheart/templates/sheets/items/ancestry/features.hbs' }
|
||||
};
|
||||
|
||||
/**@inheritdoc */
|
||||
get relatedDocs() {
|
||||
return this.document.system.features.map(x => x.item);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Application Drag/Drop */
|
||||
/* -------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -31,6 +31,11 @@ export default class BeastformSheet extends DHBaseItemSheet {
|
|||
}
|
||||
};
|
||||
|
||||
/**@inheritdoc */
|
||||
get relatedDocs() {
|
||||
return this.document.system.features;
|
||||
}
|
||||
|
||||
_attachPartListeners(partId, htmlElement, options) {
|
||||
super._attachPartListeners(partId, htmlElement, options);
|
||||
|
||||
|
|
|
|||
|
|
@ -58,6 +58,11 @@ export default class ClassSheet extends DHBaseItemSheet {
|
|||
}
|
||||
};
|
||||
|
||||
/**@inheritdoc */
|
||||
get relatedDocs() {
|
||||
return this.document.system.features.map(x => x.item);
|
||||
}
|
||||
|
||||
/**@inheritdoc */
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
|
|
|
|||
|
|
@ -15,4 +15,9 @@ export default class CommunitySheet extends DHHeritageSheet {
|
|||
scrollable: ['.feature']
|
||||
}
|
||||
};
|
||||
|
||||
/**@inheritdoc */
|
||||
get relatedDocs() {
|
||||
return this.document.system.features;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,4 +35,9 @@ export default class SubclassSheet extends DHBaseItemSheet {
|
|||
labelPrefix: 'DAGGERHEART.GENERAL.Tabs'
|
||||
}
|
||||
};
|
||||
|
||||
/**@inheritdoc */
|
||||
get relatedDocs() {
|
||||
return this.document.system.features.map(x => x.item);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue