fix: importer foundry.applications.api et utiliser _onRender dans les pickers AppV2
- applications.mjs: import HandlebarsApplicationMixin/ApplicationV2 from foundry.applications.api (they are not globals in Foundry v14), fixing 'ReferenceError: HandlebarsApplicationMixin is not defined' - Replace activateListeners(html) with _onRender(context, options) and this.element — AppV2 does not call activateListeners - TraitSelector: remove recursive render(true) in _validateTraits - fight.mjs: VermineCombatTracker same _onRender conversion
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api
|
||||||
|
|
||||||
export class TotemPicker extends HandlebarsApplicationMixin(ApplicationV2) {
|
export class TotemPicker extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||||
|
|
||||||
constructor(linkEl, actor) {
|
constructor(linkEl, actor) {
|
||||||
@@ -24,9 +26,9 @@ export class TotemPicker extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||||||
return { config: CONFIG.VERMINE };
|
return { config: CONFIG.VERMINE };
|
||||||
}
|
}
|
||||||
|
|
||||||
activateListeners(html) {
|
_onRender(context, options) {
|
||||||
super.activateListeners(html);
|
super._onRender(context, options);
|
||||||
html.querySelectorAll('.totem').forEach(el => {
|
this.element.querySelectorAll('.totem').forEach(el => {
|
||||||
el.addEventListener('click', event => {
|
el.addEventListener('click', event => {
|
||||||
const link = event.target.closest('a');
|
const link = event.target.closest('a');
|
||||||
if (!link?.dataset.totem) return;
|
if (!link?.dataset.totem) return;
|
||||||
@@ -80,9 +82,9 @@ export class ActorPicker extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
activateListeners(html) {
|
_onRender(context, options) {
|
||||||
super.activateListeners(html);
|
super._onRender(context, options);
|
||||||
html.querySelectorAll('.actor').forEach(el => {
|
this.element.querySelectorAll('.actor').forEach(el => {
|
||||||
el.addEventListener('click', async event => {
|
el.addEventListener('click', async event => {
|
||||||
const div = event.target.closest('div');
|
const div = event.target.closest('div');
|
||||||
const actorId = div?.dataset.actorId;
|
const actorId = div?.dataset.actorId;
|
||||||
@@ -148,15 +150,15 @@ export class TraitSelector extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
activateListeners(html) {
|
_onRender(context, options) {
|
||||||
super.activateListeners(html);
|
super._onRender(context, options);
|
||||||
this._validateTraits(html);
|
this._validateTraits(this.element);
|
||||||
html.querySelectorAll('input').forEach(el => {
|
this.element.querySelectorAll('input').forEach(el => {
|
||||||
el.addEventListener('change', ev => this._onChangeInput(ev));
|
el.addEventListener('change', ev => this._onChangeInput(ev));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async _validateTraits(html) {
|
_validateTraits(html) {
|
||||||
const checks = html.querySelectorAll("input.trait-selector");
|
const checks = html.querySelectorAll("input.trait-selector");
|
||||||
for (const inp of checks) {
|
for (const inp of checks) {
|
||||||
if (this.targetItem.system.traits[inp.dataset.trait]) {
|
if (this.targetItem.system.traits[inp.dataset.trait]) {
|
||||||
@@ -165,7 +167,6 @@ export class TraitSelector extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await this.render(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onChangeInput(ev) {
|
async _onChangeInput(ev) {
|
||||||
|
|||||||
@@ -239,9 +239,9 @@ export class VermineCombatTracker extends foundry.applications.sidebar.tabs.Comb
|
|||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
activateListeners(html) {
|
_onRender(context, options) {
|
||||||
super.activateListeners(html);
|
super._onRender(context, options);
|
||||||
html.querySelectorAll("[data-attitude]").forEach(el => {
|
this.element.querySelectorAll("[data-attitude]").forEach(el => {
|
||||||
el.addEventListener("click", this._setStatut.bind(this));
|
el.addEventListener("click", this._setStatut.bind(this));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user