change container using label

This commit is contained in:
faiztyanirh 2026-04-16 14:08:33 +07:00
parent 7f052986b3
commit 32c20ccd16
3 changed files with 20 additions and 13 deletions

View File

@ -117,16 +117,16 @@
tempMap, tempMap,
}); });
console.log(payload) console.log(payload)
const result = await formState.save(masterDetail.mode, payload); // const result = await formState.save(masterDetail.mode, payload);
if (result.status === 'success') { // if (result.status === 'success') {
toast('Test Map Created!'); // toast('Test Map Created!');
masterDetail?.exitForm(true); // masterDetail?.exitForm(true);
} else { // } else {
console.error('Failed to save test map'); // console.error('Failed to save test map');
const errorMessages = result.messages ? Object.values(result.messages).join('\n') : 'Failed to save test map'; // const errorMessages = result.messages ? Object.values(result.messages).join('\n') : 'Failed to save test map';
toast.error(errorMessages) // toast.error(errorMessages)
} // }
} }
const primaryAction = $derived({ const primaryAction = $derived({
@ -262,6 +262,12 @@
})) }))
}) })
function getLabel(fieldKey, value) {
const opts = testMapDetailFormState.selectOptions[fieldKey] ?? [];
const found = opts.find((o) => o.value == value);
return found ? found.rawItem.ConName : value;
}
onMount(() => { onMount(() => {
masterDetail.registerExtraState({ masterDetail.registerExtraState({
key: 'tempMap', key: 'tempMap',
@ -269,7 +275,7 @@
reset: () => { tempMap = []; idCounter = 0; editingId = null; }, reset: () => { tempMap = []; idCounter = 0; editingId = null; },
}); });
}); });
$inspect(testMapDetailFormState.errors) $inspect(testMapDetailFormState.selectOptions)
</script> </script>
<FormPageContainer title="Create Test Map" {primaryAction} {secondaryActions} {actions}> <FormPageContainer title="Create Test Map" {primaryAction} {secondaryActions} {actions}>
@ -331,7 +337,7 @@
<Table.Cell>{row.HostTestName}</Table.Cell> <Table.Cell>{row.HostTestName}</Table.Cell>
<Table.Cell>{row.ClientTestCode}</Table.Cell> <Table.Cell>{row.ClientTestCode}</Table.Cell>
<Table.Cell>{row.ClientTestName}</Table.Cell> <Table.Cell>{row.ClientTestName}</Table.Cell>
<Table.Cell>{row.ConDefID}</Table.Cell> <Table.Cell>{row.ConDefID ? getLabel('ConDefID', row.ConDefID) : '-'}</Table.Cell>
<Table.Cell> <Table.Cell>
<div class="flex gap-1"> <div class="flex gap-1">
<Tooltip.Provider> <Tooltip.Provider>

View File

@ -379,6 +379,7 @@
reset: () => { tempMap = []; idCounter = 0; editingId = null; }, reset: () => { tempMap = []; idCounter = 0; editingId = null; },
}); });
}); });
$inspect(tempMap)
</script> </script>
<FormPageContainer title="Edit Test Map" {primaryAction} {secondaryActions}> <FormPageContainer title="Edit Test Map" {primaryAction} {secondaryActions}>
@ -438,7 +439,7 @@
<Table.Cell>{row.HostTestName}</Table.Cell> <Table.Cell>{row.HostTestName}</Table.Cell>
<Table.Cell>{row.ClientTestCode}</Table.Cell> <Table.Cell>{row.ClientTestCode}</Table.Cell>
<Table.Cell>{row.ClientTestName}</Table.Cell> <Table.Cell>{row.ClientTestName}</Table.Cell>
<Table.Cell>{row.ConDefID}</Table.Cell> <Table.Cell>{row.ContainerLabel}</Table.Cell>
<Table.Cell> <Table.Cell>
<div class="flex gap-1"> <div class="flex gap-1">
<Tooltip.Provider> <Tooltip.Provider>

View File

@ -61,7 +61,7 @@
<Table.Cell>{row.HostTestName ?? '-'}</Table.Cell> <Table.Cell>{row.HostTestName ?? '-'}</Table.Cell>
<Table.Cell>{row.ClientTestCode ?? '-'}</Table.Cell> <Table.Cell>{row.ClientTestCode ?? '-'}</Table.Cell>
<Table.Cell>{row.ClientTestName ?? '-'}</Table.Cell> <Table.Cell>{row.ClientTestName ?? '-'}</Table.Cell>
<Table.Cell>{row.ConDefID ?? '-'}</Table.Cell> <Table.Cell>{row.ContainerLabel ?? '-'}</Table.Cell>
</Table.Row> </Table.Row>
{/each} {/each}
</Table.Body> </Table.Body>