From 949c96f9a8267ea5a155253333becb03f44547b1 Mon Sep 17 00:00:00 2001 From: Bilal MEDDAH Date: Wed, 9 Aug 2023 18:47:48 +0200 Subject: [PATCH] f-4140/update: enable type operator in type filter in mydata page --- src/shared/canvas/MyData/MyData.tsx | 5 +++ src/shared/canvas/MyData/types.ts | 3 +- .../molecules/MyDataHeader/MyDataHeader.tsx | 2 + .../MyDataHeaderFilters/index.tsx | 2 + .../molecules/TypeSelector/TypeSelector.tsx | 41 ++++++++++++++----- src/shared/molecules/TypeSelector/style.less | 8 ++++ src/shared/molecules/TypeSelector/types.ts | 6 ++- 7 files changed, 55 insertions(+), 12 deletions(-) diff --git a/src/shared/canvas/MyData/MyData.tsx b/src/shared/canvas/MyData/MyData.tsx index 5ca77d179..5e63c902a 100644 --- a/src/shared/canvas/MyData/MyData.tsx +++ b/src/shared/canvas/MyData/MyData.tsx @@ -31,6 +31,7 @@ const HomeMyData: React.FC<{}> = () => { locate, issuer, types, + typeOperator, }, setFilterOptions, ] = React.useReducer( @@ -51,6 +52,7 @@ const HomeMyData: React.FC<{}> = () => { locate: false, issuer: 'createdBy', types: [], + typeOperator: 'OR', } ); @@ -88,6 +90,7 @@ const HomeMyData: React.FC<{}> = () => { issuer, date, order, + typeOperator, types: resourceTypes, }, ], @@ -95,6 +98,7 @@ const HomeMyData: React.FC<{}> = () => { queryFn: () => nexus.Resource.list(undefined, undefined, { size, + typeOperator, from: offset, [issuer]: issuerUri, ...(locate && query.trim().length @@ -144,6 +148,7 @@ const HomeMyData: React.FC<{}> = () => { locate, issuer, setFilterOptions, + typeOperator, }} /> ; export type THeaderTitleProps = Pick< THeaderProps, diff --git a/src/shared/molecules/MyDataHeader/MyDataHeader.tsx b/src/shared/molecules/MyDataHeader/MyDataHeader.tsx index a44bb5086..10daedae5 100644 --- a/src/shared/molecules/MyDataHeader/MyDataHeader.tsx +++ b/src/shared/molecules/MyDataHeader/MyDataHeader.tsx @@ -11,6 +11,7 @@ const MyDataHeader: React.FC = ({ setFilterOptions, locate, issuer, + typeOperator, }) => { return (
@@ -32,6 +33,7 @@ const MyDataHeader: React.FC = ({ locate, setFilterOptions, issuer, + typeOperator, }} />
diff --git a/src/shared/molecules/MyDataHeader/MyDataHeaderFilters/index.tsx b/src/shared/molecules/MyDataHeader/MyDataHeaderFilters/index.tsx index ef9122f8d..74bbe79e1 100644 --- a/src/shared/molecules/MyDataHeader/MyDataHeaderFilters/index.tsx +++ b/src/shared/molecules/MyDataHeader/MyDataHeaderFilters/index.tsx @@ -36,6 +36,7 @@ const MyDataHeaderTitle = ({ const MyDataHeaderFilters = ({ types, + typeOperator, dateField, setFilterOptions, }: THeaderFilterProps) => { @@ -47,6 +48,7 @@ const MyDataHeaderFilters = ({ item.value === type.value) - ? [] - : [type]; + ? types.filter((item: TType) => item.value !== type.value) + : [...(types ? types : []), type]; updateOptions({ types: newTypes, }); afterUpdate?.(newTypes); }; const renderedTypes = typeSearchValue ? typesOptionsArray : typeOptions ?? []; - + const onTypeOperatorChange = ({ target: { value } }: RadioChangeEvent) => { + updateOptions({ + typeOperator: value, + }); + }; return (
@@ -197,12 +215,15 @@ const TypeSelector = ({ aria-label="type-filter" dropdownRender={() => ( <> -
- - - AND - OR - +
+
Select Type Operator
+
void; + typeOperator?: 'AND' | 'OR'; + updateOptions(options: { + types?: TType[]; + typeOperator?: 'AND' | 'OR'; + }): void; afterUpdate?: (types?: TType[]) => void; };