Skip to content

Commit 67373e9

Browse files
authored
fix: [Assets] Filters do not work for Updated Time and Size columns (Issue #2348) (#533)
1 parent 6508500 commit 67373e9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/constants/file-grid-columns.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ import { BASE_FILE_MANAGER_ICON_SIZE } from '@/components/FileManager/constants'
1313
import type { FileManagerGridContext } from '@/components/FileManager/hooks/use-file-manager-columns';
1414
import { formatBytes } from '@/components/FileManager/utils';
1515
import type { ColDef } from 'ag-grid-community';
16+
import { convertToDate } from '@/components/Grid/renderers/utils';
17+
import {
18+
DEFAULT_DATE_FORMAT_OPTIONS,
19+
DEFAULT_LOCALE,
20+
} from '@/components/Grid/renderers/constants';
1621

1722
type GridRow = FileManagerGridRow;
1823

@@ -163,6 +168,18 @@ export const UPDATED_AT_COLUMN =
163168
locale: dateLocale,
164169
options: dateOptions,
165170
},
171+
filterValueGetter: (params) => {
172+
const value = params.data[params.colDef.field || ''];
173+
const date = convertToDate(value);
174+
if (!date) return '';
175+
176+
const formatted = new Intl.DateTimeFormat(
177+
dateLocale || DEFAULT_LOCALE,
178+
dateOptions || DEFAULT_DATE_FORMAT_OPTIONS,
179+
);
180+
181+
return formatted.format(date);
182+
},
166183
});
167184

168185
export const SIZE_COLUMN = (headerName: string): ColDef => ({
@@ -176,4 +193,9 @@ export const SIZE_COLUMN = (headerName: string): ColDef => ({
176193
? formatBytes(params.data.contentLength)
177194
: '';
178195
},
196+
filterValueGetter: (params) => {
197+
return params.data.nodeType === DialFileNodeType.ITEM
198+
? formatBytes(params.data.contentLength)
199+
: '';
200+
},
179201
});

0 commit comments

Comments
 (0)