Morph-front-display-table (#13979)
## Add Morph Relation Field Display Support for Tables (one to many & many to one) **Features:** - Display morph relation fields (one-to-many, many-to-one) in table cells - Multi-field record retrieval for improved performance - Enhanced table cell rendering with morph relation support **Components Added:** - `MorphRelationManyToOneFieldDisplay` - Shows many-to-one morph relations - `MorphRelationOneToManyFieldDisplay` - Shows one-to-many morph relations TODO : handle notes and tasks case if we choose these kind of objects as targets/source for a morph relation --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
+13
@@ -0,0 +1,13 @@
|
||||
import { capitalize } from '@/utils/strings';
|
||||
|
||||
type ComputeMorphRelationFieldJoinColumnNameArgs = {
|
||||
name: string;
|
||||
targetObjectMetadataNameSingular: string;
|
||||
};
|
||||
|
||||
export const computeMorphRelationFieldJoinColumnName = ({
|
||||
name,
|
||||
targetObjectMetadataNameSingular,
|
||||
}: ComputeMorphRelationFieldJoinColumnNameArgs) => {
|
||||
return `${name}${capitalize(targetObjectMetadataNameSingular)}Id`;
|
||||
};
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
|
||||
import { capitalize } from '@/utils/strings';
|
||||
|
||||
enum RelationType {
|
||||
MANY_TO_ONE = 'MANY_TO_ONE',
|
||||
ONE_TO_MANY = 'ONE_TO_MANY'
|
||||
}
|
||||
|
||||
|
||||
type ComputeMorphRelationFieldNameArgs = {
|
||||
fieldName: string;
|
||||
relationDirection: RelationType;
|
||||
nameSingular: string;
|
||||
namePlural: string;
|
||||
};
|
||||
|
||||
export const computeMorphRelationFieldName = ({
|
||||
fieldName,
|
||||
relationDirection,
|
||||
nameSingular,
|
||||
namePlural,
|
||||
}: ComputeMorphRelationFieldNameArgs): string => {
|
||||
if (relationDirection === RelationType.MANY_TO_ONE) {
|
||||
return `${fieldName}${capitalize(nameSingular)}`;
|
||||
}
|
||||
|
||||
if (relationDirection === RelationType.ONE_TO_MANY) {
|
||||
return `${fieldName}${capitalize(namePlural)}`;
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
`Invalid relation direction: ${relationDirection} for field ${fieldName}`,
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user