From 5c5f1ebc9c20a8c53f4e5f88a2359fcc36d4b7a3 Mon Sep 17 00:00:00 2001 From: einhorn_b Date: Fri, 11 Aug 2023 20:24:43 +0200 Subject: [PATCH 1/6] add memo search to find function, update placeholder in admin --- admin/src/components/UserQuery.vue | 2 +- admin/src/locales/de.json | 3 ++- admin/src/locales/en.json | 3 ++- .../src/graphql/resolver/util/findContributions.ts | 12 ++++++++++-- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/admin/src/components/UserQuery.vue b/admin/src/components/UserQuery.vue index 2a31a8dea..8e28c1c0c 100644 --- a/admin/src/components/UserQuery.vue +++ b/admin/src/components/UserQuery.vue @@ -5,7 +5,7 @@ type="text" class="test-input-criteria" v-model="currentValue" - :placeholder="$t('user_search')" + :placeholder="$t('user_memo_search')" > diff --git a/admin/src/locales/de.json b/admin/src/locales/de.json index d4209ce83..fd7eae320 100644 --- a/admin/src/locales/de.json +++ b/admin/src/locales/de.json @@ -217,5 +217,6 @@ }, "user_deleted": "Nutzer ist gelöscht.", "user_recovered": "Nutzer ist wiederhergestellt.", - "user_search": "Nutzer-Suche" + "user_search": "Nutzer-Suche", + "user_memo_search": "Nutzer-Kommentar-Suche" } diff --git a/admin/src/locales/en.json b/admin/src/locales/en.json index 35aacfa69..b501a521f 100644 --- a/admin/src/locales/en.json +++ b/admin/src/locales/en.json @@ -217,5 +217,6 @@ }, "user_deleted": "User is deleted.", "user_recovered": "User is recovered.", - "user_search": "User search" + "user_search": "User search", + "user_memo_search": "User and Memo search" } diff --git a/backend/src/graphql/resolver/util/findContributions.ts b/backend/src/graphql/resolver/util/findContributions.ts index b35d75b6b..762f9ace0 100644 --- a/backend/src/graphql/resolver/util/findContributions.ts +++ b/backend/src/graphql/resolver/util/findContributions.ts @@ -33,8 +33,8 @@ export const findContributions = async ( ...(statusFilter?.length && { contributionStatus: In(statusFilter) }), ...(userId && { userId }), } - - const where = + + let where = query && relations?.user ? [ { @@ -57,8 +57,16 @@ export const findContributions = async ( }, }, }, + { + ...requiredWhere, + memo: Like(`%${query}%`) + }, ] : requiredWhere + + if (!relations?.user && query) { + where = [{...requiredWhere, memo: Like(`%${query}%`)}] + } return DbContribution.findAndCount({ relations, From ae7c8601e550403669dba53dbc19224a9bd32287 Mon Sep 17 00:00:00 2001 From: einhorn_b Date: Fri, 11 Aug 2023 20:30:10 +0200 Subject: [PATCH 2/6] fix lint --- backend/src/graphql/resolver/util/findContributions.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/graphql/resolver/util/findContributions.ts b/backend/src/graphql/resolver/util/findContributions.ts index 762f9ace0..ab504b37c 100644 --- a/backend/src/graphql/resolver/util/findContributions.ts +++ b/backend/src/graphql/resolver/util/findContributions.ts @@ -33,7 +33,7 @@ export const findContributions = async ( ...(statusFilter?.length && { contributionStatus: In(statusFilter) }), ...(userId && { userId }), } - + let where = query && relations?.user ? [ @@ -59,13 +59,13 @@ export const findContributions = async ( }, { ...requiredWhere, - memo: Like(`%${query}%`) + memo: Like(`%${query}%`), }, ] : requiredWhere - + if (!relations?.user && query) { - where = [{...requiredWhere, memo: Like(`%${query}%`)}] + where = [{ ...requiredWhere, memo: Like(`%${query}%`) }] } return DbContribution.findAndCount({ From fe0b44132840c0d1836bc556a9c1bc6c5365d261 Mon Sep 17 00:00:00 2001 From: einhorn_b Date: Fri, 11 Aug 2023 20:42:31 +0200 Subject: [PATCH 3/6] sort locales by key --- admin/src/locales/de.json | 4 ++-- admin/src/locales/en.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/admin/src/locales/de.json b/admin/src/locales/de.json index fd7eae320..d4d9df095 100644 --- a/admin/src/locales/de.json +++ b/admin/src/locales/de.json @@ -216,7 +216,7 @@ "tabTitle": "Nutzer-Rolle" }, "user_deleted": "Nutzer ist gelöscht.", + "user_memo_search": "Nutzer-Kommentar-Suche", "user_recovered": "Nutzer ist wiederhergestellt.", - "user_search": "Nutzer-Suche", - "user_memo_search": "Nutzer-Kommentar-Suche" + "user_search": "Nutzer-Suche" } diff --git a/admin/src/locales/en.json b/admin/src/locales/en.json index b501a521f..40ef718cf 100644 --- a/admin/src/locales/en.json +++ b/admin/src/locales/en.json @@ -216,7 +216,7 @@ "tabTitle": "User Role" }, "user_deleted": "User is deleted.", + "user_memo_search": "User and Memo search", "user_recovered": "User is recovered.", - "user_search": "User search", - "user_memo_search": "User and Memo search" + "user_search": "User search" } From dc7a8bb9c79c7c6377d13eac85f235fdec3db28c Mon Sep 17 00:00:00 2001 From: einhorn_b Date: Sat, 12 Aug 2023 09:59:21 +0200 Subject: [PATCH 4/6] parameterized placeholder in user search query --- admin/src/components/UserQuery.vue | 8 +++++++- admin/src/pages/CreationConfirm.vue | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/admin/src/components/UserQuery.vue b/admin/src/components/UserQuery.vue index 8e28c1c0c..3827ef285 100644 --- a/admin/src/components/UserQuery.vue +++ b/admin/src/components/UserQuery.vue @@ -5,7 +5,7 @@ type="text" class="test-input-criteria" v-model="currentValue" - :placeholder="$t('user_memo_search')" + :placeholder="placeholderText" > @@ -20,12 +20,18 @@ export default { name: 'UserQuery', props: { value: { type: String, default: '' }, + placeholder: { type: String, default: '' }, }, data() { return { currentValue: this.value, } }, + computed: { + placeholderText() { + return this.placeholder || this.$t('user_search') + } + }, watch: { currentValue() { if (this.value !== this.currentValue) { diff --git a/admin/src/pages/CreationConfirm.vue b/admin/src/pages/CreationConfirm.vue index 34458e0aa..8ffbbaf9e 100644 --- a/admin/src/pages/CreationConfirm.vue +++ b/admin/src/pages/CreationConfirm.vue @@ -1,7 +1,7 @@