Pull the foreign document updating into a utility method and add it to the GenericPopoverMixin
This commit is contained in:
parent
55cff3c048
commit
053ab05dcb
3 changed files with 42 additions and 18 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import { updateForeignDocumentFromEvent } from "../utils.mjs";
|
||||
|
||||
const { ApplicationV2 } = foundry.applications.api;
|
||||
|
||||
/**
|
||||
|
|
@ -65,6 +67,23 @@ export function GenericPopoverMixin(HandlebarsApp) {
|
|||
};
|
||||
};
|
||||
|
||||
async _onRender(...args) {
|
||||
await super._onRender(...args);
|
||||
|
||||
/*
|
||||
Foreign update listeners so that we can easily update items that may not
|
||||
be this document itself, but are useful to be able to be edited from this
|
||||
sheet. Primarily useful for editing the Actors' Item collection, or an Items'
|
||||
ActiveEffect collection.
|
||||
*/
|
||||
this.element.querySelectorAll(`input[data-foreign-update-on]`).forEach(el => {
|
||||
const events = el.dataset.foreignUpdateOn.split(`,`);
|
||||
for (const event of events) {
|
||||
el.addEventListener(event, updateForeignDocumentFromEvent);
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
async close(options = {}) {
|
||||
// prevent locked popovers from being closed
|
||||
if (this.popover.locked && !options.force) { return };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue