Fixed downtime config again

This commit is contained in:
WBHarry 2025-07-25 18:22:56 +02:00
parent 20dbd3804c
commit b8786d981e
8 changed files with 105 additions and 45 deletions

View file

@ -202,11 +202,21 @@ export function ActionMixin(Base) {
}
async update(updates, options = {}) {
const path = this.inCollection ? `system.${this.systemPath}.${this.id}` : `system.${this.systemPath}`,
const isSetting = !this.parent.parent;
const basePath = isSetting ? this.systemPath : `system.${this.systemPath}`;
const path = this.inCollection ? `${basePath}.${this.id}` : basePath;
let result = null;
if (isSetting) {
await this.parent.updateSource({ [path]: updates }, options);
result = this.parent;
} else {
result = await this.item.update({ [path]: updates }, options);
}
return this.inCollection
? foundry.utils.getProperty(result, `system.${this.systemPath}`).get(this.id)
: foundry.utils.getProperty(result, `system.${this.systemPath}`);
? foundry.utils.getProperty(result, basePath).get(this.id)
: foundry.utils.getProperty(result, basePath);
}
delete() {

View file

@ -1,5 +1,5 @@
import { defaultRestOptions } from '../../config/generalConfig.mjs';
import ActionField from '../fields/actionField.mjs';
import { ActionsField } from '../fields/actionField.mjs';
export default class DhHomebrew extends foundry.abstract.DataModel {
static LOCALIZATION_PREFIXES = ['DAGGERHEART.SETTINGS.Homebrew']; // Doesn't work for some reason
@ -62,7 +62,7 @@ export default class DhHomebrew extends foundry.abstract.DataModel {
base64: false
}),
description: new fields.HTMLField(),
actions: new fields.ArrayField(new ActionField())
actions: new ActionsField()
}),
{ initial: defaultRestOptions.longRest() }
)
@ -79,7 +79,7 @@ export default class DhHomebrew extends foundry.abstract.DataModel {
base64: false
}),
description: new fields.HTMLField(),
actions: new fields.ArrayField(new ActionField())
actions: new ActionsField()
}),
{ initial: defaultRestOptions.shortRest() }
)