From 57c829d698d3edb3778a77c6d23cc3739d0152b4 Mon Sep 17 00:00:00 2001 From: peoray Date: Tue, 12 Sep 2023 15:02:53 +0100 Subject: [PATCH 1/5] Add email option to members identities filter list --- .../src/modules/member/config/filters/identities/config.ts | 4 ++++ frontend/src/modules/member/config/filters/main.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/modules/member/config/filters/identities/config.ts b/frontend/src/modules/member/config/filters/identities/config.ts index c0cb53ec2f..f1b15be270 100644 --- a/frontend/src/modules/member/config/filters/identities/config.ts +++ b/frontend/src/modules/member/config/filters/identities/config.ts @@ -21,6 +21,10 @@ const identities: MultiSelectFilterConfig = { label: (platform as any).name, value: platform.platform, }))), + { + label: 'Email', + value: 'email', + }, ], }, ], diff --git a/frontend/src/modules/member/config/filters/main.ts b/frontend/src/modules/member/config/filters/main.ts index df279f9aeb..c5237b9294 100644 --- a/frontend/src/modules/member/config/filters/main.ts +++ b/frontend/src/modules/member/config/filters/main.ts @@ -33,7 +33,7 @@ export const memberFilters: Record = { }; export const memberSearchFilter: SearchFilterConfig = { - placeholder: 'Search members', + placeholder: 'Search member\'s name or email', apiFilterRenderer(value: string): any[] { return [ { From 51f24eebbcb10d0474fc2799532c29bc18db689a Mon Sep 17 00:00:00 2001 From: peoray Date: Tue, 26 Sep 2023 13:53:33 +0100 Subject: [PATCH 2/5] Refactor apiFilterRenderer for identities in member list filters --- .../member/config/filters/identities/config.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/frontend/src/modules/member/config/filters/identities/config.ts b/frontend/src/modules/member/config/filters/identities/config.ts index f1b15be270..b607a851f9 100644 --- a/frontend/src/modules/member/config/filters/identities/config.ts +++ b/frontend/src/modules/member/config/filters/identities/config.ts @@ -32,8 +32,19 @@ const identities: MultiSelectFilterConfig = { itemLabelRenderer(value: MultiSelectFilterValue, options: MultiSelectFilterOptions): string { return itemLabelRendererByType[FilterConfigType.MULTISELECT]('Identities', value, options); }, - apiFilterRenderer(value: MultiSelectFilterValue): any[] { - return apiFilterRendererByType[FilterConfigType.MULTISELECT]('identities', value); + apiFilterRenderer({ value, include }: MultiSelectFilterValue): any[] { + const filter = { + or: value.map((identity) => ({ + + identities: { eq: identity }, + email: { + ne: null, + }, + })), + }; + return [ + (include ? filter : { not: filter }), + ]; }, }; From 7b002e66edf8ad647ef5d6b95d67a4b0e9c595a9 Mon Sep 17 00:00:00 2001 From: peoray Date: Mon, 9 Oct 2023 10:26:42 +0100 Subject: [PATCH 3/5] Updated filter logic for identity filter option in members --- .../config/filters/identities/config.ts | 55 +++++++++++++++---- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/frontend/src/modules/member/config/filters/identities/config.ts b/frontend/src/modules/member/config/filters/identities/config.ts index b607a851f9..d4854a319e 100644 --- a/frontend/src/modules/member/config/filters/identities/config.ts +++ b/frontend/src/modules/member/config/filters/identities/config.ts @@ -17,14 +17,14 @@ const identities: MultiSelectFilterConfig = { options: [ { options: [ + { + label: 'Email', + value: 'emails', + }, ...(CrowdIntegrations.enabledConfigs.map((platform) => ({ label: (platform as any).name, value: platform.platform, }))), - { - label: 'Email', - value: 'email', - }, ], }, ], @@ -33,15 +33,46 @@ const identities: MultiSelectFilterConfig = { return itemLabelRendererByType[FilterConfigType.MULTISELECT]('Identities', value, options); }, apiFilterRenderer({ value, include }: MultiSelectFilterValue): any[] { - const filter = { - or: value.map((identity) => ({ + const platformIdentities = value.filter((identity) => identity !== 'emails'); + + const emailFilter = value.filter((identity) => identity === 'emails'); + + // Initialize an empty filter + let filter = {}; + + // Handle the conditions + if (platformIdentities.length > 0 && emailFilter.length === 0) { + console.log('ONLY PLATFORMS RANNN!!!!'); + // Only platforms selected + filter = { + or: platformIdentities.map((identity) => ({ + identities: { eq: identity }, + })), + }; + } else if (platformIdentities.length === 0 && emailFilter.length > 0) { + // Only emails selected + console.log('ONLY EMAILSSS RANNN!!!!'); + filter = { + emails: { ne: null }, + }; + } else if (platformIdentities.length > 0 && emailFilter.length > 0) { + console.log('BOTH RANNN!!!!'); + // Both platforms and emails selected + filter = { + // [ + or: [ + { + or: + platformIdentities.map((identity) => ({ + identities: { eq: identity }, + })), + }, + + { emails: { ne: null } }, + ], + }; + } - identities: { eq: identity }, - email: { - ne: null, - }, - })), - }; return [ (include ? filter : { not: filter }), ]; From 2bf316679969d3620a3acdf06fec38337af0ca8a Mon Sep 17 00:00:00 2001 From: peoray Date: Thu, 19 Oct 2023 21:09:11 +0100 Subject: [PATCH 4/5] Remove console logs --- .../src/modules/member/config/filters/identities/config.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/frontend/src/modules/member/config/filters/identities/config.ts b/frontend/src/modules/member/config/filters/identities/config.ts index d4854a319e..96eb3abefe 100644 --- a/frontend/src/modules/member/config/filters/identities/config.ts +++ b/frontend/src/modules/member/config/filters/identities/config.ts @@ -42,7 +42,6 @@ const identities: MultiSelectFilterConfig = { // Handle the conditions if (platformIdentities.length > 0 && emailFilter.length === 0) { - console.log('ONLY PLATFORMS RANNN!!!!'); // Only platforms selected filter = { or: platformIdentities.map((identity) => ({ @@ -51,12 +50,10 @@ const identities: MultiSelectFilterConfig = { }; } else if (platformIdentities.length === 0 && emailFilter.length > 0) { // Only emails selected - console.log('ONLY EMAILSSS RANNN!!!!'); filter = { emails: { ne: null }, }; } else if (platformIdentities.length > 0 && emailFilter.length > 0) { - console.log('BOTH RANNN!!!!'); // Both platforms and emails selected filter = { // [ From 817a7f09400c1ed6956e2c3963aab96d4fceaa60 Mon Sep 17 00:00:00 2001 From: peoray Date: Thu, 26 Oct 2023 21:51:25 +0100 Subject: [PATCH 5/5] Fix lint issue --- frontend/src/modules/member/config/filters/identities/config.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/modules/member/config/filters/identities/config.ts b/frontend/src/modules/member/config/filters/identities/config.ts index 96eb3abefe..5276ed5451 100644 --- a/frontend/src/modules/member/config/filters/identities/config.ts +++ b/frontend/src/modules/member/config/filters/identities/config.ts @@ -6,7 +6,6 @@ import { } from '@/shared/modules/filters/types/filterTypes/MultiSelectFilterConfig'; import { CrowdIntegrations } from '@/integrations/integrations-config'; import { itemLabelRendererByType } from '@/shared/modules/filters/config/itemLabelRendererByType'; -import { apiFilterRendererByType } from '@/shared/modules/filters/config/apiFilterRendererByType'; const identities: MultiSelectFilterConfig = { id: 'identities',