rudimentary filter string for game list

This commit is contained in:
jmosrael@gmail.com
2024-05-18 14:13:38 -07:00
parent 401330d842
commit f0de240b8a
3 changed files with 40 additions and 15 deletions

View File

@@ -1,4 +1,7 @@
<template>
<div class="d-flex flex-row">
<input class="filter flex-1-0" placeholder="Filter by Name" v-model="filtervalue" />
</div>
<v-table>
<thead>
<tr>
@@ -26,22 +29,35 @@
@update:modelValue="setPage($event)"
></v-pagination>
</template>
<style></style>
<style>
label.filter {
margin: 10px;
margin-bottom: 0px;
}
input.filter {
margin: 10px;
background: darkslategray;
border-color: lightgray;
}
</style>
<script setup lang="ts">
import { onMounted, onCreated, ref } from 'vue'
import { onMounted, watch, ref } from 'vue'
import axios from 'axios'
let page = 1
let page = 0
let count = 10
const games = ref({})
const pageCount = ref(1)
const filtervalue = ref("")
async function loadData() {
const response = await axios.post('/api/game', {
page: `${page}`,
count: '10',
orderBy: 'id'
filter: filtervalue.value ? `title:${filtervalue.value}` : ""
})
games.value = response.data.gameData
@@ -66,4 +82,13 @@ function setPage(targetPage: number) {
onMounted(async () => {
loadData()
})
let debounce = null;
watch(filtervalue, (oldFilter, newFilter) => {
debounce = clearTimeout(debounce)
debounce = setTimeout(() => {
loadData()
}, 500)
})
</script>