Make filters work on export csv action (#8389)
- Create a new component state `contextStoreFiltersComponentState` and refactor `contextStoreTargetedRecordsRuleComponentState` - Refactor `computeContextStoreFilters` to use filters when no records are selected
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import { contextStoreFiltersComponentState } from '@/context-store/states/contextStoreFiltersComponentState';
|
||||
import { contextStoreNumberOfSelectedRecordsComponentState } from '@/context-store/states/contextStoreNumberOfSelectedRecordsComponentState';
|
||||
import { contextStoreTargetedRecordsRuleComponentState } from '@/context-store/states/contextStoreTargetedRecordsRuleComponentState';
|
||||
import { computeContextStoreFilters } from '@/context-store/utils/computeContextStoreFilters';
|
||||
@ -35,6 +36,10 @@ export const RecordIndexContainerContextStoreNumberOfSelectedRecordsEffect =
|
||||
objectMetadataItem?.namePlural ?? '',
|
||||
);
|
||||
|
||||
const contextStoreFilters = useRecoilComponentValueV2(
|
||||
contextStoreFiltersComponentState,
|
||||
);
|
||||
|
||||
const { totalCount } = useFindManyRecords({
|
||||
...findManyRecordsParams,
|
||||
recordGqlFields: {
|
||||
@ -42,6 +47,7 @@ export const RecordIndexContainerContextStoreNumberOfSelectedRecordsEffect =
|
||||
},
|
||||
filter: computeContextStoreFilters(
|
||||
contextStoreTargetedRecordsRule,
|
||||
contextStoreFilters,
|
||||
objectMetadataItem,
|
||||
),
|
||||
limit: 1,
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { useContext, useEffect } from 'react';
|
||||
|
||||
import { contextStoreFiltersComponentState } from '@/context-store/states/contextStoreFiltersComponentState';
|
||||
import { contextStoreTargetedRecordsRuleComponentState } from '@/context-store/states/contextStoreTargetedRecordsRuleComponentState';
|
||||
import { useColumnDefinitionsFromFieldMetadata } from '@/object-metadata/hooks/useColumnDefinitionsFromFieldMetadata';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
@ -99,7 +100,6 @@ export const RecordIndexTableContainerEffect = () => {
|
||||
setContextStoreTargetedRecords({
|
||||
mode: 'exclusion',
|
||||
excludedRecordIds: unselectedRowIds,
|
||||
filters: recordIndexFilters,
|
||||
});
|
||||
} else {
|
||||
setContextStoreTargetedRecords({
|
||||
@ -116,11 +116,22 @@ export const RecordIndexTableContainerEffect = () => {
|
||||
};
|
||||
}, [
|
||||
hasUserSelectedAllRows,
|
||||
recordIndexFilters,
|
||||
selectedRowIds,
|
||||
setContextStoreTargetedRecords,
|
||||
unselectedRowIds,
|
||||
]);
|
||||
|
||||
const setContextStoreFilters = useSetRecoilComponentStateV2(
|
||||
contextStoreFiltersComponentState,
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
setContextStoreFilters(recordIndexFilters);
|
||||
|
||||
return () => {
|
||||
setContextStoreFilters([]);
|
||||
};
|
||||
}, [recordIndexFilters, setContextStoreFilters]);
|
||||
|
||||
return <></>;
|
||||
};
|
||||
|
||||
@ -106,7 +106,7 @@ const mocks: MockedResponse[] = [
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
filter: undefined,
|
||||
filter: {},
|
||||
limit: 30,
|
||||
orderBy: [{ position: 'AscNullsFirst' }],
|
||||
},
|
||||
|
||||
@ -6,6 +6,7 @@ import { ColumnDefinition } from '@/object-record/record-table/types/ColumnDefin
|
||||
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
import { contextStoreFiltersComponentState } from '@/context-store/states/contextStoreFiltersComponentState';
|
||||
import { contextStoreTargetedRecordsRuleComponentState } from '@/context-store/states/contextStoreTargetedRecordsRuleComponentState';
|
||||
import { computeContextStoreFilters } from '@/context-store/utils/computeContextStoreFilters';
|
||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
@ -81,8 +82,13 @@ export const useRecordData = ({
|
||||
contextStoreTargetedRecordsRuleComponentState,
|
||||
);
|
||||
|
||||
const contextStoreFilters = useRecoilComponentValueV2(
|
||||
contextStoreFiltersComponentState,
|
||||
);
|
||||
|
||||
const queryFilter = computeContextStoreFilters(
|
||||
contextStoreTargetedRecordsRule,
|
||||
contextStoreFilters,
|
||||
objectMetadataItem,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user