feat: add Consume and Restock quick action buttons (#64 #65)
Some checks failed
Deploy to Coolify / Code Quality (pull_request) Has been cancelled
Deploy to Coolify / Run Tests (pull_request) Has been cancelled
Deploy to Coolify / Deploy to Development (pull_request) Has been cancelled
Deploy to Coolify / Deploy to Production (pull_request) Has been cancelled
Deploy to Coolify / Deploy to Test (pull_request) Has been cancelled
Pull Request Checks / Validate PR (pull_request) Has been cancelled
Some checks failed
Deploy to Coolify / Code Quality (pull_request) Has been cancelled
Deploy to Coolify / Run Tests (pull_request) Has been cancelled
Deploy to Coolify / Deploy to Development (pull_request) Has been cancelled
Deploy to Coolify / Deploy to Production (pull_request) Has been cancelled
Deploy to Coolify / Deploy to Test (pull_request) Has been cancelled
Pull Request Checks / Validate PR (pull_request) Has been cancelled
This commit is contained in:
@@ -88,13 +88,37 @@
|
|||||||
|
|
||||||
<!-- Action Buttons -->
|
<!-- Action Buttons -->
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<div class="flex gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
|
<!-- Quick Actions Row -->
|
||||||
|
<div class="grid grid-cols-2 gap-2">
|
||||||
|
<UButton
|
||||||
|
icon="i-heroicons-arrow-trending-down"
|
||||||
|
size="sm"
|
||||||
|
color="orange"
|
||||||
|
variant="soft"
|
||||||
|
@click="handleConsume"
|
||||||
|
:disabled="item.quantity <= 0.01"
|
||||||
|
>
|
||||||
|
Consume
|
||||||
|
</UButton>
|
||||||
|
<UButton
|
||||||
|
icon="i-heroicons-arrow-trending-up"
|
||||||
|
size="sm"
|
||||||
|
color="green"
|
||||||
|
variant="soft"
|
||||||
|
@click="showRestockModal = true"
|
||||||
|
>
|
||||||
|
Restock
|
||||||
|
</UButton>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Management Actions Row -->
|
||||||
|
<div class="grid grid-cols-2 gap-2">
|
||||||
<UButton
|
<UButton
|
||||||
icon="i-heroicons-pencil"
|
icon="i-heroicons-pencil"
|
||||||
size="sm"
|
size="sm"
|
||||||
color="gray"
|
color="gray"
|
||||||
variant="soft"
|
variant="soft"
|
||||||
class="flex-1"
|
|
||||||
@click="$emit('edit', item)"
|
@click="$emit('edit', item)"
|
||||||
>
|
>
|
||||||
Edit
|
Edit
|
||||||
@@ -109,7 +133,61 @@
|
|||||||
Delete
|
Delete
|
||||||
</UButton>
|
</UButton>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<!-- Restock Modal -->
|
||||||
|
<UModal v-model="showRestockModal">
|
||||||
|
<UCard>
|
||||||
|
<template #header>
|
||||||
|
<h3 class="text-lg font-semibold">Restock {{ item.name }}</h3>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div class="space-y-4">
|
||||||
|
<div class="text-sm text-gray-600">
|
||||||
|
Current: <span class="font-semibold">{{ item.quantity }} {{ item.unit?.abbreviation }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<UFormGroup label="Amount to add">
|
||||||
|
<UInput
|
||||||
|
v-model.number="restockAmount"
|
||||||
|
type="number"
|
||||||
|
min="0.01"
|
||||||
|
step="0.01"
|
||||||
|
size="lg"
|
||||||
|
autofocus
|
||||||
|
placeholder="e.g. 5"
|
||||||
|
/>
|
||||||
|
</UFormGroup>
|
||||||
|
|
||||||
|
<div v-if="restockAmount > 0" class="text-sm text-gray-600">
|
||||||
|
New total: <span class="font-semibold">{{ (Number(item.quantity) + Number(restockAmount)).toFixed(2) }} {{ item.unit?.abbreviation }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<div class="flex gap-2">
|
||||||
|
<UButton
|
||||||
|
color="primary"
|
||||||
|
size="lg"
|
||||||
|
class="flex-1"
|
||||||
|
@click="handleRestock"
|
||||||
|
:disabled="!restockAmount || restockAmount <= 0"
|
||||||
|
>
|
||||||
|
Add {{ restockAmount || 0 }} {{ item.unit?.abbreviation }}
|
||||||
|
</UButton>
|
||||||
|
<UButton
|
||||||
|
color="gray"
|
||||||
|
size="lg"
|
||||||
|
variant="soft"
|
||||||
|
@click="showRestockModal = false"
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</UButton>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</UCard>
|
||||||
|
</UModal>
|
||||||
</UCard>
|
</UCard>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -118,12 +196,17 @@ const props = defineProps<{
|
|||||||
item: any
|
item: any
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
defineEmits<{
|
const emit = defineEmits<{
|
||||||
edit: [item: any]
|
edit: [item: any]
|
||||||
delete: [id: string]
|
delete: [id: string]
|
||||||
'update-quantity': [id: string, change: number]
|
'update-quantity': [id: string, change: number]
|
||||||
|
'consume': [id: string]
|
||||||
|
'restock': [id: string, amount: number]
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
const showRestockModal = ref(false)
|
||||||
|
const restockAmount = ref<number>(1)
|
||||||
|
|
||||||
// Calculate days until expiry
|
// Calculate days until expiry
|
||||||
const daysUntilExpiry = computed(() => {
|
const daysUntilExpiry = computed(() => {
|
||||||
if (!props.item.expiry_date) return null
|
if (!props.item.expiry_date) return null
|
||||||
@@ -163,4 +246,24 @@ const isLowStock = computed(() => {
|
|||||||
if (!props.item.low_stock_threshold) return false
|
if (!props.item.low_stock_threshold) return false
|
||||||
return Number(props.item.quantity) <= Number(props.item.low_stock_threshold)
|
return Number(props.item.quantity) <= Number(props.item.low_stock_threshold)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Quick actions
|
||||||
|
const handleConsume = () => {
|
||||||
|
emit('update-quantity', props.item.id, -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleRestock = () => {
|
||||||
|
if (restockAmount.value && restockAmount.value > 0) {
|
||||||
|
emit('update-quantity', props.item.id, restockAmount.value)
|
||||||
|
showRestockModal.value = false
|
||||||
|
restockAmount.value = 1 // Reset for next time
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset restock amount when modal closes
|
||||||
|
watch(showRestockModal, (isOpen) => {
|
||||||
|
if (!isOpen) {
|
||||||
|
restockAmount.value = 1
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user