Skip to content

Commit f051585

Browse files
Merge pull request #99 from terminusdb/postReleaseFixes
Post release fixes
2 parents ef81f58 + c9ec5fd commit f051585

File tree

10 files changed

+67
-31
lines changed

10 files changed

+67
-31
lines changed

packages/tdb-dashboard/src/components/MainNavBar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const MainNavBar = ({setShowTimeTravel}) => {
3030
{dataProduct}
3131
</h4>
3232
<TimeTravelWidget setShowTimeTravel={setShowTimeTravel}/>
33-
</React.Fragment>
33+
</React.Fragment>
3434
}
3535
{accessControlDashboard && accessControlDashboard.createDB() &&
3636
<NewDataProduct css={"btn-sm mr-1 pt-2 pr-4 pl-4 "}/>

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"] = {

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@ import OverlayTrigger from 'react-bootstrap/OverlayTrigger'
66
import Tooltip from 'react-bootstrap/Tooltip'
77
import {FiHelpCircle} from "react-icons/fi"
88

9-
/**
9+
/** displays documentation for enum with @comment*/
10+
export function getEnumLabelDescription(item, documentation) {
11+
if(!documentation) return <div className="control-label">{item}</div>
12+
if(!documentation.hasOwnProperty(CONST.COMMENT)) return <div className="control-label">{item}</div>
13+
return <DisplayPropertyNameAndComment comment={documentation[CONST.COMMENT]} label={item}/>
14+
//return <small className="fst-italic text-muted">{documentation[CONST.COMMENT]}</small>
15+
}
16+
17+
/**
1018
*
1119
* @param {*} documentation - documentation object which contains labels and comments
1220
* @param {*} item - item
@@ -19,6 +27,7 @@ import {FiHelpCircle} from "react-icons/fi"
1927
"@values": values
2028
}
2129
if(!documentation) return enumDocumentation
30+
//if(typeof documentation === CONST.OBJECT_TYPE) return getEnumLabelDescription(item, documentation)
2231
if(!Array.isArray(documentation)) return enumDocumentation
2332
let valueArray=[]
2433
documentation.map(doc => {
@@ -51,9 +60,9 @@ import {FiHelpCircle} from "react-icons/fi"
5160
* @param {*} comment - documentation comment which will be displayed as a description tool tip in the UI
5261
* @returns
5362
*/
54-
function DisplayPropertyNameAndComment ({label, comment}){
63+
export function DisplayPropertyNameAndComment ({label, comment}){
5564
return <React.Fragment>
56-
<span id="tdb__property__name__label" className="h6">{label}</span>
65+
{label && <span id="tdb__property__name__label" className="h6">{label}</span>}
5766
{comment && <OverlayTrigger
5867
key={comment}
5968
placement={'right'}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {getLabelFromEnumDocumentation} from "../documentationTemplates"
33
import * as util from "../utils"
44
import * as CONST from "../constants"
55
import React from "react"
6+
import {DisplayPropertyNameAndComment} from "../documentationTemplates"
67

78
export function makeEnumTypeFrames (fullFrame, frame, item, uiFrame, mode, formData, documentation) {
89
let enumClassName=frame[item]["@id"]
@@ -16,15 +17,16 @@ export function makeEnumTypeFrames (fullFrame, frame, item, uiFrame, mode, formD
1617
return {enum: enumDocumentation["@values"]}
1718
}
1819

20+
1921
export function getUILayout (fullFrame, frame, item, uiFrame, mode, formData, documentation) {
20-
22+
2123
let label=item
2224
//let enumDocumentation=getLabelFromEnumDocumentation(item, documentation, frame[item]["@values"])
2325
//if(enumDocumentation.hasOwnProperty("@label")) label=enumDocumentation["@label"]
2426

2527
let uiLayout = {
2628
"ui:placeholder": `Select ${label} ...`,
27-
//"ui:description": getUI(),
29+
//"ui:description": getDescription(documentation),
2830
classNames: "tdb__input mb-3 mt-3"
2931
}
3032

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)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ function extractPropertyFrames (extractedProperties) {
6161

6262
// retrieves layout of object data types one ofs
6363
function getDocumentLayout(choiceDocument, choiceDocumentFrames, oneOfLinkedClassName, args) {
64-
let {fullFrame, item, frame, uiFrame, mode, formData, onTraverse, onSelect, documentation, setChainedData} = args
64+
let {fullFrame, item, frame, uiFrame, mode, formData, onTraverse, onSelect, documentation, docType} = args
6565

6666
let choiceSubDocument=choiceDocumentFrames.hasOwnProperty("@class") ? choiceDocumentFrames["@class"] : choiceDocumentFrames
6767
let choiceSubDocumentFrame = fullFrame[choiceSubDocument]
6868

6969
// get documentation from frame
7070
let extractedDocumentation= choiceSubDocumentFrame.hasOwnProperty(CONST.DOCUMENTATION) ? choiceSubDocumentFrame[CONST.DOCUMENTATION] : []
71-
let exractedProperties = getProperties(fullFrame, item, choiceSubDocumentFrame, uiFrame, mode, formData, onTraverse, onSelect, extractedDocumentation, setChainedData)
71+
let exractedProperties = getProperties(fullFrame, item, choiceSubDocumentFrame, uiFrame, mode, formData, onTraverse, onSelect, extractedDocumentation, docType)
7272

7373
console.log("exractedProperties sub", exractedProperties)
7474
exractedProperties.properties["@type"]={

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as CONST from "../constants"
2-
import {getProperties} from "../FrameHelpers"
32
import * as util from "../utils"
43
import * as helper from "./helpers"
54

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ export function isFilled (item, formData){
460460
return false
461461
}
462462

463+
463464
/**
464465
*
465466
* @param {*} frame - full frame from a data product
@@ -471,21 +472,34 @@ export function isFilled (item, formData){
471472
if(frame.hasOwnProperty(item) && frame[item].hasOwnProperty(CONST.DOCUMENTATION)) {
472473
let docArr=[]
473474
if(language) {
474-
frame[item][CONST.DOCUMENTATION].map(doc => {
475+
if(Array.isArray(frame[item][CONST.DOCUMENTATION])) {
476+
// expecting an array with multi language definitions
477+
frame[item][CONST.DOCUMENTATION].map(doc => {
478+
let obj={}
479+
for(var things in doc) {
480+
obj[things]=doc[things]
481+
}
482+
obj[CONST.SELECTED_LANGUAGE]=language
483+
docArr.push(obj)
484+
})
485+
}
486+
else if (typeof frame[item][CONST.DOCUMENTATION] === CONST.OBJECT_TYPE){
487+
// expecting an object
475488
let obj={}
476-
for(var things in doc) {
477-
obj[things]=doc[things]
489+
for(var things in frame[item][CONST.DOCUMENTATION]) {
490+
obj[things]=frame[item][CONST.DOCUMENTATION][things]
478491
}
479492
obj[CONST.SELECTED_LANGUAGE]=language
480-
docArr.push(obj)
481-
})
493+
docArr.push(obj)
494+
}
482495
documentation=docArr
483496
}
484497
else documentation = frame[item][CONST.DOCUMENTATION]
485498
}
486499
return documentation
487500
}
488501

502+
489503
/**
490504
*
491505
* @param {*} documentation - documentation object which contains labels and comments

0 commit comments

Comments
 (0)