From f3df5d4159a1f4f4ac37a5e967866bb4b6b770b6 Mon Sep 17 00:00:00 2001 From: tm-sanjay Date: Sun, 8 Jan 2023 15:22:06 +0530 Subject: [PATCH] search and page filter combined --- .gitignore | 3 ++- src/www/index.html | 25 ++++++++++++++++++++++++- src/www/js/app.js | 35 ++++++++++++++++++++++++++++++++--- 3 files changed, 58 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 77574b5e..afb9df7b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /config /wg0.conf -/wg0.json \ No newline at end of file +/wg0.json +/create config \ No newline at end of file diff --git a/src/www/index.html b/src/www/index.html index 34177ffc..c8945faa 100644 --- a/src/www/index.html +++ b/src/www/index.html @@ -79,7 +79,7 @@
-
@@ -527,7 +527,30 @@
+ +
+
+ + +
+
+ + +
+

Made by { if (!this.search) return true; + // Reset page number if search changed + if (this.search !== this.searchPrevious) { + this.pageNumber = 0; + this.searchPrevious = this.search; + } const search = this.search.toLowerCase(); - return client.name.toLowerCase().includes(search) - || client.address.toLowerCase().includes(search) - || client.id.toLowerCase().includes(search); + return client.name.toLowerCase().includes(search); }); + }, + + currentPage() { + if (!this.filteredClients) return null; + + this.canGoToNextPage = this.pageNumber+1 < this.filteredClients.length / this.prepage; + return this.filteredClients.slice(this.pageNumber * this.prepage, this.pageNumber * this.prepage + this.prepage); } + }, methods: { + nextPage() { + if (this.pageNumber < this.clients.length / this.prepage) { + this.pageNumber++; + } + }, + + previousPage() { + if (this.pageNumber > 0) { + this.pageNumber--; + } + }, + dateTime: value => { return new Intl.DateTimeFormat(undefined, { year: 'numeric',