mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-18 16:09:03 +01:00
Fixed using ItemLinkfield for Ancestry/Class/Subclass
This commit is contained in:
parent
060fe41730
commit
6336f2a60f
11 changed files with 70 additions and 113 deletions
|
|
@ -492,15 +492,29 @@ export default function DHApplicationMixin(Base) {
|
|||
* Renders an embedded document.
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static #editDoc(_event, target) {
|
||||
static async #editDoc(_event, target) {
|
||||
const doc = getDocFromElement(target);
|
||||
if (doc) return doc.sheet.render({ force: true });
|
||||
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;
|
||||
}
|
||||
|
||||
// TODO: REDO this
|
||||
const { actionId } = target.closest('[data-action-id]').dataset;
|
||||
const { actions, attack } = this.document.system;
|
||||
const action = attack?.id === actionId ? attack : actions?.find(a => a.id === actionId);
|
||||
new DHActionConfig(action).render({ force: true });
|
||||
|
||||
const config = new DHActionConfig(action);
|
||||
config.render({ force: true });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
|||
const feature = await cls.create({
|
||||
type: 'feature',
|
||||
name: cls.defaultName({ type: 'feature' }),
|
||||
[`system.itemLinks.["${this.document.uuid}"]`]: CONFIG.DH.ITEM.featureSubTypes[type]
|
||||
[`system.itemLinks.${this.document.uuid}`]: CONFIG.DH.ITEM.featureSubTypes[type]
|
||||
});
|
||||
await this.document.update({
|
||||
'system.features': [...this.document.system.features, feature].map(f => f.uuid)
|
||||
|
|
@ -192,7 +192,7 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
|||
* Remove a feature from the item.
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #deleteFeature(_, target) {
|
||||
static async #deleteFeature(event, target) {
|
||||
const feature = getDocFromElement(target);
|
||||
if (!feature) return ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.featureIsMissing'));
|
||||
await feature.update({ [`system.itemLinks.-=${this.document.uuid}`]: null });
|
||||
|
|
@ -270,13 +270,19 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
|||
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event);
|
||||
if (data.fromInternal) return;
|
||||
|
||||
const target = event.target.closest('fieldset.drop-section');
|
||||
const item = await fromUuid(data.uuid);
|
||||
if (item?.type === 'feature') {
|
||||
const { type } = target.dataset;
|
||||
const previouslyLinked = item.system.itemLinks[this.document.uuid] !== undefined;
|
||||
await item.update({ [`system.itemLinks.${this.document.uuid}`]: CONFIG.DH.ITEM.featureSubTypes[type] });
|
||||
|
||||
const current = this.document.system.features.map(x => x.uuid);
|
||||
await this.document.update({ 'system.features': [...current, item.uuid] });
|
||||
if (!previouslyLinked) {
|
||||
const current = this.document.system.features.map(x => x.uuid);
|
||||
await this.document.update({ 'system.features': [...current, item.uuid] });
|
||||
} else {
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue