Introduced TempStore to Store SearchStrings and Selections etc
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
|
import {useTempStore} from "~/stores/temp.js";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
type: {
|
type: {
|
||||||
required: true,
|
required: true,
|
||||||
@@ -47,6 +49,7 @@ defineShortcuts({
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
const profileStore = useProfileStore()
|
const profileStore = useProfileStore()
|
||||||
|
const tempStore = useTempStore()
|
||||||
|
|
||||||
const dataType = dataStore.dataTypes[type]
|
const dataType = dataStore.dataTypes[type]
|
||||||
|
|
||||||
@@ -58,7 +61,12 @@ const selectedItem = ref(0)
|
|||||||
const selectedColumns = ref(dataType.templateColumns.filter(i => !i.disabledInTable))
|
const selectedColumns = ref(dataType.templateColumns.filter(i => !i.disabledInTable))
|
||||||
const columns = computed(() => dataType.templateColumns.filter((column) => !column.disabledInTable && selectedColumns.value.includes(column)))
|
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 selectableFilters = ref(dataType.filters.map(i => i.name))
|
||||||
const selectedFilters = ref(dataType.filters.filter(i => i.default).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..."
|
placeholder="Suche..."
|
||||||
class="hidden lg:block"
|
class="hidden lg:block"
|
||||||
@keydown.esc="$event.target.blur()"
|
@keydown.esc="$event.target.blur()"
|
||||||
|
@change="tempStore.modifySearchString(type,searchString)"
|
||||||
>
|
>
|
||||||
<template #trailing>
|
<template #trailing>
|
||||||
<UKbd value="/" />
|
<UKbd value="/" />
|
||||||
</template>
|
</template>
|
||||||
</UInput>
|
</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>
|
</template>
|
||||||
</UDashboardNavbar>
|
</UDashboardNavbar>
|
||||||
|
|
||||||
|
|||||||
24
stores/temp.js
Normal file
24
stores/temp.js
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import {defineStore} from 'pinia'
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
export const useTempStore = defineStore('temp', () => {
|
||||||
|
|
||||||
|
const searchStrings = ref({})
|
||||||
|
|
||||||
|
function modifySearchString(type,input) {
|
||||||
|
searchStrings.value[type] = input
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearSearchString(type) {
|
||||||
|
searchStrings.value[type] = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return {
|
||||||
|
searchStrings,
|
||||||
|
modifySearchString,
|
||||||
|
clearSearchString
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user