Introduced TempStore to Store SearchStrings and Selections etc

This commit is contained in:
2025-02-03 11:05:35 +01:00
parent f4b0964e25
commit c207329a3e
2 changed files with 46 additions and 2 deletions

View File

@@ -1,4 +1,6 @@
<script setup>
import {useTempStore} from "~/stores/temp.js";
const props = defineProps({
type: {
required: true,
@@ -47,6 +49,7 @@ defineShortcuts({
const router = useRouter()
const dataStore = useDataStore()
const profileStore = useProfileStore()
const tempStore = useTempStore()
const dataType = dataStore.dataTypes[type]
@@ -58,7 +61,12 @@ const selectedItem = ref(0)
const selectedColumns = ref(dataType.templateColumns.filter(i => !i.disabledInTable))
const columns = computed(() => dataType.templateColumns.filter((column) => !column.disabledInTable && selectedColumns.value.includes(column)))
const searchString = ref('')
const searchString = ref(tempStore.searchStrings[props.type] ||'')
const clearSearchString = () => {
tempStore.clearSearchString(type)
searchString.value = ''
}
const selectableFilters = ref(dataType.filters.map(i => i.name))
const selectedFilters = ref(dataType.filters.filter(i => i.default).map(i => i.name) || [])
@@ -106,13 +114,25 @@ const filteredRows = computed(() => {
placeholder="Suche..."
class="hidden lg:block"
@keydown.esc="$event.target.blur()"
@change="tempStore.modifySearchString(type,searchString)"
>
<template #trailing>
<UKbd value="/" />
</template>
</UInput>
<UButton
icon="i-heroicons-x-mark"
variant="outline"
color="rose"
@click="clearSearchString()"
v-if="searchString.length > 0"
/>
<UButton v-if="useRole().checkRight(`${type}-create`)" @click="router.push(`/standardEntity/${type}/create`)">+ {{dataType.labelSingle}}</UButton>
<UButton
v-if="useRole().checkRight(`${type}-create`)"
@click="router.push(`/standardEntity/${type}/create`)"
class="ml-3"
>+ {{dataType.labelSingle}}</UButton>
</template>
</UDashboardNavbar>