refactor: add local quantity state to feed items grid modal and allow direct save via parameter

This commit is contained in:
Yoga Pangestu 2026-05-02 14:42:41 +07:00
parent a9e10849fd
commit b12e20f49a
2 changed files with 20 additions and 16 deletions

View File

@ -43,8 +43,12 @@ public function openQtyModal(int $feedId): void
$this->dispatch('open-modal', id: 'qty-modal');
}
public function saveQtyModal(): void
public function saveQtyModal($qty = null): void
{
if ($qty !== null) {
$this->modalQty = $qty;
}
if ($this->modalFeedId) {
$this->updateQty($this->modalFeedId, (int) $this->modalQty);
}

View File

@ -53,28 +53,28 @@ class="w-8 h-8 rounded-full flex items-center justify-center text-white text-lg
Atur Jumlah: {{ $this->modalFeedName }}
</x-slot>
<div class="py-2">
<x-filament::input.wrapper>
<x-filament::input
type="number"
wire:model="modalQty"
wire:keydown.enter="saveQtyModal"
placeholder="Masukan jumlah..."
autofocus
/>
</x-filament::input.wrapper>
</div>
<div x-data="{ localQty: 0 }" x-on:open-modal.window="if ($event.detail.id === 'qty-modal') { localQty = $wire.modalQty }">
<div class="py-2">
<x-filament::input.wrapper>
<x-filament::input
type="number"
x-model="localQty"
x-on:keydown.enter="$wire.saveQtyModal(localQty)"
placeholder="Masukan jumlah..."
autofocus
/>
</x-filament::input.wrapper>
</div>
<x-slot name="footer">
<div class="flex justify-end gap-3">
<div class="flex justify-end gap-3 mt-4">
<x-filament::button color="gray" wire:click="$set('isQtyModalOpen', false)" size="sm">
Batal
</x-filament::button>
<x-filament::button wire:click="saveQtyModal" size="sm">
<x-filament::button x-on:click="$wire.saveQtyModal(localQty)" size="sm">
Simpan
</x-filament::button>
</div>
</x-slot>
</div>
</x-filament::modal>
</div>