2357 Refactor RecordTable to use the new scope architecture (#2407)
* create RecordTableScope * use RecordTableScope * working on useRecordTable hook * add RecordTableScope to company-table * add RecordTableScope to person-table * add filter state and sort state * add useSetRecordTableData to useRecordTable * wip * add setRecordTableData to useRecordTable * update in RecordTableEffect * fix bug * getting rid of unnecessary context and hooks * remove console.log * wip * fix bug by creating an init effect * fix viewbar not in scope in company and people tables * wip * updating useRecordTable to use internal hooks * updating useRecordTable to use internal hooks * updating useRecordTable to use internal hooks * updating useRecordTable to use internal hooks * modified according to comments
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId';
|
||||
|
||||
import { ObjectMetadataItemScopeInternalContext } from '../scopes/scope-internal-context/ObjectMetadataItemScopeInternalContext';
|
||||
|
||||
type UseObjectMetadataItemProps = {
|
||||
objectMetadataItemNamePlural?: string;
|
||||
};
|
||||
|
||||
export const useObjectMetadataItem = (props?: UseObjectMetadataItemProps) => {
|
||||
const scopeId = useAvailableScopeIdOrThrow(
|
||||
ObjectMetadataItemScopeInternalContext,
|
||||
props?.objectMetadataItemNamePlural,
|
||||
);
|
||||
|
||||
return {
|
||||
scopeId,
|
||||
};
|
||||
};
|
||||
@@ -1,34 +0,0 @@
|
||||
import { useContext } from 'react';
|
||||
|
||||
import { ObjectMetadataItemScopeInternalContext } from '../scopes/scope-internal-context/ObjectMetadataItemScopeInternalContext';
|
||||
|
||||
import { useFindOneObjectMetadataItem } from './useFindOneObjectMetadataItem';
|
||||
|
||||
export const useObjectMetadataItemInContext = () => {
|
||||
const context = useContext(ObjectMetadataItemScopeInternalContext);
|
||||
|
||||
if (!context) {
|
||||
throw new Error(
|
||||
'Could not find ObjectMetadataItemScopeInternalContext while in useObjectMetadataItemInContext',
|
||||
);
|
||||
}
|
||||
|
||||
const {
|
||||
foundObjectMetadataItem,
|
||||
loading,
|
||||
columnDefinitions,
|
||||
filterDefinitions,
|
||||
sortDefinitions,
|
||||
} = useFindOneObjectMetadataItem({
|
||||
objectNamePlural: context.objectNamePlural,
|
||||
});
|
||||
|
||||
return {
|
||||
...context,
|
||||
foundObjectMetadataItem,
|
||||
loading,
|
||||
columnDefinitions,
|
||||
filterDefinitions,
|
||||
sortDefinitions,
|
||||
};
|
||||
};
|
||||
+3
-3
@@ -1,14 +1,14 @@
|
||||
import { useRecoilCallback } from 'recoil';
|
||||
|
||||
import { entityFieldsFamilyState } from '@/ui/object/field/states/entityFieldsFamilyState';
|
||||
import { useResetTableRowSelection } from '@/ui/object/record-table/hooks/useResetTableRowSelection';
|
||||
import { useRecordTable } from '@/ui/object/record-table/hooks/useRecordTable';
|
||||
import { isFetchingRecordTableDataState } from '@/ui/object/record-table/states/isFetchingRecordTableDataState';
|
||||
import { numberOfTableRowsState } from '@/ui/object/record-table/states/numberOfTableRowsState';
|
||||
import { tableRowIdsState } from '@/ui/object/record-table/states/tableRowIdsState';
|
||||
import { useView } from '@/views/hooks/useView';
|
||||
|
||||
export const useSetObjectRecordTableData = () => {
|
||||
const resetTableRowSelection = useResetTableRowSelection();
|
||||
export const useSetRecordTableData = () => {
|
||||
const { resetTableRowSelection } = useRecordTable();
|
||||
const { setEntityCountInCurrentView } = useView();
|
||||
|
||||
return useRecoilCallback(
|
||||
Reference in New Issue
Block a user