RC-88 | String Set Input
This commit is contained in:
parent
d0374880bc
commit
000f490584
7 changed files with 95 additions and 6 deletions
|
|
@ -1,5 +1,7 @@
|
|||
import { stringSet } from "./string-set.mjs";
|
||||
|
||||
const inputTypes = {
|
||||
set: displayOnly,
|
||||
"string-set": stringSet,
|
||||
integer: displayOnly,
|
||||
bar: displayOnly,
|
||||
dropdown: displayOnly,
|
||||
|
|
@ -10,11 +12,11 @@ function displayOnly(input) {
|
|||
return `<div data-input-type="${input.type}">${input.label}</div>`;
|
||||
};
|
||||
|
||||
export function formFields(inputs) {
|
||||
export function formFields(inputs, opts) {
|
||||
let htmlString = ``;
|
||||
for (const input of inputs) {
|
||||
if (inputTypes[input.type] == null) { continue };
|
||||
htmlString += inputTypes[input.type](input);
|
||||
htmlString += inputTypes[input.type](input, opts.data.root);
|
||||
};
|
||||
return htmlString;
|
||||
};
|
||||
|
|
|
|||
25
module/handlebarHelpers/inputs/string-set.mjs
Normal file
25
module/handlebarHelpers/inputs/string-set.mjs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { localizer } from "../../utils/Localizer.mjs";
|
||||
|
||||
export function stringSet(input, data) {
|
||||
const label = localizer(input.label);
|
||||
|
||||
if (!data.meta.editable) {
|
||||
return `<div data-input-type="string-set">
|
||||
<span class="label">${label}</span>
|
||||
<span>${input.value}</span>
|
||||
</div>`;
|
||||
};
|
||||
|
||||
return `<div data-input-type="string-set">
|
||||
<label
|
||||
for="${data.meta.idp}-traits"
|
||||
>
|
||||
${label}
|
||||
</label>
|
||||
<string-tags
|
||||
id="${data.meta.idp}-traits"
|
||||
value="${input.value}"
|
||||
name="${input.path}"
|
||||
/>
|
||||
</div>`;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue