mirror of
https://github.com/faiztyanirh/clqms-shadcn-v1.git
synced 2026-04-27 11:25:53 +07:00
add auto for testname & add tabindex in testmap form
This commit is contained in:
parent
13d9e0e7cc
commit
905ce97f5e
@ -18,6 +18,7 @@ const optionsMode = {
|
|||||||
const baseOption = {
|
const baseOption = {
|
||||||
value: item[valueKey],
|
value: item[valueKey],
|
||||||
label: typeof labelKey === 'function' ? labelKey(item) : item[labelKey],
|
label: typeof labelKey === 'function' ? labelKey(item) : item[labelKey],
|
||||||
|
rawItem: item
|
||||||
};
|
};
|
||||||
|
|
||||||
if (field.key === 'FormulaInput') {
|
if (field.key === 'FormulaInput') {
|
||||||
|
|||||||
@ -55,14 +55,16 @@ export const testMapFormFields = [
|
|||||||
label: 'Host Type',
|
label: 'Host Type',
|
||||||
required: false,
|
required: false,
|
||||||
type: 'select',
|
type: 'select',
|
||||||
optionsEndpoint: `${API.BASE_URL}${API.VALUESET}/entity_type`
|
optionsEndpoint: `${API.BASE_URL}${API.VALUESET}/entity_type`,
|
||||||
|
tabIndex: 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'ClientType',
|
key: 'ClientType',
|
||||||
label: 'Client Type',
|
label: 'Client Type',
|
||||||
required: false,
|
required: false,
|
||||||
type: 'select',
|
type: 'select',
|
||||||
optionsEndpoint: `${API.BASE_URL}${API.VALUESET}/entity_type`
|
optionsEndpoint: `${API.BASE_URL}${API.VALUESET}/entity_type`,
|
||||||
|
tabIndex: 5,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -74,14 +76,16 @@ export const testMapFormFields = [
|
|||||||
label: 'Host ID',
|
label: 'Host ID',
|
||||||
required: false,
|
required: false,
|
||||||
type: 'text',
|
type: 'text',
|
||||||
validateOn: ['input']
|
validateOn: ['input'],
|
||||||
|
tabIndex: 2,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'ClientID',
|
key: 'ClientID',
|
||||||
label: 'Client ID',
|
label: 'Client ID',
|
||||||
required: false,
|
required: false,
|
||||||
type: 'text',
|
type: 'text',
|
||||||
validateOn: ['input']
|
validateOn: ['input'],
|
||||||
|
tabIndex: 6,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -92,13 +96,15 @@ export const testMapFormFields = [
|
|||||||
key: 'HostTestCode',
|
key: 'HostTestCode',
|
||||||
label: 'Host Test Code',
|
label: 'Host Test Code',
|
||||||
required: false,
|
required: false,
|
||||||
type: 'text'
|
type: 'text',
|
||||||
|
tabIndex: 3,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'ClientTestCode',
|
key: 'ClientTestCode',
|
||||||
label: 'Client Test Code',
|
label: 'Client Test Code',
|
||||||
required: false,
|
required: false,
|
||||||
type: 'text'
|
type: 'text',
|
||||||
|
tabIndex: 7,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -109,13 +115,15 @@ export const testMapFormFields = [
|
|||||||
key: 'HostTestName',
|
key: 'HostTestName',
|
||||||
label: 'Host Test Name',
|
label: 'Host Test Name',
|
||||||
required: false,
|
required: false,
|
||||||
type: 'text'
|
type: 'text',
|
||||||
|
tabIndex: 4,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'ClientTestName',
|
key: 'ClientTestName',
|
||||||
label: 'Client Test Name',
|
label: 'Client Test Name',
|
||||||
required: false,
|
required: false,
|
||||||
type: 'text'
|
type: 'text',
|
||||||
|
tabIndex: 8,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -130,7 +138,8 @@ export const testMapFormFields = [
|
|||||||
optionsEndpoint: `${API.BASE_URL}${API.CONTAINER}`,
|
optionsEndpoint: `${API.BASE_URL}${API.CONTAINER}`,
|
||||||
valueKey: 'ConDefID',
|
valueKey: 'ConDefID',
|
||||||
labelKey: (item) => `${item.ConCode} - ${item.ConName}`,
|
labelKey: (item) => `${item.ConCode} - ${item.ConName}`,
|
||||||
fullWidth: false
|
fullWidth: false,
|
||||||
|
tabIndex: 9,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -164,7 +164,7 @@
|
|||||||
return { ...col, type: 'text', optionsEndpoint: undefined };
|
return { ...col, type: 'text', optionsEndpoint: undefined };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (col.key === 'HostTestCode' || col.key === 'HostTestName') {
|
if (col.key === 'HostTestCode') {
|
||||||
if (formState.form.HostType === 'SITE' && formState.form.HostID) {
|
if (formState.form.HostType === 'SITE' && formState.form.HostID) {
|
||||||
return {
|
return {
|
||||||
...col,
|
...col,
|
||||||
@ -182,7 +182,7 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (col.key === 'ClientTestCode' || col.key === 'ClientTestName') {
|
if (col.key === 'ClientTestCode') {
|
||||||
if (formState.form.ClientType === 'SITE' && formState.form.ClientID) {
|
if (formState.form.ClientType === 'SITE' && formState.form.ClientID) {
|
||||||
return {
|
return {
|
||||||
...col,
|
...col,
|
||||||
@ -207,6 +207,12 @@
|
|||||||
}))
|
}))
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// $effect(() => {
|
||||||
|
// if (formState.form.ClientTestCode) {
|
||||||
|
// formState.form.ClientTestName = 'nyaho';
|
||||||
|
// }
|
||||||
|
// })
|
||||||
$inspect(mapFormFieldsTransformed)
|
$inspect(mapFormFieldsTransformed)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -127,7 +127,8 @@
|
|||||||
endpointParamKey,
|
endpointParamKey,
|
||||||
valueKey,
|
valueKey,
|
||||||
labelKey,
|
labelKey,
|
||||||
txtKey
|
txtKey,
|
||||||
|
tabIndex = 0,
|
||||||
})}
|
})}
|
||||||
<div class="flex w-full flex-col gap-1.5">
|
<div class="flex w-full flex-col gap-1.5">
|
||||||
<div class="flex justify-between items-center w-full">
|
<div class="flex justify-between items-center w-full">
|
||||||
@ -155,6 +156,7 @@
|
|||||||
{#if type === 'text'}
|
{#if type === 'text'}
|
||||||
<Input
|
<Input
|
||||||
type="text"
|
type="text"
|
||||||
|
tabindex={tabIndex}
|
||||||
bind:value={formState.form[key]}
|
bind:value={formState.form[key]}
|
||||||
oninput={() => {
|
oninput={() => {
|
||||||
if (validateOn?.includes('input')) {
|
if (validateOn?.includes('input')) {
|
||||||
@ -275,6 +277,18 @@
|
|||||||
formState.selectOptions.ClientTestCode = [];
|
formState.selectOptions.ClientTestCode = [];
|
||||||
formState.selectOptions.ClientTestName = [];
|
formState.selectOptions.ClientTestName = [];
|
||||||
}
|
}
|
||||||
|
if (key === 'ClientTestCode') {
|
||||||
|
const selectedItem = formState.selectOptions?.[key]?.find(
|
||||||
|
(opt) => opt.value === val
|
||||||
|
);
|
||||||
|
formState.form.ClientTestName = selectedItem?.rawItem?.TestSiteName ?? '';
|
||||||
|
}
|
||||||
|
if (key === 'HostTestCode') {
|
||||||
|
const selectedItem = formState.selectOptions?.[key]?.find(
|
||||||
|
(opt) => opt.value === val
|
||||||
|
);
|
||||||
|
formState.form.HostTestName = selectedItem?.rawItem?.TestSiteName ?? '';
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
onOpenChange={(open) => {
|
onOpenChange={(open) => {
|
||||||
if (open) {
|
if (open) {
|
||||||
@ -291,7 +305,7 @@
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Select.Trigger class="w-full truncate">
|
<Select.Trigger class="w-full truncate" tabindex={tabIndex}>
|
||||||
{selectedLabel}
|
{selectedLabel}
|
||||||
</Select.Trigger>
|
</Select.Trigger>
|
||||||
<Select.Content>
|
<Select.Content>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user