refactor(person-relative): update contact form fields and conditional label
- Change form field names from medicines to contacts - Update default contact object structure - Make label in select-relations conditional - Improve delete button title with contact number
This commit is contained in:
@@ -47,10 +47,10 @@ const { title = 'Kontak Pasien', isReadonly = false } = props
|
||||
<div class="mb-5 space-y-4">
|
||||
<FieldArray
|
||||
v-slot="{ fields, push, remove }"
|
||||
name="medicines"
|
||||
name="contacts"
|
||||
>
|
||||
<template v-if="fields.length === 0">
|
||||
{{ push({ name: '', dose: '', unit: '' }) }}
|
||||
{{ push({ relation: '', name: '', address: '', phone: '' }) }}
|
||||
</template>
|
||||
<div class="space-y-4">
|
||||
<DE.Block
|
||||
@@ -63,7 +63,6 @@ const { title = 'Kontak Pasien', isReadonly = false } = props
|
||||
:label="idx === 0 ? 'Hubungan dengan Pasien' : undefined"
|
||||
:field-name="`contacts[${idx}].relation`"
|
||||
placeholder="Pilih"
|
||||
field-group-class="mb-0"
|
||||
:is-disabled="isReadonly"
|
||||
/>
|
||||
<InputBase
|
||||
@@ -90,7 +89,7 @@ const { title = 'Kontak Pasien', isReadonly = false } = props
|
||||
<ButtonAction
|
||||
:disabled="isReadonly"
|
||||
preset="delete"
|
||||
title="Hapus"
|
||||
:title="`Hapus Kontak ${idx + 1}`"
|
||||
icon-only
|
||||
@click="remove(idx)"
|
||||
/>
|
||||
@@ -100,12 +99,12 @@ const { title = 'Kontak Pasien', isReadonly = false } = props
|
||||
|
||||
<ButtonAction
|
||||
preset="add"
|
||||
label="Tambah Obat"
|
||||
label="Tambah Kontak"
|
||||
title="Tambah Kontak ke Daftar Kontak"
|
||||
:disabled="fields.length >= 5 || isReadonly"
|
||||
:full-width-mobile="true"
|
||||
class="mt-4"
|
||||
@click="push({ name: '', dose: '', unit: '' })"
|
||||
@click="push({ relation: '', name: '', address: '', phone: '' })"
|
||||
/>
|
||||
</FieldArray>
|
||||
</div>
|
||||
|
||||
@@ -33,6 +33,7 @@ const opts = Object.entries(relationshipCodes).map(([value, label]) => ({
|
||||
:class="cn('select-field-group', fieldGroupClass, containerClass)"
|
||||
>
|
||||
<DE.Label
|
||||
v-if="label"
|
||||
:label-for="fieldName"
|
||||
:class="cn('select-field-label', labelClass)"
|
||||
:is-required="isRequired"
|
||||
|
||||
Reference in New Issue
Block a user