fix switch toggle on wording data parents
This commit is contained in:
@@ -33,13 +33,14 @@ watch(
|
||||
(newValue) => {
|
||||
if (!formRef.value) return
|
||||
|
||||
const currentFamilies = formRef.value.values?.families || []
|
||||
|
||||
if (newValue === '1') {
|
||||
isFamilyFormDisabled.value = false
|
||||
|
||||
// CREATE MODE — Auto default
|
||||
if (!isEditing.value && currentFamilies.length === 0) {
|
||||
const fam = formRef.value.values?.families || []
|
||||
|
||||
const needsReset = fam.length !== 2 || fam[0]?.relation !== 'mother' || fam[1]?.relation !== 'father'
|
||||
|
||||
if (needsReset) {
|
||||
formRef.value.setFieldValue('families', [
|
||||
{ relation: 'mother', name: '', education: '', occupation: '' },
|
||||
{ relation: 'father', name: '', education: '', occupation: '' },
|
||||
@@ -51,9 +52,7 @@ watch(
|
||||
|
||||
isFamilyFormDisabled.value = true
|
||||
|
||||
if (!isEditing.value) {
|
||||
formRef.value.setFieldValue('families', [])
|
||||
}
|
||||
formRef.value.setFieldValue('families', [])
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
@@ -105,7 +104,7 @@ watch(
|
||||
class="space-y-4 rounded-lg border border-gray-200 bg-gray-50/50 p-4 dark:border-gray-700 dark:bg-gray-800/50"
|
||||
>
|
||||
<h4 class="text-sm font-medium text-gray-700 dark:text-gray-300">
|
||||
{{ (values.families as FamilyData[])?.[idx]?.relation === 'mother' ? 'Data Ibu' : 'Data Ayah' }}
|
||||
{{ (field.value as FamilyData).relation === 'mother' ? 'Data Ibu' : 'Data Ayah' }}
|
||||
</h4>
|
||||
|
||||
<DE.Block>
|
||||
|
||||
Reference in New Issue
Block a user