Introduce main identifier to power RelationFieldDisplay (#2577)
* Introduce main identifier to power RelationFieldDisplay, FilterDrodown, TableFirstColumn * Apply to RelationPicker
This commit is contained in:
@@ -165,11 +165,11 @@ export const RecordShowPage = () => {
|
||||
value={{
|
||||
entityId: object.id,
|
||||
recoilScopeId: object.id + metadataField.id,
|
||||
isMainIdentifier: false,
|
||||
fieldDefinition:
|
||||
formatFieldMetadataItemAsColumnDefinition({
|
||||
field: metadataField,
|
||||
position: index,
|
||||
objectMetadataItem: foundObjectMetadataItem,
|
||||
}),
|
||||
useUpdateEntityMutation: useUpdateOneObjectMutation,
|
||||
hotkeyScope: InlineCellHotkeyScope.InlineCell,
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useEffect } from 'react';
|
||||
|
||||
import { useComputeDefinitionsFromFieldMetadata } from '@/object-metadata/hooks/useComputeDefinitionsFromFieldMetadata';
|
||||
import { useFindOneObjectMetadataItem } from '@/object-metadata/hooks/useFindOneObjectMetadataItem';
|
||||
import { useObjectMainIdentifier } from '@/object-metadata/hooks/useObjectMainIdentifier';
|
||||
import { useRecordTableContextMenuEntries } from '@/object-record/hooks/useRecordTableContextMenuEntries';
|
||||
import { filterAvailableTableColumns } from '@/object-record/utils/filterAvailableTableColumns';
|
||||
import { useRecordTable } from '@/ui/object/record-table/hooks/useRecordTable';
|
||||
@@ -13,12 +14,19 @@ export const RecordTableEffect = () => {
|
||||
scopeId: objectNamePlural,
|
||||
setAvailableTableColumns,
|
||||
setOnEntityCountChange,
|
||||
setObjectMetadataConfig,
|
||||
} = useRecordTable();
|
||||
|
||||
const { foundObjectMetadataItem } = useFindOneObjectMetadataItem({
|
||||
objectNamePlural,
|
||||
});
|
||||
|
||||
const {
|
||||
mainIdentifierMapper,
|
||||
basePathToShowPage,
|
||||
mainIdentifierFieldMetadataId,
|
||||
} = useObjectMainIdentifier(foundObjectMetadataItem);
|
||||
|
||||
const { columnDefinitions, filterDefinitions, sortDefinitions } =
|
||||
useComputeDefinitionsFromFieldMetadata(foundObjectMetadataItem);
|
||||
|
||||
@@ -31,6 +39,26 @@ export const RecordTableEffect = () => {
|
||||
setEntityCountInCurrentView,
|
||||
} = useView();
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
mainIdentifierMapper &&
|
||||
basePathToShowPage &&
|
||||
mainIdentifierFieldMetadataId
|
||||
) {
|
||||
setObjectMetadataConfig?.({
|
||||
mainIdentifierMapper,
|
||||
basePathToShowPage,
|
||||
mainIdentifierFieldMetadataId,
|
||||
});
|
||||
}
|
||||
}, [
|
||||
basePathToShowPage,
|
||||
foundObjectMetadataItem,
|
||||
mainIdentifierFieldMetadataId,
|
||||
mainIdentifierMapper,
|
||||
setObjectMetadataConfig,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!foundObjectMetadataItem) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user