-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix record board export not taking filters into account (#8505)
Fix Export CSV action not taking into account the filters applied on the Kanban index view
- Loading branch information
1 parent
a799370
commit 5384b4a
Showing
11 changed files
with
110 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
.../modules/object-record/record-index/components/RecordIndexFiltersToContextStoreEffect.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { useContext, useEffect } from 'react'; | ||
|
||
import { contextStoreFiltersComponentState } from '@/context-store/states/contextStoreFiltersComponentState'; | ||
import { contextStoreTargetedRecordsRuleComponentState } from '@/context-store/states/contextStoreTargetedRecordsRuleComponentState'; | ||
import { RecordIndexRootPropsContext } from '@/object-record/record-index/contexts/RecordIndexRootPropsContext'; | ||
import { recordIndexFiltersState } from '@/object-record/record-index/states/recordIndexFiltersState'; | ||
import { hasUserSelectedAllRowsComponentState } from '@/object-record/record-table/record-table-row/states/hasUserSelectedAllRowsFamilyState'; | ||
import { selectedRowIdsComponentSelector } from '@/object-record/record-table/states/selectors/selectedRowIdsComponentSelector'; | ||
import { unselectedRowIdsComponentSelector } from '@/object-record/record-table/states/selectors/unselectedRowIdsComponentSelector'; | ||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2'; | ||
import { useSetRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useSetRecoilComponentStateV2'; | ||
import { useRecoilValue } from 'recoil'; | ||
|
||
export const RecordIndexFiltersToContextStoreEffect = () => { | ||
const { recordIndexId } = useContext(RecordIndexRootPropsContext); | ||
|
||
const recordIndexFilters = useRecoilValue(recordIndexFiltersState); | ||
|
||
const setContextStoreTargetedRecords = useSetRecoilComponentStateV2( | ||
contextStoreTargetedRecordsRuleComponentState, | ||
); | ||
|
||
const hasUserSelectedAllRows = useRecoilComponentValueV2( | ||
hasUserSelectedAllRowsComponentState, | ||
recordIndexId, | ||
); | ||
|
||
const selectedRowIds = useRecoilComponentValueV2( | ||
selectedRowIdsComponentSelector, | ||
recordIndexId, | ||
); | ||
const unselectedRowIds = useRecoilComponentValueV2( | ||
unselectedRowIdsComponentSelector, | ||
recordIndexId, | ||
); | ||
|
||
useEffect(() => { | ||
if (hasUserSelectedAllRows) { | ||
setContextStoreTargetedRecords({ | ||
mode: 'exclusion', | ||
excludedRecordIds: unselectedRowIds, | ||
}); | ||
} else { | ||
setContextStoreTargetedRecords({ | ||
mode: 'selection', | ||
selectedRecordIds: selectedRowIds, | ||
}); | ||
} | ||
|
||
return () => { | ||
setContextStoreTargetedRecords({ | ||
mode: 'selection', | ||
selectedRecordIds: [], | ||
}); | ||
}; | ||
}, [ | ||
hasUserSelectedAllRows, | ||
selectedRowIds, | ||
setContextStoreTargetedRecords, | ||
unselectedRowIds, | ||
]); | ||
|
||
const setContextStoreFilters = useSetRecoilComponentStateV2( | ||
contextStoreFiltersComponentState, | ||
); | ||
|
||
useEffect(() => { | ||
setContextStoreFilters(recordIndexFilters); | ||
|
||
return () => { | ||
setContextStoreFilters([]); | ||
}; | ||
}, [recordIndexFilters, setContextStoreFilters]); | ||
|
||
return <></>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters