refac
This commit is contained in:
1 parent
b35e2d265a
commit
239cb74007
1 file changed
+19
-9
@@ -20,6 +20,10 @@
|
|||||||
|
|
||||||
let loading = true;
|
let loading = true;
|
||||||
let variableValues = {};
|
let variableValues = {};
|
||||||
|
let variablesKey = '';
|
||||||
|
|
||||||
|
const getVariableLabel = (variable) => variables[variable]?.label ?? variable;
|
||||||
|
const getVariablesKey = (value) => JSON.stringify(value ?? {});
|
||||||
|
|
||||||
const submitHandler = async () => {
|
const submitHandler = async () => {
|
||||||
// Normalize Windows CRLF (\r\n) to LF (\n) for all string values
|
// Normalize Windows CRLF (\r\n) to LF (\n) for all string values
|
||||||
@@ -60,8 +64,16 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$: if (!show) {
|
||||||
|
variablesKey = '';
|
||||||
|
}
|
||||||
|
|
||||||
$: if (show) {
|
$: if (show) {
|
||||||
init();
|
const key = getVariablesKey(variables);
|
||||||
|
if (key !== variablesKey) {
|
||||||
|
variablesKey = key;
|
||||||
|
init();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -98,10 +110,10 @@
|
|||||||
<div class=" py-0.5 w-full justify-between">
|
<div class=" py-0.5 w-full justify-between">
|
||||||
<div class="flex w-full justify-between mb-1.5">
|
<div class="flex w-full justify-between mb-1.5">
|
||||||
<div class=" self-center text-xs font-normal">
|
<div class=" self-center text-xs font-normal">
|
||||||
{variable}
|
{getVariableLabel(variable)}
|
||||||
|
|
||||||
{#if variables[variable]?.required ?? false}
|
{#if variables[variable]?.required ?? false}
|
||||||
<span class=" text-gray-500">*{$i18n.t('required')}</span>
|
<span class="ml-1 text-gray-500">* {$i18n.t('required')}</span>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -114,13 +126,11 @@
|
|||||||
bind:value={variableValues[variable]}
|
bind:value={variableValues[variable]}
|
||||||
id="input-variable-{idx}"
|
id="input-variable-{idx}"
|
||||||
>
|
>
|
||||||
{#if variables[variable]?.placeholder}
|
<option value="" disabled>
|
||||||
<option value="" disabled selected>
|
{variables[variable]?.placeholder ?? $i18n.t('Select an option')}
|
||||||
{variables[variable].placeholder}
|
</option>
|
||||||
</option>
|
|
||||||
{/if}
|
|
||||||
{#each variables[variable]?.options ?? [] as option}
|
{#each variables[variable]?.options ?? [] as option}
|
||||||
<option value={option} selected={option === variableValues[variable]}>
|
<option value={option}>
|
||||||
{option}
|
{option}
|
||||||
</option>
|
</option>
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
Reference in new issue
Block a user