RC-96 | Add Boolean inputs for the item forms
This commit is contained in:
parent
5c78523791
commit
fe90172656
4 changed files with 45 additions and 1 deletions
32
module/handlebarHelpers/inputs/booleanInput.mjs
Normal file
32
module/handlebarHelpers/inputs/booleanInput.mjs
Normal 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>`;
|
||||||
|
};
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { barInput } from "./barInput.mjs";
|
import { barInput } from "./barInput.mjs";
|
||||||
|
import { booleanInput } from "./booleanInput.mjs";
|
||||||
import { dropdownInput } from "./dropdownInput.mjs";
|
import { dropdownInput } from "./dropdownInput.mjs";
|
||||||
import { numberInput } from "./numberInput.mjs";
|
import { numberInput } from "./numberInput.mjs";
|
||||||
import { stringSet } from "./stringSet.mjs";
|
import { stringSet } from "./stringSet.mjs";
|
||||||
|
|
@ -10,7 +11,7 @@ const inputTypes = {
|
||||||
integer: numberInput,
|
integer: numberInput,
|
||||||
bar: barInput,
|
bar: barInput,
|
||||||
dropdown: dropdownInput,
|
dropdown: dropdownInput,
|
||||||
boolean: displayOnly,
|
boolean: booleanInput,
|
||||||
};
|
};
|
||||||
|
|
||||||
const typesToSanitize = new Set([ `string`, `number` ]);
|
const typesToSanitize = new Set([ `string`, `number` ]);
|
||||||
|
|
|
||||||
|
|
@ -61,4 +61,9 @@
|
||||||
[data-tag-count="0"] {
|
[data-tag-count="0"] {
|
||||||
justify-content: start;
|
justify-content: start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[data-input-type="boolean"] > .checkbox-container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: right;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,12 @@
|
||||||
border-bottom: var(--input-underline);
|
border-bottom: var(--input-underline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&[type="checkbox"] {
|
||||||
|
all: revert-layer;
|
||||||
|
--checkbox-checked-color: var(--accent-3);
|
||||||
|
--checkbox-background-color: var(--accent-2);
|
||||||
|
}
|
||||||
|
|
||||||
&::placeholder {
|
&::placeholder {
|
||||||
color: var(--input-placeholder-text);
|
color: var(--input-placeholder-text);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue