feat: add dialog description and refactor variant selection to use native select element in RetailStockTransferModal
This commit is contained in:
parent
8eee3b04ce
commit
ee7b9b5839
@ -7,6 +7,7 @@ import { Button } from '@/components/ui/button';
|
|||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
@ -18,14 +19,7 @@ import {
|
|||||||
FieldLabel,
|
FieldLabel,
|
||||||
FieldSet,
|
FieldSet,
|
||||||
} from '@/components/ui/field';
|
} from '@/components/ui/field';
|
||||||
import {
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||||
Select,
|
|
||||||
SelectContent,
|
|
||||||
SelectGroup,
|
|
||||||
SelectItem,
|
|
||||||
SelectTrigger,
|
|
||||||
SelectValue,
|
|
||||||
} from '@/components/ui/select';
|
|
||||||
import { Textarea } from '@/components/ui/textarea';
|
import { Textarea } from '@/components/ui/textarea';
|
||||||
import { apiFetch } from '@/lib/api';
|
import { apiFetch } from '@/lib/api';
|
||||||
import { transfer } from '@/routes/admin/manage/retail-stock';
|
import { transfer } from '@/routes/admin/manage/retail-stock';
|
||||||
@ -54,6 +48,7 @@ const emit = defineEmits<{
|
|||||||
|
|
||||||
const processing = ref(false);
|
const processing = ref(false);
|
||||||
const errors = reactive<Record<string, string>>({});
|
const errors = reactive<Record<string, string>>({});
|
||||||
|
const selectPortalTarget = ref<HTMLElement>();
|
||||||
|
|
||||||
const selectedVariantId = ref(0);
|
const selectedVariantId = ref(0);
|
||||||
|
|
||||||
@ -151,6 +146,9 @@ function formatNumber(value: number): string {
|
|||||||
<DialogTitle class="flex items-center gap-2">
|
<DialogTitle class="flex items-center gap-2">
|
||||||
Transfer Stok Ecer
|
Transfer Stok Ecer
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
|
<DialogDescription class="sr-only">
|
||||||
|
Form pengajuan transfer stok ecer untuk produk {{ productName }}
|
||||||
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
|
|
||||||
<div class="space-y-4">
|
<div class="space-y-4">
|
||||||
@ -159,20 +157,21 @@ function formatNumber(value: number): string {
|
|||||||
|
|
||||||
<Field v-if="hasMultipleVariants">
|
<Field v-if="hasMultipleVariants">
|
||||||
<FieldLabel for="transfer-variant" required>Pilih Varian</FieldLabel>
|
<FieldLabel for="transfer-variant" required>Pilih Varian</FieldLabel>
|
||||||
<Select :model-value="selectedVariantId ? String(selectedVariantId) : undefined" @update:model-value="selectedVariantId = Number($event)">
|
<Select
|
||||||
|
:model-value="selectedVariantId ? String(selectedVariantId) : undefined"
|
||||||
|
@update:model-value="selectedVariantId = Number($event)"
|
||||||
|
>
|
||||||
<SelectTrigger id="transfer-variant" class="w-full">
|
<SelectTrigger id="transfer-variant" class="w-full">
|
||||||
<SelectValue placeholder="Pilih varian" />
|
<SelectValue placeholder="Pilih varian" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent :to="selectPortalTarget">
|
||||||
<SelectGroup>
|
|
||||||
<SelectItem
|
<SelectItem
|
||||||
v-for="variant in variants"
|
v-for="variant in props.variants"
|
||||||
:key="variant.id"
|
:key="variant.id"
|
||||||
:value="String(variant.id)"
|
:value="String(variant.id)"
|
||||||
>
|
>
|
||||||
{{ variant.name }}
|
{{ variant.name }}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
</SelectGroup>
|
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
</Field>
|
</Field>
|
||||||
@ -237,6 +236,7 @@ function formatNumber(value: number): string {
|
|||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
<div ref="selectPortalTarget" class="contents"></div>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -16,20 +16,20 @@ defineOptions({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<SelectContentProps & { class?: HTMLAttributes["class"] }>(),
|
defineProps<SelectContentProps & { class?: HTMLAttributes["class"], to?: string | HTMLElement }>(),
|
||||||
{
|
{
|
||||||
position: "popper",
|
position: "popper",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
const emits = defineEmits<SelectContentEmits>()
|
const emits = defineEmits<SelectContentEmits>()
|
||||||
|
|
||||||
const delegatedProps = reactiveOmit(props, "class")
|
const delegatedProps = reactiveOmit(props, "class", "to")
|
||||||
|
|
||||||
const forwarded = useForwardPropsEmits(delegatedProps, emits)
|
const forwarded = useForwardPropsEmits(delegatedProps, emits)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<SelectPortal>
|
<SelectPortal :to="to">
|
||||||
<SelectContent
|
<SelectContent
|
||||||
data-slot="select-content"
|
data-slot="select-content"
|
||||||
v-bind="{ ...$attrs, ...forwarded }"
|
v-bind="{ ...$attrs, ...forwarded }"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user