Skip to content

Commit 54cdc72

Browse files
committed
change to support profile db
1 parent d50efcc commit 54cdc72

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

packages/tdb-documents-ui/src/documentTypeFrames/documentTypeFrames.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,20 @@ function getCreateAnyOfFrames (frame, item, exractedProperties) {
8080
return anyOfFrame
8181
}
8282

83-
function checkIfCycleExists(property, linked_to_frames) {
83+
function checkIfCycleExists(property, linked_to_frames, linked_to, docType) {
8484
if(linked_to_frames.hasOwnProperty(property)) return true
85+
if(linked_to && docType) {
86+
// doc Type is the type of document to be displayed in <FrameViewer/>
87+
// checks if linked to is same as the parent document class
88+
if(linked_to === docType) return true
89+
}
8590
return false
8691
}
8792

8893
/** make documentation frames basaed on mode */
8994
export const makeDocumentTypeFrames = (args) => {
9095

91-
let {fullFrame, frame, item, uiFrame, documentation, mode, formData, onTraverse, onSelect}=args
96+
let {fullFrame, frame, item, uiFrame, documentation, mode, formData, onTraverse, onSelect, docType}=args
9297

9398
let anyOf = []
9499
let linked_to = frame[item]
@@ -97,7 +102,7 @@ export const makeDocumentTypeFrames = (args) => {
97102
let linked_to_frames=fullFrame[linked_to]
98103
let unfoldable=util.isUnfoldable(fullFrame[linked_to])
99104

100-
let ifCycleExists=checkIfCycleExists(item, linked_to_frames)
105+
let ifCycleExists=checkIfCycleExists(item, linked_to_frames, linked_to, docType)
101106

102107
/** if a property is pointing to its own parent document class
103108
* then display only Link an Existing Document
@@ -118,11 +123,13 @@ export const makeDocumentTypeFrames = (args) => {
118123
}
119124

120125
/** extract frames to pass to any of when user chooses to Create a new Document */
126+
let linkedDocType=linked_to
127+
// pass the linked doc type instead to check if there are cycles
121128
let exractedProperties = getProperties(
122129
fullFrame,
123130
linked_to,
124131
linked_to_frames,
125-
uiFrame, mode, formData, onTraverse, onSelect, documentation)
132+
uiFrame, mode, formData, onTraverse, onSelect, documentation, linkedDocType)
126133

127134
// adding type of linked data
128135
exractedProperties["properties"]["@type"] = {

0 commit comments

Comments
 (0)