Compare commits
4 Commits
feature/is
...
ec6dd68e70
| Author | SHA1 | Date | |
|---|---|---|---|
| ec6dd68e70 | |||
|
|
76c4a875ff | ||
|
|
2635483dbc | ||
| f6300c890b |
@@ -60,6 +60,7 @@ const { getInventory, deleteInventoryItem, updateQuantity } = useInventory()
|
|||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
refresh?: boolean
|
refresh?: boolean
|
||||||
tagFilters?: string[]
|
tagFilters?: string[]
|
||||||
|
searchQuery?: string
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
@@ -89,17 +90,27 @@ const loadInventory = async () => {
|
|||||||
|
|
||||||
// Computed filtered items
|
// Computed filtered items
|
||||||
const filteredItems = computed(() => {
|
const filteredItems = computed(() => {
|
||||||
if (!props.tagFilters || props.tagFilters.length === 0) {
|
let result = items.value
|
||||||
return items.value
|
|
||||||
|
// Filter by search query (case-insensitive)
|
||||||
|
if (props.searchQuery && props.searchQuery.trim()) {
|
||||||
|
const query = props.searchQuery.trim().toLowerCase()
|
||||||
|
result = result.filter(item =>
|
||||||
|
item.name.toLowerCase().includes(query)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter items that have at least one of the selected tags
|
// Filter by tags
|
||||||
return items.value.filter(item => {
|
if (props.tagFilters && props.tagFilters.length > 0) {
|
||||||
|
result = result.filter(item => {
|
||||||
if (!item.tags || item.tags.length === 0) return false
|
if (!item.tags || item.tags.length === 0) return false
|
||||||
|
|
||||||
const itemTagIds = item.tags.map((t: any) => t.tag.id)
|
const itemTagIds = item.tags.map((t: any) => t.tag.id)
|
||||||
return props.tagFilters!.some(filterId => itemTagIds.includes(filterId))
|
return props.tagFilters!.some(filterId => itemTagIds.includes(filterId))
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
})
|
})
|
||||||
|
|
||||||
const handleDelete = async (id: string) => {
|
const handleDelete = async (id: string) => {
|
||||||
|
|||||||
@@ -33,9 +33,36 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Search & Filters -->
|
||||||
|
<UCard v-if="showFilters" class="mb-6 space-y-4">
|
||||||
|
<!-- Search Bar -->
|
||||||
|
<div>
|
||||||
|
<UFormGroup label="Search Items">
|
||||||
|
<UInput
|
||||||
|
v-model="searchQuery"
|
||||||
|
placeholder="Search by item name..."
|
||||||
|
icon="i-heroicons-magnifying-glass"
|
||||||
|
size="lg"
|
||||||
|
:ui="{ icon: { trailing: { pointer: '' } } }"
|
||||||
|
>
|
||||||
|
<template #trailing>
|
||||||
|
<UButton
|
||||||
|
v-if="searchQuery"
|
||||||
|
color="gray"
|
||||||
|
variant="link"
|
||||||
|
icon="i-heroicons-x-mark"
|
||||||
|
:padded="false"
|
||||||
|
@click="searchQuery = ''"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</UInput>
|
||||||
|
</UFormGroup>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Tag Filters -->
|
<!-- Tag Filters -->
|
||||||
<UCard v-if="showFilters" class="mb-6">
|
<div>
|
||||||
<TagsTagFilter v-model="selectedTagFilters" />
|
<TagsTagFilter v-model="selectedTagFilters" />
|
||||||
|
</div>
|
||||||
</UCard>
|
</UCard>
|
||||||
|
|
||||||
<!-- Add Item Form (Overlay) -->
|
<!-- Add Item Form (Overlay) -->
|
||||||
@@ -61,6 +88,7 @@
|
|||||||
ref="inventoryListRef"
|
ref="inventoryListRef"
|
||||||
:refresh="refreshKey"
|
:refresh="refreshKey"
|
||||||
:tag-filters="selectedTagFilters"
|
:tag-filters="selectedTagFilters"
|
||||||
|
:search-query="searchQuery"
|
||||||
@add-item="showAddForm = true"
|
@add-item="showAddForm = true"
|
||||||
@edit-item="editingItem = $event"
|
@edit-item="editingItem = $event"
|
||||||
/>
|
/>
|
||||||
@@ -82,6 +110,7 @@ const refreshKey = ref(0)
|
|||||||
const inventoryListRef = ref()
|
const inventoryListRef = ref()
|
||||||
const prefilledData = ref<any>(null)
|
const prefilledData = ref<any>(null)
|
||||||
const selectedTagFilters = ref<string[]>([])
|
const selectedTagFilters = ref<string[]>([])
|
||||||
|
const searchQuery = ref('')
|
||||||
|
|
||||||
// Handle scan-to-add flow (Issue #25)
|
// Handle scan-to-add flow (Issue #25)
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user