RC-96 | Add Boolean inputs for the item forms

This commit is contained in:
Oliver-Akins 2025-01-12 10:39:50 -07:00
parent 5c78523791
commit fe90172656
4 changed files with 45 additions and 1 deletions

View file

@ -0,0 +1,32 @@
import { localizer } from "../../utils/Localizer.mjs";
const { randomID } = foundry.utils;
export function booleanInput(input, data) {
const label = localizer(input.label);
const id = `${data.meta.idp}-${randomID(10)}`;
if (data.meta.limited) {
return `<div data-input-type="boolean">
<span class="label">${label}</span>
<div>
<span class="value">???</span>
</div>
</div>`;
};
return `<div data-input-type="boolean">
<label for="${id}">
${label}
</label>
<div class="checkbox-container">
<input
type="checkbox"
id="${id}"
${input.value ? `checked` : ``}
name="${input.path}"
${data.meta.editable ? `` : `disabled`}
>
</div>
</div>`;
};

View file

@ -1,4 +1,5 @@
import { barInput } from "./barInput.mjs";
import { booleanInput } from "./booleanInput.mjs";
import { dropdownInput } from "./dropdownInput.mjs";
import { numberInput } from "./numberInput.mjs";
import { stringSet } from "./stringSet.mjs";
@ -10,7 +11,7 @@ const inputTypes = {
integer: numberInput,
bar: barInput,
dropdown: dropdownInput,
boolean: displayOnly,
boolean: booleanInput,
};
const typesToSanitize = new Set([ `string`, `number` ]);