Update the popover management to work with origin rerenders, and rerendering the popovers directly.

This commit is contained in:
Oliver-Akins 2025-03-15 18:35:24 -06:00
parent 69bf712eca
commit 96e4d09e7b
4 changed files with 93 additions and 29 deletions

View file

@ -3,7 +3,10 @@ const { ApplicationV2 } = foundry.applications.api;
/**
* This mixin provides the ability to designate an Application as a "popover",
* which means that it will spawn near the x/y coordinates provided it won't
* overflow the bounds of the screen.
* overflow the bounds of the screen. This also implements a _preparePartContext
* in order to allow the parent application passing new data into the popover
* whenever it rerenders; how the popover handles this data is up to the
* specific implementation.
*/
export function GenericPopoverMixin(HandlebarsApp) {
class GenericRipCryptPopover extends HandlebarsApp {
@ -29,7 +32,6 @@ export function GenericPopoverMixin(HandlebarsApp) {
popover.framed ??= true;
popover.locked ??= false;
if (popover.framed) {
options.window ??= {};
options.window.frame = true;
@ -151,6 +153,17 @@ export function GenericPopoverMixin(HandlebarsApp) {
scale,
};
};
/**
* This is here in order allow things that are not this Application
* to provide / augment the context data for the lifecycle of the app.
*/
async _prepareContext(_partId, _context, options) {
const context = {};
Hooks.callAll(`prepare${this.constructor.name}Context`, context, options);
Hooks.callAll(`prepare${this.popover.managerId}Context`, context, options);
return context;
};
};
return GenericRipCryptPopover;
};