refactor: add local quantity state to feed items grid modal and allow direct save via parameter
This commit is contained in:
parent
a9e10849fd
commit
b12e20f49a
@ -43,8 +43,12 @@ public function openQtyModal(int $feedId): void
|
|||||||
$this->dispatch('open-modal', id: 'qty-modal');
|
$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) {
|
if ($this->modalFeedId) {
|
||||||
$this->updateQty($this->modalFeedId, (int) $this->modalQty);
|
$this->updateQty($this->modalFeedId, (int) $this->modalQty);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,28 +53,28 @@ class="w-8 h-8 rounded-full flex items-center justify-center text-white text-lg
|
|||||||
Atur Jumlah: {{ $this->modalFeedName }}
|
Atur Jumlah: {{ $this->modalFeedName }}
|
||||||
</x-slot>
|
</x-slot>
|
||||||
|
|
||||||
|
<div x-data="{ localQty: 0 }" x-on:open-modal.window="if ($event.detail.id === 'qty-modal') { localQty = $wire.modalQty }">
|
||||||
<div class="py-2">
|
<div class="py-2">
|
||||||
<x-filament::input.wrapper>
|
<x-filament::input.wrapper>
|
||||||
<x-filament::input
|
<x-filament::input
|
||||||
type="number"
|
type="number"
|
||||||
wire:model="modalQty"
|
x-model="localQty"
|
||||||
wire:keydown.enter="saveQtyModal"
|
x-on:keydown.enter="$wire.saveQtyModal(localQty)"
|
||||||
placeholder="Masukan jumlah..."
|
placeholder="Masukan jumlah..."
|
||||||
autofocus
|
autofocus
|
||||||
/>
|
/>
|
||||||
</x-filament::input.wrapper>
|
</x-filament::input.wrapper>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<x-slot name="footer">
|
<div class="flex justify-end gap-3 mt-4">
|
||||||
<div class="flex justify-end gap-3">
|
|
||||||
<x-filament::button color="gray" wire:click="$set('isQtyModalOpen', false)" size="sm">
|
<x-filament::button color="gray" wire:click="$set('isQtyModalOpen', false)" size="sm">
|
||||||
Batal
|
Batal
|
||||||
</x-filament::button>
|
</x-filament::button>
|
||||||
<x-filament::button wire:click="saveQtyModal" size="sm">
|
<x-filament::button x-on:click="$wire.saveQtyModal(localQty)" size="sm">
|
||||||
Simpan
|
Simpan
|
||||||
</x-filament::button>
|
</x-filament::button>
|
||||||
</div>
|
</div>
|
||||||
</x-slot>
|
</div>
|
||||||
</x-filament::modal>
|
</x-filament::modal>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user