fix: address a few problems with active effect application

This commit is contained in:
Johannes Loher 2022-11-04 04:49:18 +01:00
parent 1abaf6203c
commit ab31450dd8
8 changed files with 62 additions and 23 deletions

View file

@ -4,15 +4,17 @@
import { getGame } from "../helpers";
export function disableOverriddenFields<
Options extends FormApplicationOptions,
Data extends object,
ConcreteObject extends { overrides: Record<string, unknown> },
>(this: FormApplication<Options, Data, ConcreteObject>): void {
export function disableOverriddenFields(
form: HTMLElement | null,
overrides: Record<string, unknown>,
selector: (key: string) => string,
): void {
const inputs = ["INPUT", "SELECT", "TEXTAREA", "BUTTON"];
const titleAddition = `(${getGame().i18n.localize("DS4.TooltipDisabledDueToEffects")})`;
for (const key of Object.keys(foundry.utils.flattenObject(this.object.overrides))) {
const elements = this.form?.querySelectorAll(`[name="${key}"]`);
const titleAddition = `(${getGame().i18n.localize("DS4.TooltipNotEditableDueToEffects")})`;
for (const key of Object.keys(foundry.utils.flattenObject(overrides))) {
const sel = selector(key);
const elements = form?.querySelectorAll(sel);
elements?.forEach((element) => {
if (inputs.includes(element.tagName)) {
element.setAttribute("disabled", "");