Skip to content

Commit 6b3cc1c

Browse files
committed
changes to support profiledb
1 parent df375ee commit 6b3cc1c

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

packages/tdb-documents-ui/src/helpers/labelHelper.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from "react"
22
import * as util from "../utils"
33
import * as CONST from "../constants"
44
import {getDataType} from "../dataTypeFrames/helpers"
5-
import {getLabelFromEnumDocumentation} from "../documentationTemplates"
5+
import {getEnumLabelDescription} from "../documentationTemplates"
66
import {getPropertyLabelFromDocumentation} from "../documentationTemplates"
77
import Row from "react-bootstrap/Row"
88

@@ -35,7 +35,7 @@ const EnumLabelComponent =({frame, label, documentation, isKey}) => {
3535

3636
let values=frame[label]["@values"]
3737
return <div className="d-flex hd enum__label">
38-
{getLabelFromEnumDocumentation (label, documentation, values)}
38+
{getEnumLabelDescription(label, documentation)}
3939
{util.displayIfKeyField(isKey, label)}
4040
</div>
4141
}
@@ -55,6 +55,10 @@ export function generateLabel (frame, item, documentation, fullFrame) {
5555

5656
let isKey=util.checkIfKey(item, frame["@key"])
5757

58+
if(util.isEnumType(frame[item])) {
59+
return <EnumLabelComponent frame={frame} label={item} documentation={documentation} isKey={isKey}/>
60+
}
61+
5862
if(util.isSubDocumentType(frame[item])) {
5963
return <SubDocumentLabelComponent label={item} documentation={documentation} isKey={isKey}/>
6064
}

packages/tdb-documents-ui/src/helpers/propertyHelper.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function getSubDocumentFormData (formData, subDocumentName) {
1818
return formData[subDocumentName]
1919
}
2020

21-
function constructSubDocumentFrame (fullFrame, subDocumentName, documentClassName,frame, uiFrame, mode, formData, onTraverse, onSelect, documentation, setChainedData) {
21+
function constructSubDocumentFrame (fullFrame, subDocumentName, documentClassName,frame, uiFrame, mode, formData, onTraverse, onSelect, documentation, docType) {
2222

2323
//documentClassNamme
2424
let constructedFrame= fullFrame.hasOwnProperty(documentClassName) ? fullFrame[documentClassName] : {}
@@ -36,7 +36,7 @@ function constructSubDocumentFrame (fullFrame, subDocumentName, documentClassNam
3636
onTraverse,
3737
onSelect,
3838
documentation,
39-
setChainedData
39+
docType
4040
)
4141
// Add @type attribute here only for CREATE & EDIT mode to help in saving to terminusDB
4242
if(mode !== CONST.VIEW) {
@@ -61,26 +61,27 @@ function constructSubDocumentFrame (fullFrame, subDocumentName, documentClassNam
6161
}
6262
return subDocumentFrames
6363
}
64-
64+
6565

66-
export function generateInternalFrames(fullFrame, item, frame, uiFrame, mode, formData, onTraverse, onSelect, documentation, setChainedData) {
66+
export function generateInternalFrames(fullFrame, item, frame, uiFrame, mode, formData, onTraverse, onSelect, documentation, docType) {
6767
/** return null if frame doesnt have property in it */
6868
if(!frame.hasOwnProperty(item)) return null
6969

7070
if(util.isOneOfSubDocumentType(fullFrame, frame[item])) {
71-
let {anyOf, anyOfUiSchema}=makeOneOfTypeFrames({fullFrame, item, frame, uiFrame, mode, formData, onTraverse, onSelect, documentation})
71+
let {anyOf, anyOfUiSchema}=makeOneOfTypeFrames({fullFrame, item, frame, uiFrame, mode, formData, onTraverse, onSelect, documentation, docType})
7272
//let oneOfFrame= makeOneOfTypeFrames({fullFrame, item, frame, uiFrame, mode, formData, onTraverse, onSelect, documentation})
7373
return {anyOf, anyOfUiSchema}
7474
}
7575
if(util.isSubDocumentType(frame[item])) { // Subdocument type
7676
let documentClassName=util.getLinkedDocumentClassName (frame, item)
77+
//let cycleExists=checkDocumentClassCycles(documentClassName, fullFrame)
7778
let subDocumentFormData=formData//formData.hasOwnProperty(item) ? formData[item] : {}
78-
let subDocumentFrame = constructSubDocumentFrame(fullFrame, item, documentClassName, frame, uiFrame, mode, subDocumentFormData, onTraverse, onSelect, documentation, setChainedData)
79+
let subDocumentFrame = constructSubDocumentFrame(fullFrame, item, documentClassName, frame, uiFrame, mode, subDocumentFormData, onTraverse, onSelect, documentation, docType)
7980

8081
return subDocumentFrame
8182
}
8283
else if (util.isChoiceSubDocumentType(frame[item])) {
83-
let choiceSubDocumentFrame= makeChoiceSubDocumentTypeFrames({fullFrame, item, frame, uiFrame, mode, formData, onTraverse, onSelect, documentation})
84+
let choiceSubDocumentFrame= makeChoiceSubDocumentTypeFrames({fullFrame, item, frame, uiFrame, mode, formData, onTraverse, onSelect, documentation, docType})
8485
return choiceSubDocumentFrame
8586
}
8687
else if (util.isEnumType(frame[item])) {
@@ -110,7 +111,7 @@ export function generateInternalFrames(fullFrame, item, frame, uiFrame, mode, fo
110111
return feautureViewFrames
111112
}*/
112113
else if(util.isDocumentType(frame[item], fullFrame)) {
113-
let documetFrames=makeDocumentTypeFrames({fullFrame, item, frame, uiFrame, mode, formData, onTraverse, onSelect, documentation})
114+
let documetFrames=makeDocumentTypeFrames({fullFrame, item, frame, uiFrame, mode, formData, onTraverse, onSelect, documentation, docType})
114115
return documetFrames
115116
}
116117
else if (util.isRdfLangString(frame[item])) {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ import * as CONST from "./constants"
1818
* @param {*} documentation - formData - filled data to be displayed in form
1919
* @returns a data field
2020
*/
21-
export function makeMandatoryFrames (fullFrame, item, frame, uiFrame, mode, formData, onTraverse, onSelect, documentation, setChainedData) {
21+
export function makeMandatoryFrames (fullFrame, item, frame, uiFrame, mode, formData, onTraverse, onSelect, documentation, docType) {
2222

2323
/** generate properties of sub frames */
24-
let extractedFrames = propertyHelper.generateInternalFrames(fullFrame, item, frame, uiFrame, mode, formData, onTraverse, onSelect, documentation, setChainedData)
24+
let extractedFrames = propertyHelper.generateInternalFrames(fullFrame, item, frame, uiFrame, mode, formData, onTraverse, onSelect, documentation, docType)
2525
//console.log("extractedFrames", extractedFrames)
2626

2727
/** gather layout of property */
@@ -77,7 +77,7 @@ export function makeMandatoryFrames (fullFrame, item, frame, uiFrame, mode, form
7777
}
7878

7979
/** gather ui layout of property to change look and feel */
80-
let uiLayout = generateUI(fullFrame, frame, item, uiFrame, mode, formData, onTraverse, onSelect, documentation, extractedFrames, setChainedData)
80+
let uiLayout = generateUI(fullFrame, frame, item, uiFrame, mode, formData, onTraverse, onSelect, documentation, extractedFrames, docType)
8181

8282
//console.log("layout", layout)
8383
//console.log("uiLayout", uiLayout)

0 commit comments

Comments
 (0)