From c24428b52feeb4b9cfbafac2541e40e9a891b428 Mon Sep 17 00:00:00 2001
From: alex <alex@alexloehr.net>
Date: Sun, 08 Jun 2025 16:34:04 +0000
Subject: [PATCH] fixing current count

---
 vue/src/pages/Users.vue |   64 ++++++++++++++++++++++++++++----
 1 files changed, 56 insertions(+), 8 deletions(-)

diff --git a/vue/src/pages/Users.vue b/vue/src/pages/Users.vue
index 0fa615f..eb21ccf 100644
--- a/vue/src/pages/Users.vue
+++ b/vue/src/pages/Users.vue
@@ -3,8 +3,9 @@
 import {onMounted, reactive, ref} from "vue"
 import {useRoute} from "vue-router"
 import Pagination from "../components/Pagination.vue"
-import {getUsers, routerBase} from "@/lib/api"
+import {getUsers, routerBase, searchUsers} from "@/lib/api"
 import {useRouteQuery} from '@vueuse/router'
+import {onKeyStroke, useDebounceFn} from "@vueuse/core"
 
 const route = useRoute()
 const userId = route.params.userId
@@ -15,15 +16,28 @@
    data: [],
 })
 const offset = useRouteQuery("offset", 0, {transform: Number})
-const limit = 24
+const limit = 22
 const error = ref(null)
 
-onMounted(() => init(offset.value))
+onMounted(() => init(offset.value, search.value))
+
+/////// SEARCH ////////////////////////////////////////////////////////////////
+
+const search = useRouteQuery("search", "",)// {transform: s => s.trim()})
+async function _doSearch (asearch) {
+   console.log("doSEarch", asearch)
+   // return init(0, asearch)
+   // TODO offset muss zurückgesetzt werden wenn die Suche neu ist
+   // search.value = asearch
+   return init(offset.value, asearch)
+}
+const doSearch = useDebounceFn(_doSearch, 333)
 
 /////////////////////////////////////////////////////////////////////////
 
-async function init (noffset = 0) {
-   const data = await getUsers(noffset, limit)
+async function init (noffset = 0, search) {
+   console.log(">>> INIT", noffset, search)
+   const data = await getUsers(noffset, limit, search)
    console.log(data)
    Object.assign(users, data)
    offset.value = noffset
@@ -31,8 +45,10 @@
 
 function go (offset) {
    console.log("go to offset", offset)
-   return init(offset)
+   return init(offset, search.value)
 }
+
+
 
 </script>
 
@@ -49,7 +65,16 @@
 
       <div class="users">
 
-         <Pagination :offset="users.offset" :limit="users.limit" :total="users.total" @go="go" />
+         <div class="users-header">
+            <div class="search">
+               Search
+               <input @keyup="doSearch(search)" v-model="search" type="text" size="30">
+               <button type="button" @click="_doSearch('')">
+                  <div style="transform:scale(1.4); font-weight: bold;">&times;</div>
+               </button>
+            </div>
+            <Pagination :offset="users.offset" :limit="users.limit" :total="users.total" :current="users.data.length" @go="go" />
+         </div>
 
          <table class="w100p">
             <thead>
@@ -88,6 +113,29 @@
 
 </template>
 
-<style scoped>
+<style scoped lang="stylus">
+
+.users-header
+   display flex;
+   align-items center
+   justify-content space-around
+   margin-bottom 1em;
+   margin-top -.5em;
+   border 1px dotted #ccc
+   background-color #eee;
+
+.search
+   display flex;
+   gap .33em
+   align-items center;
+   button
+      display flex;
+      //background-color blue
+      align-items stretch
+      display grid
+      grid-template-columns 1fr
+      padding 0
+      min-width 1.33em
+      cursor pointer;
 
 </style>

--
Gitblit v1.8.0