Fix: GMPlayerPrivacySelectorMenu must extend ApplicationV2
Modified GMPlayerPrivacySelectorMenu to extend ApplicationV2 (or fallback class) to be compatible with FoundryVTT's registerMenu API. FoundryVTT requires that menu types passed to registerMenu() must be a FormApplication or ApplicationV2 instance or subclass. Changes: - Added conditional _AppBase class (ApplicationV2 or fallback for tests) - Extended GMPlayerPrivacySelectorMenu from _AppBase - Added DEFAULT_OPTIONS static property for ApplicationV2 compatibility - Added super(options) call in constructor This fixes: Error: You must provide a menu type that is a FormApplication or ApplicationV2 instance or subclass Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -3,10 +3,30 @@
|
|||||||
*
|
*
|
||||||
* A settings menu entry that allows the GM to select a player and view their privacy settings.
|
* A settings menu entry that allows the GM to select a player and view their privacy settings.
|
||||||
* This provides read-only access to all players' privacy panels.
|
* This provides read-only access to all players' privacy panels.
|
||||||
|
*
|
||||||
|
* Extends ApplicationV2 to be compatible with FoundryVTT's registerMenu API.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { PlayerPrivacyPanel } from '../player/PlayerPrivacyPanel.js';
|
import { PlayerPrivacyPanel } from '../player/PlayerPrivacyPanel.js';
|
||||||
|
|
||||||
|
// Conditional base class for test compatibility
|
||||||
|
// At module load time in tests, foundry is undefined → fallback class is used
|
||||||
|
const _AppBase =
|
||||||
|
typeof foundry !== 'undefined' &&
|
||||||
|
foundry.applications?.api?.ApplicationV2
|
||||||
|
? foundry.applications.api.ApplicationV2
|
||||||
|
: class _FallbackApp {
|
||||||
|
static DEFAULT_OPTIONS = {};
|
||||||
|
get rendered() { return this._rendered ?? false; }
|
||||||
|
set rendered(v) { this._rendered = v; }
|
||||||
|
get element() { return this._element ?? null; }
|
||||||
|
set element(v) { this._element = v; }
|
||||||
|
async render() { this._rendered = true; }
|
||||||
|
async close() { this._rendered = false; }
|
||||||
|
_onRender() {}
|
||||||
|
_onClose() {}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Static references to DI dependencies (set during module initialization).
|
* Static references to DI dependencies (set during module initialization).
|
||||||
*/
|
*/
|
||||||
@@ -68,12 +88,26 @@ function _registerSettingsMenu() {
|
|||||||
/**
|
/**
|
||||||
* GM Player Privacy Selector Menu class.
|
* GM Player Privacy Selector Menu class.
|
||||||
* When instantiated by Foundry, it creates a user selector dialog.
|
* When instantiated by Foundry, it creates a user selector dialog.
|
||||||
|
* Extends ApplicationV2 (or fallback) for Foundry settings menu compatibility.
|
||||||
*/
|
*/
|
||||||
export class GMPlayerPrivacySelectorMenu {
|
export class GMPlayerPrivacySelectorMenu extends _AppBase {
|
||||||
|
static DEFAULT_OPTIONS = {
|
||||||
|
id: 'scrying-pool-gm-privacy-selector',
|
||||||
|
classes: ['scrying-pool', 'gm-privacy-selector'],
|
||||||
|
window: {
|
||||||
|
title: 'Player Privacy Selector',
|
||||||
|
resizable: false,
|
||||||
|
width: 400,
|
||||||
|
height: 'auto',
|
||||||
|
},
|
||||||
|
position: {},
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {object} [options] - Foundry options (unused, but required by settings menu API)
|
* @param {object} [options] - Foundry options (unused, but required by settings menu API)
|
||||||
*/
|
*/
|
||||||
constructor(options = {}) {
|
constructor(options = {}) {
|
||||||
|
super(options);
|
||||||
this._adapter = _adapter;
|
this._adapter = _adapter;
|
||||||
this._playerPrivacyManager = _playerPrivacyManager;
|
this._playerPrivacyManager = _playerPrivacyManager;
|
||||||
this._options = options;
|
this._options = options;
|
||||||
|
|||||||
Reference in New Issue
Block a user