File tree Expand file tree Collapse file tree
server/src/services/common Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { getGenericRepository } from '../../repositories';
22import { NavigationError } from '../../app-errors' ;
33import { NavigationItemType } from '../../schemas' ;
44import { Core , UID } from '@strapi/types' ;
5+ import { isEmpty } from 'lodash' ;
56
67export interface DuplicateCheckItem {
78 items ?: DuplicateCheckItem [ ] ;
@@ -65,12 +66,14 @@ export const generateFieldsFromRelated = async (
6566 { locale }
6667 ) ;
6768
68- const defaultTitleFields = contentTypesNameFields [ related . __type || 'default' ] ;
69+ const defaultTitleFields = isEmpty ( contentTypesNameFields [ related . __type ] )
70+ ? contentTypesNameFields [ 'default' ] : contentTypesNameFields [ related . __type ] ;
71+
6972 const title = defaultTitleFields . reduce ( ( acc , field ) => {
7073 return acc ? acc : relatedEntity ?. [ field ] ?. toString ( ) ;
7174 } , '' ) ;
7275
73- const defaultPathFields = related ? pathDefaultFields [ related . __type ] : [ ] ;
76+ const defaultPathFields = pathDefaultFields [ related . __type ] || [ ] ;
7477 const path = defaultPathFields . reduce ( ( acc , field ) => {
7578 return acc ? acc : relatedEntity ?. [ field ] ?. toString ( ) ;
7679 } , undefined ) || relatedEntity ?. id . toString ( ) ;
You can’t perform that action at this time.
0 commit comments