mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-10 19:17:09 +01:00
1613-Rolltable-delete-formula-buttons
This commit is contained in:
parent
2c36da8433
commit
4c51bb5899
1 changed files with 5 additions and 3 deletions
|
|
@ -108,14 +108,16 @@ export default class DhRollTableSheet extends foundry.applications.sheets.RollTa
|
||||||
getSystemFlagUpdate() {
|
getSystemFlagUpdate() {
|
||||||
const deleteUpdate = Object.keys(this.document._source.flags.daggerheart?.altFormula ?? {}).reduce(
|
const deleteUpdate = Object.keys(this.document._source.flags.daggerheart?.altFormula ?? {}).reduce(
|
||||||
(acc, formulaKey) => {
|
(acc, formulaKey) => {
|
||||||
if (!this.daggerheartFlag.altFormula[formulaKey]) acc.altFormula[`-=${formulaKey}`] = null;
|
if (!this.daggerheartFlag.altFormula[formulaKey])
|
||||||
|
acc.altFormula[formulaKey] = foundry.data.operators.ForcedDeletion.create();
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
},
|
},
|
||||||
{ altFormula: {} }
|
{ altFormula: {} }
|
||||||
);
|
);
|
||||||
|
|
||||||
return { ['flags.daggerheart']: foundry.utils.mergeObject(this.daggerheartFlag.toObject(), deleteUpdate) };
|
const flagData = this.daggerheartFlag.toObject();
|
||||||
|
return { ...flagData, altFormula: { ...flagData.altFormula, ...deleteUpdate.altFormula } };
|
||||||
}
|
}
|
||||||
|
|
||||||
static async #addFormula() {
|
static async #addFormula() {
|
||||||
|
|
@ -127,7 +129,7 @@ export default class DhRollTableSheet extends foundry.applications.sheets.RollTa
|
||||||
|
|
||||||
static async #removeFormula(_event, target) {
|
static async #removeFormula(_event, target) {
|
||||||
await this.daggerheartFlag.updateSource({
|
await this.daggerheartFlag.updateSource({
|
||||||
[`altFormula.-=${target.dataset.key}`]: null
|
[`altFormula.${target.dataset.key}`]: foundry.data.operators.ForcedDeletion.create()
|
||||||
});
|
});
|
||||||
this.render({ internalRefresh: true });
|
this.render({ internalRefresh: true });
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue