From bd428fef1b89d000a278b149d84969237cf93d7d Mon Sep 17 00:00:00 2001 From: NoelKova Date: Fri, 2 Aug 2024 07:26:18 +0200 Subject: [PATCH 1/2] search_unsortable_columns --- .../components/content-list/content-list.tsx | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/apps/sensenet/src/components/content-list/content-list.tsx b/apps/sensenet/src/components/content-list/content-list.tsx index 2f1e7d5d7..b01ef4118 100644 --- a/apps/sensenet/src/components/content-list/content-list.tsx +++ b/apps/sensenet/src/components/content-list/content-list.tsx @@ -669,6 +669,7 @@ export const ContentList = (props: Co } const displayNameInArray = ['DisplayName'] + const sortableColumns = ['DisplayName', 'Path', 'Type', 'Name', 'Version', 'CreationDate', 'ModificationDate'] return (
@@ -715,11 +716,24 @@ export const ContentList = (props: Co getSelectionControl={getSelectionControl} /* If the Order by Column Is The Display. The client will sort it. Due to some locale and indexing issues */ items={ - currentOrder === 'DisplayName' + sortableColumns.includes(String(currentOrder)) ? children?.sort((a, b) => { // If no display Name - const nameA = a?.DisplayName ?? '' // Provide a default value if displayName is undefined - const nameB = b?.DisplayName ?? '' // Provide a default value if displayName is undefined + const nameA = String(a[currentOrder]) ?? '' // Provide a default value if displayName is undefined + const nameB = String(b[currentOrder]) ?? '' // Provide a default value if displayName is undefined + + if (currentDirection === 'asc') { + return nameA.localeCompare(nameB) + } + return nameB.localeCompare(nameA) + }) + : currentOrder === 'CreatedBy' || currentOrder === 'ModifiedBy' + ? children?.sort((a, b) => { + const aTmp = a[currentOrder] as any + const bTmp = b[currentOrder] as any + + const nameA = String(aTmp?.DisplayName) ?? '' + const nameB = String(bTmp?.DisplayName) ?? '' if (currentDirection === 'asc') { return nameA.localeCompare(nameB) From a4000cedc3b02512a5a34fc712cb5483a6a8f2a8 Mon Sep 17 00:00:00 2001 From: NoelKova Date: Fri, 2 Aug 2024 07:30:31 +0200 Subject: [PATCH 2/2] remove any --- apps/sensenet/src/components/content-list/content-list.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/sensenet/src/components/content-list/content-list.tsx b/apps/sensenet/src/components/content-list/content-list.tsx index b01ef4118..8e136569f 100644 --- a/apps/sensenet/src/components/content-list/content-list.tsx +++ b/apps/sensenet/src/components/content-list/content-list.tsx @@ -729,8 +729,8 @@ export const ContentList = (props: Co }) : currentOrder === 'CreatedBy' || currentOrder === 'ModifiedBy' ? children?.sort((a, b) => { - const aTmp = a[currentOrder] as any - const bTmp = b[currentOrder] as any + const aTmp = a[currentOrder] as GenericContent + const bTmp = b[currentOrder] as GenericContent const nameA = String(aTmp?.DisplayName) ?? '' const nameB = String(bTmp?.DisplayName) ?? ''