mirror of
https://github.com/faiztyanirh/clqms-shadcn-v1.git
synced 2026-04-26 19:06:33 +07:00
add feature dynamic error multitab & continue dict test calc
This commit is contained in:
parent
d3099248b2
commit
c5d2aa6711
@ -1,10 +1,24 @@
|
|||||||
export function useDictionaryForm(formState) {
|
// export function useDictionaryForm(formState) {
|
||||||
let uploadErrors = $state({});
|
// let uploadErrors = $state({});
|
||||||
let isChecking = $state({});
|
// let isChecking = $state({});
|
||||||
|
|
||||||
let hasErrors = $derived(
|
// let hasErrors = $derived(
|
||||||
Object.values(formState.errors).some(value => value !== null)
|
// Object.values(formState.errors).some(value => value !== null)
|
||||||
);
|
// );
|
||||||
|
|
||||||
|
// return {
|
||||||
|
// get hasErrors() { return hasErrors },
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
export function useDictionaryForm(formState, getActiveFormStates) {
|
||||||
|
let hasErrors = $derived.by(() => {
|
||||||
|
const mainHasError = Object.values(formState.errors).some(v => v !== null);
|
||||||
|
const activeHasError = getActiveFormStates().some(fs =>
|
||||||
|
Object.values(fs.errors).some(v => v !== null)
|
||||||
|
);
|
||||||
|
return mainHasError || activeHasError;
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
get hasErrors() { return hasErrors },
|
get hasErrors() { return hasErrors },
|
||||||
|
|||||||
@ -44,6 +44,7 @@ export const testCalSchema = z.object({
|
|||||||
ctx.addIssue({
|
ctx.addIssue({
|
||||||
code: z.ZodIssueCode.custom,
|
code: z.ZodIssueCode.custom,
|
||||||
message: `Formula must contain all selected input parameters:${data.FormulaInput.join(',')}`,
|
message: `Formula must contain all selected input parameters:${data.FormulaInput.join(',')}`,
|
||||||
|
// message: `Formula must contain all selected input parameters:`,
|
||||||
path: ['FormulaCode']
|
path: ['FormulaCode']
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,7 +55,24 @@
|
|||||||
modeOpt: 'cascade'
|
modeOpt: 'cascade'
|
||||||
})
|
})
|
||||||
|
|
||||||
const helpers = useDictionaryForm(formState);
|
const activeFormStates = $derived.by(() => {
|
||||||
|
switch (formState.form.TestType) {
|
||||||
|
case "TEST":
|
||||||
|
case "PARAM":
|
||||||
|
return [refNumState, refTxtState, mapFormState];
|
||||||
|
case "CALC":
|
||||||
|
return [calFormState, refNumState, refTxtState, mapFormState];
|
||||||
|
case "GROUP":
|
||||||
|
return [];
|
||||||
|
case "TITLE":
|
||||||
|
return [];
|
||||||
|
default:
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// const helpers = useDictionaryForm(formState);
|
||||||
|
const helpers = useDictionaryForm(formState, () => activeFormStates);
|
||||||
|
|
||||||
const handlers = {
|
const handlers = {
|
||||||
clearForm: () => {
|
clearForm: () => {
|
||||||
@ -269,18 +286,6 @@
|
|||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
const activeFormState = $derived.by(() => {
|
|
||||||
switch (formState.form.TestType) {
|
|
||||||
case "TEST":
|
|
||||||
return formState;
|
|
||||||
case "PARAM":
|
|
||||||
return formState;
|
|
||||||
case "CALC":
|
|
||||||
return calFormState;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// $inspect(activeFormState.errors)
|
// $inspect(activeFormState.errors)
|
||||||
let activeTab = $state('definition');
|
let activeTab = $state('definition');
|
||||||
|
|
||||||
@ -391,6 +396,11 @@
|
|||||||
refTxtState.form.TxtRefType = value;
|
refTxtState.form.TxtRefType = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// $inspect({
|
||||||
|
// definition: formState.errors,
|
||||||
|
// active: activeFormStates.map(fs => fs.errors)
|
||||||
|
// });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<FormPageContainer title="Create Test" {primaryAction} {secondaryActions} {actions}>
|
<FormPageContainer title="Create Test" {primaryAction} {secondaryActions} {actions}>
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user