mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-18 07:59:03 +01:00
Improved the config app for Downtime activities. You can now create/edit/remove actions on them
This commit is contained in:
parent
42a705a870
commit
c3d71f0c39
18 changed files with 275 additions and 196 deletions
|
|
@ -2,10 +2,11 @@ import DaggerheartSheet from '../sheets/daggerheart-sheet.mjs';
|
|||
|
||||
const { ApplicationV2 } = foundry.applications.api;
|
||||
export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
|
||||
constructor(action) {
|
||||
constructor(action, sheetUpdate) {
|
||||
super({});
|
||||
|
||||
this.action = action;
|
||||
this.sheetUpdate = sheetUpdate;
|
||||
this.openSection = null;
|
||||
}
|
||||
|
||||
|
|
@ -183,14 +184,34 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
|
|||
if (!newActions.findSplice(x => x._id === data._id, data)) newActions.push(data);
|
||||
} else newActions = data;
|
||||
|
||||
const updates = await this.action.parent.parent.update({ [`system.${this.action.systemPath}`]: newActions });
|
||||
if (!updates) return;
|
||||
this.action = Array.isArray(container)
|
||||
? foundry.utils.getProperty(updates.system, this.action.systemPath)[this.action.index]
|
||||
: foundry.utils.getProperty(updates.system, this.action.systemPath);
|
||||
const action = await this.updateParent(newActions, container);
|
||||
if (!action) return;
|
||||
|
||||
this.action = action;
|
||||
|
||||
this.sheetUpdate?.(this.action);
|
||||
this.render();
|
||||
}
|
||||
|
||||
async updateParent(newActions, container) {
|
||||
const isSystemPath = this.action.parent.parent?.update;
|
||||
if (isSystemPath) {
|
||||
const updates = await this.action.parent.parent.update({
|
||||
[`system.${this.action.systemPath}`]: newActions
|
||||
});
|
||||
if (!updates) return null;
|
||||
|
||||
return Array.isArray(container)
|
||||
? foundry.utils.getProperty(updates.system, this.action.systemPath)[this.action.index]
|
||||
: foundry.utils.getProperty(updates.system, this.action.systemPath);
|
||||
} else {
|
||||
await this.action.parent.updateSource({ [this.action.systemPath]: newActions });
|
||||
|
||||
const updates = foundry.utils.getProperty(this.action.parent, this.action.systemPath);
|
||||
return Array.isArray(container) ? updates[this.action.index] : updates;
|
||||
}
|
||||
}
|
||||
|
||||
static addElement(event) {
|
||||
const data = this.action.toObject(),
|
||||
key = event.target.closest('[data-key]').dataset.key;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue