implemented simpleSearch for Employees/Index.

This commit is contained in:
Sockenklaus
2021-11-07 15:37:08 +01:00
parent e018db9e0a
commit a9d0f109a9
6 changed files with 128 additions and 22 deletions

View File

@@ -0,0 +1,64 @@
<template>
<div class="input-group">
<input
type="text"
class="form-control"
v-model="searchQuery"
placeholder="Suche nach..."
@keyup="search"
>
<button aria-expanded="false" data-bs-toggle="dropdown" data-bs-auto-close="outside" type="button" class="btn btn-outline-secondary dropdown-toggle">
Suche in...
</button>
<ul class="dropdown-menu">
<li v-for="(item, index) in unionColumns" :key="item">
<label class="dropdown-item form-check">
<input type="checkbox" :value="item" :id="'checkBox'+item" v-model="checkedColumns" class="form-check-input">
{{item}}
</label>
</li>
</ul>
</div>
{{ unionColumns }}
</template>
<script setup lang="ts">
import { ref, computed} from 'vue';
import { storeToRefs } from 'pinia'
import { useEmployees } from '@/stores/employees';
import { union } from 'lodash';
const searchQuery = ref('')
const checkedColumns = ref([])
const store = useEmployees()
const { columns, simple_search } = storeToRefs(store)
const queryString = computed(() => {
return searchQuery.value + '(' + checkedColumns.value.join(',') + ')'
})
const unionColumns = computed(() => {
return union(columns.value, checkedColumns.value)
})
async function search() {
simple_search.value = queryString.value
await store.fetchFromApi()
}
</script>
<style scoped>
.form-check {
padding-left: 20px;
}
.form-check input {
margin-left: -0.5rem;
margin-right: 0.5rem;
}
</style>