mirror of
https://github.com/faiztyanirh/clqms-shadcn-v1.git
synced 2026-04-27 03:16:33 +07:00
add feature level validation dict test cal
This commit is contained in:
parent
c5d2aa6711
commit
0d49cc57eb
@ -23,7 +23,7 @@ const optionsMode = {
|
|||||||
if (field.key === 'FormulaInput') {
|
if (field.key === 'FormulaInput') {
|
||||||
return {
|
return {
|
||||||
...baseOption,
|
...baseOption,
|
||||||
level: item.SeqRpt,
|
level: item.CountStat,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -9,6 +9,7 @@
|
|||||||
import DictionaryFormRenderer from '$lib/components/reusable/form/dictionary-form-renderer.svelte';
|
import DictionaryFormRenderer from '$lib/components/reusable/form/dictionary-form-renderer.svelte';
|
||||||
|
|
||||||
let props = $props();
|
let props = $props();
|
||||||
|
|
||||||
// const formState = props.calFormState;
|
// const formState = props.calFormState;
|
||||||
|
|
||||||
// let options = $state([]);
|
// let options = $state([]);
|
||||||
|
|||||||
@ -85,9 +85,9 @@
|
|||||||
const selected = formState.form.FormulaInput;
|
const selected = formState.form.FormulaInput;
|
||||||
if (!Array.isArray(selected)) return [];
|
if (!Array.isArray(selected)) return [];
|
||||||
|
|
||||||
return selected.map((v) => ({
|
return selected.map((item) => ({
|
||||||
value: v,
|
value: item.value,
|
||||||
done: new RegExp(`\\b${v}\\b`, 'i').test(formulaCode)
|
done: new RegExp(`\\b${item.value}\\b`, 'i').test(formulaCode)
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,13 +347,17 @@
|
|||||||
</Select.Root>
|
</Select.Root>
|
||||||
{:else if type === 'selectmultiple'}
|
{:else if type === 'selectmultiple'}
|
||||||
{@const filteredOptions = getFilteredOptions(key)}
|
{@const filteredOptions = getFilteredOptions(key)}
|
||||||
|
{@const currentValues = Array.isArray(formState.form[key]) ? formState.form[key] : []}
|
||||||
<Select.Root
|
<Select.Root
|
||||||
type="multiple"
|
type="multiple"
|
||||||
bind:value={formState.form[key]}
|
value={currentValues.map((item) => item.value)}
|
||||||
onValueChange={(val) => {
|
onValueChange={(val) => {
|
||||||
formState.form[key] = val;
|
const selectedObjects = (formState.selectOptions?.[key] ?? []).filter((opt) =>
|
||||||
|
val.includes(opt.value)
|
||||||
|
);
|
||||||
|
formState.form[key] = selectedObjects;
|
||||||
if (validateOn?.includes('input')) {
|
if (validateOn?.includes('input')) {
|
||||||
formState.validateField?.(key, val, false);
|
formState.validateField?.(key, selectedObjects, false);
|
||||||
formState.validateField?.('FormulaCode', expression, false);
|
formState.validateField?.('FormulaCode', expression, false);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
@ -367,9 +371,9 @@
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Select.Trigger class="w-full">
|
<Select.Trigger class="w-full">
|
||||||
{formState.form[key]?.length
|
{currentValues.length
|
||||||
? (formState.selectOptions?.[key] ?? [])
|
? (formState.selectOptions?.[key] ?? [])
|
||||||
.filter((o) => formState.form[key].includes(o.value))
|
.filter((o) => currentValues.some((f) => f.value === o.value))
|
||||||
.map((o) => o.label)
|
.map((o) => o.label)
|
||||||
.join(', ')
|
.join(', ')
|
||||||
: 'Choose'}
|
: 'Choose'}
|
||||||
@ -387,7 +391,7 @@
|
|||||||
{#if formState.loadingOptions?.[key]}
|
{#if formState.loadingOptions?.[key]}
|
||||||
<div class="p-2 text-sm text-muted-foreground">Loading...</div>
|
<div class="p-2 text-sm text-muted-foreground">Loading...</div>
|
||||||
{:else}
|
{:else}
|
||||||
{#if formState.form[key].length > 0}
|
{#if currentValues.length > 0}
|
||||||
<Select.Separator />
|
<Select.Separator />
|
||||||
<button
|
<button
|
||||||
class="w-full px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground"
|
class="w-full px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground"
|
||||||
@ -581,9 +585,9 @@
|
|||||||
type="button"
|
type="button"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
class="h-auto w-auto p-2"
|
class="h-auto w-auto p-2"
|
||||||
onclick={() => addValue(item)}
|
onclick={() => addValue(item.value)}
|
||||||
>
|
>
|
||||||
{item}
|
{item.value}
|
||||||
</Button>
|
</Button>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user