wip: adjust form

- adjust rencana edukasi
- hide code on select items
This commit is contained in:
Khafid Prayoga
2025-12-08 11:14:51 +07:00
parent a5ec824f4d
commit 0d3cfbec47
4 changed files with 56 additions and 75 deletions
@@ -3,10 +3,11 @@ import { toTypedSchema } from '@vee-validate/zod'
import { FieldArray } from 'vee-validate'
import { Form } from '~/components/pub/ui/form'
// componenets
import * as DE from '~/components/pub/my-ui/doc-entry'
import Separator from '~/components/pub/ui/separator/Separator.vue'
import { BaseSelect, BaseTextarea, CheckboxGeneral, CheckboxSpecial } from './field'
import { BaseSelect, CheckboxGeneral, CheckboxSpecial } from './field'
import { ButtonAction, TextAreaInput } from '~/components/pub/my-ui/form'
// constant
import {
@@ -154,53 +155,53 @@ defineExpose({
>
<FieldArray
v-slot="{ fields, push, remove }"
name="plans"
name="tissueNotes"
>
<div
:col-count="2"
v-for="(field, idx) in fields"
:key="field.key"
>
<template v-if="fields.length === 0">
{{ push({ note: '' }) }}
</template>
<div class="space-y-4">
<DE.Block
:col-count="4"
v-for="(field, idx) in fields"
:key="field.key"
:col-count="6"
:cell-flex="false"
>
<DE.Cell :col-span="3">
<BaseTextarea
<DE.Cell :col-span="5">
<TextAreaInput
:field-name="`plans[${idx}].value`"
:label="'Rencana ' + Number(idx + 1)"
placeholder="Masukkan rencana catatan"
:col-span="2"
:rows="5"
:is-disabled="isReadonly"
/>
</DE.Cell>
<Button
type="button"
variant="outline"
size="icon"
class="mt-5 text-red-600 hover:border-red-400 hover:bg-red-50 hover:text-red-700 dark:border-red-400 dark:text-red-400 dark:hover:border-red-300 dark:hover:bg-red-900/20"
:class="{ invisible: idx === 0 }"
@click="remove(idx)"
>
<Icon
name="i-lucide-trash-2"
class="h-5 w-5"
/>
</Button>
<DE.Cell class="flex items-start justify-start">
<DE.Field :class="idx === 0 ? 'mt-[30px]' : 'mt-0'">
<ButtonAction
v-if="idx !== 0"
:disabled="isReadonly"
preset="delete"
:title="`Hapus Rencana ${idx + 1}`"
icon-only
@click="remove(idx)"
/>
</DE.Field>
</DE.Cell>
</DE.Block>
</div>
<div class="self-center pt-3">
<Button
:disabled="fields.length >= noteLimit"
type="button"
variant="outline"
size="sm"
<ButtonAction
preset="add"
label="Tambah Rencana"
title="Tambah Rencana Edukasi"
:disabled="fields.length >= noteLimit || isReadonly"
:full-width-mobile="true"
class="mt-4"
@click="push({ id: fields.length + 1, value: '' })"
>
<Icon
name="i-lucide-plus"
class="h-5 w-5"
/>
Tambah Kontak
</Button>
/>
</div>
</FieldArray>
</DE.Block>
@@ -18,7 +18,24 @@ const props = defineProps<{
const { placeholder = 'Pilih', class: containerClass, selectClass, fieldGroupClass, labelClass } = props
const religionOptions = mapToComboboxOptList(props.items)
const opts = computed(() => {
const data = mapToComboboxOptList(props.items)
// hide code on select options
const filtered = data
.filter((item) => item.code)
.reduce(
(acc, item) => {
acc.push({
label: item.label as string,
value: item.value as string,
})
return acc
},
[] as Array<{ label: string; value: string }>,
)
return filtered
})
</script>
<template>
@@ -43,7 +60,7 @@ const religionOptions = mapToComboboxOptList(props.items)
<Select
:id="fieldName"
v-bind="componentField"
:items="religionOptions"
:items="opts"
:placeholder="placeholder"
:preserve-order="false"
:class="
@@ -1,36 +0,0 @@
<script setup lang="ts">
import * as DE from '~/components/pub/my-ui/doc-entry'
const props = defineProps<{
label: string
fieldName: string
placeholder?: string
colSpan?: number
}>()
const { label, fieldName, placeholder = 'Masukkan catatan' } = props
</script>
<template>
<DE.Cell :col-span="colSpan || 1">
<DE.Label :label-for="fieldName">
{{ label }}
</DE.Label>
<DE.Field :id="fieldName">
<FormField
v-slot="{ componentField }"
:name="fieldName"
>
<FormItem>
<FormControl>
<Textarea
v-bind="componentField"
:placeholder="placeholder"
/>
</FormControl>
<FormMessage />
</FormItem>
</FormField>
</DE.Field>
</DE.Cell>
</template>
@@ -1,5 +1,4 @@
export { default as BaseSelect } from './base-select.vue'
export { default as BaseTextarea } from './base-textarea.vue'
export { default as CheckboxGeneral } from './checkbox-general.vue'
export { default as CheckboxSpecial } from './checkbox-special.vue'
export { default as SelectAssessmentCode } from './select-assessment-code.vue'