From aedf54deb436884eb45eac64dbbdaf663f66d65d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20Jedlicska?= Date: Tue, 23 Nov 2021 14:55:21 +0100 Subject: [PATCH] refactor(frontend, server): backport stream admin route handling solution to user admin --- .../frontend/src/views/admin/AdminUsers.vue | 29 ++++++++++++------- .../modules/core/graph/schemas/user.graphql | 2 +- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/packages/frontend/src/views/admin/AdminUsers.vue b/packages/frontend/src/views/admin/AdminUsers.vue index ae7fd839e..40228b807 100644 --- a/packages/frontend/src/views/admin/AdminUsers.vue +++ b/packages/frontend/src/views/admin/AdminUsers.vue @@ -141,8 +141,8 @@ export default { items: [], totalCount: 0 }, - currentPage: 1, - searchQuery: null, + // currentPage: 1, + // searchQuery: null, showConfirmDialog: false, showDeleteDialog: false, manipulatedUser: null, @@ -153,6 +153,22 @@ export default { queryLimit() { return parseInt(this.limit) }, + currentPage: { + get() { + return parseInt(this.page) + }, + set(newPage) { + this.paginateNext(newPage) + } + }, + searchQuery: { + get() { + return this.q + }, + set: debounce(function (q) { + this.applySearch(q) + }, 500) + }, queryOffset() { return (this.page - 1) * this.queryLimit }, @@ -167,21 +183,12 @@ export default { return roleItems } }, - watch: { - currentPage: function (newPage) { - this.paginateNext(newPage) - }, - searchQuery: debounce(function (newQuery) { - this.applySearch(newQuery) - }, 1000) - }, methods: { initiateDeleteUser(user) { this.showDeleteDialog = true this.manipulatedUser = user }, async deleteUser(user) { - console.log('deleting', user.email) await this.$apollo.mutate({ mutation: gql` mutation($userEmail: String!) { diff --git a/packages/server/modules/core/graph/schemas/user.graphql b/packages/server/modules/core/graph/schemas/user.graphql index 74d78ac7c..121bb7706 100644 --- a/packages/server/modules/core/graph/schemas/user.graphql +++ b/packages/server/modules/core/graph/schemas/user.graphql @@ -7,7 +7,7 @@ extend type Query { """ Get users from the server in a paginated view. The query search for matches in name, company and email. """ - users(limit: Int!=25, offset: Int!=0, query: String=null) : UserCollection + users(limit: Int! = 25, offset: Int! = 0, query: String=null) : UserCollection userSearch( query: String! limit: Int! = 25