Use ActiveEffect Config for settings as well (#1741)

This commit is contained in:
Carlos Fernandez 2026-03-20 19:46:30 -04:00 committed by GitHub
parent 15fc879f9b
commit b3e9c3fd9f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 28 additions and 226 deletions

View file

@ -247,4 +247,30 @@ export default class DhActiveEffectConfig extends foundry.applications.sheets.Ac
return submitData;
}
/** @inheritDoc */
_processSubmitData(event, form, submitData, options) {
if (this.options.isSetting) {
// Settings should update source instead
this.document.updateSource(submitData);
this.render();
} else {
return super._processSubmitData(event, form, submitData, options);
}
}
/** Creates an active effect config for a setting */
static async configureSetting(effect, options = {}) {
const document = new CONFIG.ActiveEffect.documentClass({ ...foundry.utils.duplicate(effect), _id: effect.id });
return new Promise(resolve => {
const app = new this({ document, ...options, isSetting: true });
app.addEventListener('close', () => {
const newEffect = app.document.toObject(true);
newEffect.id = newEffect._id;
delete newEffect._id;
resolve(newEffect);
}, { once: true });
app.render({ force: true });
});
}
}