121 lines
2.7 KiB
Vue
121 lines
2.7 KiB
Vue
<template>
|
|
<UDashboardNavbar title="Objekte" :badge="filteredRows.length">
|
|
<template #right>
|
|
<UInput
|
|
id="searchinput"
|
|
v-model="searchString"
|
|
icon="i-heroicons-funnel"
|
|
autocomplete="off"
|
|
placeholder="Suche..."
|
|
class="hidden lg:block"
|
|
@keydown.esc="$event.target.blur()"
|
|
>
|
|
<template #trailing>
|
|
<UKbd value="/" />
|
|
</template>
|
|
</UInput>
|
|
|
|
<UButton @click="router.push(`/plants/create`)">+ Objekt</UButton>
|
|
</template>
|
|
</UDashboardNavbar>
|
|
|
|
<UDashboardToolbar>
|
|
<template #left>
|
|
|
|
|
|
<UCheckbox
|
|
label="Erledigte Anzeigen"
|
|
v-model="showDone"
|
|
/>
|
|
</template>
|
|
|
|
<template #right>
|
|
<USelectMenu
|
|
v-model="selectedColumns"
|
|
icon="i-heroicons-adjustments-horizontal-solid"
|
|
:options="templateColumns"
|
|
multiple
|
|
class="hidden lg:block"
|
|
by="key"
|
|
>
|
|
<template #label>
|
|
Spalten
|
|
</template>
|
|
</USelectMenu>
|
|
</template>
|
|
</UDashboardToolbar>
|
|
|
|
<UTable
|
|
:rows="filteredRows"
|
|
:columns="columns"
|
|
class="w-full"
|
|
:ui="{ divide: 'divide-gray-200 dark:divide-gray-800' }"
|
|
@select="(i) => router.push(`/plants/show/${i.id}`) "
|
|
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine Objekte anzuzeigen' }"
|
|
>
|
|
<template #customer-data="{row}">
|
|
{{dataStore.customers.find(customer => customer.id === row.customer) ? dataStore.customers.find(customer => customer.id === row.customer).name : "" }}
|
|
</template>
|
|
</UTable>
|
|
|
|
</template>
|
|
|
|
<script setup>
|
|
|
|
definePageMeta({
|
|
middleware: "auth"
|
|
})
|
|
|
|
defineShortcuts({
|
|
'/': () => {
|
|
//console.log(searchinput)
|
|
//searchinput.value.focus()
|
|
document.getElementById("searchinput").focus()
|
|
},
|
|
'+': () => {
|
|
router.push("/plants/create")
|
|
}
|
|
})
|
|
|
|
const dataStore = useDataStore()
|
|
const router = useRouter()
|
|
|
|
const templateColumns = [
|
|
{
|
|
key: "name",
|
|
label: "Name",
|
|
sortable: true
|
|
},{
|
|
key: "customer",
|
|
label: "Kunde",
|
|
sortable: true
|
|
}
|
|
]
|
|
const selectedColumns = ref(templateColumns)
|
|
const columns = computed(() => templateColumns.filter((column) => selectedColumns.value.includes(column)))
|
|
|
|
|
|
const searchString = ref('')
|
|
|
|
const filteredRows = computed(() => {
|
|
if(!searchString.value) {
|
|
return dataStore.plants
|
|
}
|
|
|
|
return dataStore.plants.filter(item => {
|
|
|
|
item.customerName = dataStore.customers.find(i => i.id === item.customer).name
|
|
|
|
return Object.values(item).some((value) => {
|
|
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
|
|
})
|
|
})
|
|
})
|
|
const selectItem = (item) => {
|
|
router.push(`/plants/show/${item.id} `)
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
|
|
</style> |