Skip to content

Commit 326d5ef

Browse files
authored
fixes (#133)
* fixes * removing old comments
1 parent a2b90f9 commit 326d5ef

File tree

13 files changed

+225
-178
lines changed

13 files changed

+225
-178
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,9 @@ const ViewHeader = ({type, id, setView, setShowCRModal, setClickedDelete}) => {
183183
<div className="col-md-6">
184184
<strong className="text-success">
185185
<span className="mr-1 h6 fst-italic">{CONST.VIEW_DOCUMENT}:</span>
186-
<span className="fw-bolder h6"> {type}/{id} </span>
186+
<span className="fw-bolder h6"> {id} </span>
187187
</strong>
188-
<CopyButton text={`${type}/${id}`} title={`Copy Document ID`}/>
188+
<CopyButton text={`${id}`} title={`Copy Document ID`}/>
189189
</div>
190190
<ViewFramesButton/>
191191
<ToggleJsonAndFormControl onClick={setView}/>

packages/tdb-documents-ui/diff/src/Output.js

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,29 +125,44 @@ export const Output = () => {
125125
}
126126
}*/
127127

128-
let testFrames ={
128+
let testFrames = {
129129
"@context": {
130-
"@base": "terminusdb:///documentation/data/",
131-
"@schema": "terminusdb:///documentation/schema#",
130+
"@base": "terminusdb:///data/",
131+
"@schema": "terminusdb:///schema#",
132132
"@type": "Context"
133133
},
134-
"Body": {
134+
"body": {
135+
"@key": {
136+
"@type": "Random"
137+
},
135138
"@metadata": {
136139
"render_as": {
137-
"value": "markdown"
140+
"optMarkDown": "markdown",
141+
"setMarkDown": "markdown"
138142
}
139143
},
140144
"@type": "Class",
141-
"value": "xsd:string"
145+
"optMarkDown": {
146+
"@class": "xsd:string",
147+
"@type": "Optional"
148+
},
149+
"setMarkDown": {
150+
"@class": "xsd:string",
151+
"@type": "Set"
152+
},
153+
"text": {
154+
"@class": "xsd:string",
155+
"@type": "Set"
156+
}
142157
}
143-
144158
}
159+
145160
return <div className="w-100">
146161
<DiffViewer
147162
oldValue={doc[OLD_VALUE]}
148163
newValue={doc[CHANGED_VALUE]}
149164
frame={testFrames}
150-
type={"Body"}
165+
type={"body"}
151166
diffPatch={diff}/>
152167
</div>
153168
}

packages/tdb-documents-ui/diff/src/diff.constants.js

Lines changed: 18 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,28 @@
11
/** Review DependencyRelation - boolean field | Geometry */
22
export const oldData = {
3-
/*"Body": {
4-
"@id": "Body/c4a7f457e606df038ba5f6b4089e1e4cc5ddc8f0d5ad6fed1bb2a49d43378252",
5-
"@type": "Body",
6-
"value": "---\n__Advertisement :)__\n\n- __[pica](https://nodeca.github.io/pica/demo/)__ - high quality and fast image\n resize in browser.\n- __[babelfish](https://github.com/nodeca/babelfish/)__ - developer friendly\n i18n with plurals support and easy syntax.\n\nYou will like those projects!\n\n---\n\n# h1 Heading 8-)\n## h2 Heading\n### h3 Heading\n#### h4 Heading\n##### h5 Heading\n###### h6 Heading\n\n\n## Horizontal Rules\n\n___\n\n---\n\n***\n\n\n## Typographic replacements\n\nEnable typographer option to see result.\n\n(c) (C) (r) (R) (tm) (TM) (p) (P) +-\n\ntest.. test... test..... test?..... test!....\n\n!!!!!! ???? ,, -- ---\n\n\"Smartypants, double quotes\" and 'single quotes'\n\n\n## Emphasis\n\n**This is bold text**\n\n__This is bold text__\n\n*This is italic text*\n\n_This is italic text_\n\n~~Strikethrough~~\n\n\n## Blockquotes\n\n\n> Blockquotes can also be nested...\n>> ...by using additional greater-than signs right next to each other...\n> > > ...or with spaces between arrows.\n\n\n## Lists\n\nUnordered\n\n+ Create a list b",
7-
},*/
8-
"job": {
9-
"@id": "job/16c3c5ff4003bb3d53d876504ac89703fffc378338154a5abffd012892aef332",
10-
"@type": "job",
11-
"company": "company",
12-
"title": "saddsa",
13-
"nonUnfoldable_property": "nonUnfoldable_property/239729wqdsad8921973",
14-
"section": {
15-
"@id": "category/215b036f11acf6b0be2e698ece217193ca9adf1eeadb8c7872f7690e93100730",
16-
"@type": "category",
17-
"name": "ddd",
18-
"notes": "crappy",
19-
"has_other": {
20-
"@id": "subCategory/215b036f11acf6b0be2e698ece217193ca9adf1eeadb8c7872f7690e93100730",
21-
"@type": "subCategory",
22-
"description": "elaborate descr",
23-
}
24-
}
3+
"body": {
4+
"@id": "body/6230f55d381076aa7f94b6b01a7a7ae1692ef40c44e233a52c1c280b5d339839",
5+
"@type": "body",
6+
"optMarkDown": "### opt",
7+
"setMarkDown": [
8+
"### set 1",
9+
"### set 2"
10+
],
11+
"text": ["text1", "text2", "text3", "2","text4org", "5", "5"]
2512
}
2613
}
2714

2815

2916
export const changedData = {
30-
"Body": {
31-
/*"@id": "Body/c4a7f457e606df038ba5f6b4089e1e4cc5ddc8f0d5ad6fed1bb2a49d43378252",*/
32-
"@type": "Body",
33-
"value": "---\n__Advertisement :)__\n\n- __[pica](https://nodeca.github.io/pica/demo/)__ - high quality and fast image\n resize in browser.\n- __[babelfish](https://github.com/nodeca/babelfish/)__ - developer friendly\n i18n with plurals support and easy syntax.\n\nYou will like those projects!\n\n---\n\n# h1 Heading 8-)\n## h2 Heading\n### h3 Heading\n#### h4 Heading\n##### h5 Heading\n###### h6 Heading\n\n\n## Horizontal Rules\n\n___\n\n---\n\n***\n\n\n## Typographic replacements\n\nEnable typographer option to see result.\n\n(c) (C) (r) (R) (tm) (TM) (p) (P) +-\n\ntest.. test... test..... test?..... test!....\n\n!!!!!! ???? ,, -- ---\n\n\"Smartypants, double quotes\" and 'single quotes'\n\n\n## Emphasis\n\n**This is bold text**\n\n__This is bold text__\n\n*This is italic text*\n\n_This is italic text_\n\n~~Strikethrough~~\n\n\n## Blockquotes\n\n\n> Blockquotes can also be nested...\n>> ...by using additional greater-than signs right next to each other...\n> > > ...or with spaces between arrows.\n\n\n## Lists\n\nUnordered\n\n+ Create a list b",
34-
},
35-
"job": {
36-
"@id": "job/16c3c5ff4003bb3d53d876504ac89703fffc378338154a5abffd012892aef332",
37-
"@type": "job",
38-
"company": "company",
39-
"title": "saddsa",
40-
"nonUnfoldable_property": "nonUnfoldable_property/239729wqdsad8921973",
41-
"section": {
42-
"@id": "category/215b036f11acf6b0be2e698ece217193ca9adf1eeadb8c7872f7690e93100730",
43-
"@type": "category",
44-
"name": "ddd",
45-
"notes": "crappy new data",
46-
"has_other": {
47-
"@id": "subCategory/215b036f11acf6b0be2e698ece217193ca9adf1eeadb8c7872f7690e93100730",
48-
"@type": "subCategory",
49-
"description": "elaborate descr",
50-
}
51-
}
17+
"body": {
18+
"@id": "body/6230f55d381076aa7f94b6b01a7a7ae1692ef40c44e233a52c1c280b5d339839",
19+
"@type": "body",
20+
"optMarkDown": "### opt changed",
21+
"setMarkDown": [
22+
"### set 1 changed",
23+
"### set 2"
24+
],
25+
"text": ["text1changed", "text2", "text3ch", "2", "text4", "5", "5"]
5226
}
5327
}
5428
/*

packages/tdb-documents-ui/src/css/terminusdb__styles.css

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,10 @@ div.leaflet-popup-content-wrapper > div.leaflet-popup-content {
542542

543543
/** REACT DIFF VIEWER FOR MARKDOWN **/
544544
/** hide changed diff from original react-diff-viewer */
545-
div.diff_react_viewer_original > table.css-1ri4lr5-diff-container > tbody > tr.css-1n7ec1i-line td:nth-last-child(-n+3) {
545+
/*div.diff_react_viewer_original > table.css-1ri4lr5-diff-container > tbody > tr.css-1n7ec1i-line td:nth-last-child(-n+3) {
546+
display: none !important;
547+
}*/
548+
div.diff_react_viewer_original table.css-1ri4lr5-diff-container tbody tr.css-1n7ec1i-line td.css-1pm82w3-diff-added {
546549
display: none !important;
547550
}
548551

@@ -563,7 +566,11 @@ div.diff_react_viewer_original > table.css-1ri4lr5-diff-container > tbody > tr.c
563566
}
564567

565568
/** hide original diff from changed react-diff-viewer */
566-
div.diff_react_viewer_changed > table.css-1ri4lr5-diff-container > tbody > tr.css-1n7ec1i-line td:nth-child(-n+3) {
569+
/*div.diff_react_viewer_changed > table.css-1ri4lr5-diff-container > tbody > tr.css-1n7ec1i-line td:nth-child(-n+3) {
570+
display: none !important;
571+
}*/
572+
573+
div.diff_react_viewer_changed table.css-1ri4lr5-diff-container tbody tr.css-1n7ec1i-line td.css-14exn69-diff-removed {
567574
display: none !important;
568575
}
569576

@@ -744,7 +751,8 @@ form.rjsf label.control-label:after { content: ""; }
744751

745752
/* hide anyof select from document links in edit and view mode */
746753
.tdb__edit__document__link .panel .form-group select.form-control,
747-
.tdb__view__document__link .panel .form-group select.form-control{
754+
.tdb__view__document__link .panel .form-group select.form-control,
755+
.tdb__view__document__link + .panel {
748756
display: none !important;
749757
}
750758

packages/tdb-documents-ui/src/diffs/arrayFieldDiffs.js

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,17 @@ function patchListOperation (diff, item, tagOriginalUI, tagChangedUI) {
105105
}
106106
else {
107107
// copy list swap operation
108-
diff[DIFFCONST.REST][DIFFCONST.REST].map(rest => {
109-
let {originalUI, changedUI} = swapOperation(rest)
110-
tagOriginalUI[item].push(originalUI)
111-
tagChangedUI[item].push(changedUI)
112-
})
108+
if(Array.isArray(diff[DIFFCONST.REST][DIFFCONST.REST])) {
109+
diff[DIFFCONST.REST][DIFFCONST.REST].map(rest => {
110+
let {originalUI, changedUI} = swapOperation(rest)
111+
tagOriginalUI[item].push(originalUI)
112+
tagChangedUI[item].push(changedUI)
113+
})
114+
}
115+
else {
116+
// at this point this will be patch operation - if not we will need a check here to see if @op is patch
117+
patchListOperation (diff[DIFFCONST.REST][DIFFCONST.REST], item, tagOriginalUI, tagChangedUI)
118+
}
113119

114120
}
115121
}
@@ -339,7 +345,7 @@ function getCss(props, item, tagUI) {
339345

340346

341347
// ALL ARRAY FIELDS
342-
export function getArrayFieldDiffs(diff, item, oldValue, newValue) {
348+
export function getArrayFieldDiffs(diff, item, oldValue, newValue, metaDataConfig) {
343349

344350
let originalUIFrame={}, changedUIFrame={}
345351

@@ -420,7 +426,15 @@ export function getArrayFieldDiffs(diff, item, oldValue, newValue) {
420426
// when @before is null - we will check form data here
421427
let css = getCss(props, item, tagOriginalUI)
422428
let data=getFormData(props.formData, css)
423-
return displayElements(data, item, props.schema, tagOriginalUI)
429+
/*if(metaDataConfig) {
430+
css= css === "tdb__diff__original" ? "diff_react_viewer_original mb-3" : ""
431+
return <DisplayArrayMarkdown data={data}
432+
item={item}
433+
newValue={newValue}
434+
oldValue={oldValue}
435+
css={css}/>
436+
}
437+
else */return displayElements(data, item, props.schema, tagOriginalUI, metaDataConfig)
424438
}
425439

426440
/**
@@ -433,7 +447,15 @@ export function getArrayFieldDiffs(diff, item, oldValue, newValue) {
433447
// when @after is null - we will check form data here
434448
let css = getCss(props, item, tagChangedUI)
435449
let data=getFormData(props.formData, css)
436-
return displayElements(data, item, props.schema, tagChangedUI)
450+
/*if(metaDataConfig) {
451+
css=css === "tdb__diff__changed" ? "diff_react_viewer_changed mb-3" : ""
452+
return <DisplayArrayMarkdown data={data}
453+
item={item}
454+
newValue={newValue}
455+
oldValue={oldValue}
456+
css={css}/>
457+
}
458+
else*/ return displayElements(data, item, props.schema, tagChangedUI, metaDataConfig)
437459
}
438460

439461
originalUIFrame[CONST.DIFF] = displayOriginal

packages/tdb-documents-ui/src/diffs/dataFieldDiffs.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as DIFFCONST from "./diff.constants"
2-
import {DIFF} from "../constants"
2+
import { DIFF, MARKDOWN } from "../constants"
33
import * as util from "./diffComponents"
4+
import { getMarkdownFieldDiffs } from "./markdownFieldDiffs"
45

56
/**
67
*
@@ -53,7 +54,15 @@ function getClassNamesForDiffs(diff) {
5354

5455

5556
// ALL SWAP VALUE OPERATIONS
56-
export function getDataFieldDiffs(diff) {
57+
export function getDataFieldDiffs(diff, metaDataConfig) {
58+
59+
if(metaDataConfig) {
60+
if(metaDataConfig.metaDataType === MARKDOWN) {
61+
// display as markdown
62+
let ui=getMarkdownFieldDiffs(metaDataConfig)
63+
return ui
64+
}
65+
}
5766

5867
if(!diff.hasOwnProperty(DIFFCONST.OPERATION)) {
5968
let originalUIFrame=[], changedUIFrame=[]
@@ -72,5 +81,5 @@ export function getDataFieldDiffs(diff) {
7281

7382
let {originalUIFrame, changedUIFrame}=getClassNamesForDiffs(diff)
7483

75-
return {originalUIFrame, changedUIFrame}
84+
return { originalUIFrame, changedUIFrame }
7685
}

packages/tdb-documents-ui/src/diffs/diffViewer copy.js

Lines changed: 0 additions & 73 deletions
This file was deleted.

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as util from "../utils"
22
import * as CONST from "../constants"
33
import * as DIFFCONST from "./diff.constants"
4-
import {getMarkdownFieldDiffs} from "./markdownFieldDiffs"
54
import {getDataFieldDiffs} from "./dataFieldDiffs"
65
import {getArrayFieldDiffs} from "./arrayFieldDiffs"
76

@@ -18,29 +17,29 @@ export function generateDiffUIFrames (fullFrame, frame, type, oldValue, newValue
1817
else if(item === "@id") continue
1918
else if(item === CONST.SUBDOCUMENT) continue
2019
else if(item === CONST.DOCUMENTATION) continue
21-
else if(util.checkIfRenderedAsMarkdown(frame, item, diffPatch)) {
22-
let ui=getMarkdownFieldDiffs(item, oldValue, newValue)
23-
24-
diffUIFrames[DIFFCONST.ORIGINAL_UI_FRAME][item]=ui.originalUIFrame
25-
diffUIFrames[DIFFCONST.CHANGED_UI_FRAME][item]=ui.changedUIFrame
26-
}
2720
else if(util.isMandatory(frame, item)) {
2821
let diff=diffPatch.hasOwnProperty(item) ? diffPatch[item] : {}
29-
let ui=getDataFieldDiffs(diff)
30-
22+
// check if defined in metadata
23+
let metaDataConfig = util.gatherMetaDataConfig(frame, item, diffPatch, oldValue, newValue)
24+
let ui=getDataFieldDiffs(diff, metaDataConfig)
25+
3126
diffUIFrames[DIFFCONST.ORIGINAL_UI_FRAME][item]=ui.originalUIFrame
3227
diffUIFrames[DIFFCONST.CHANGED_UI_FRAME][item]=ui.changedUIFrame
3328
}
3429
else if(util.isOptional(frame, item)) {
3530
let diff=diffPatch.hasOwnProperty(item) ? diffPatch[item] : {}
36-
let ui=getDataFieldDiffs(diff)
31+
// check if defined in metadata
32+
let metaDataConfig = util.gatherMetaDataConfig(frame, item, diffPatch, oldValue, newValue)
33+
let ui=getDataFieldDiffs(diff, metaDataConfig)
3734

3835
diffUIFrames[DIFFCONST.ORIGINAL_UI_FRAME][item]=ui.originalUIFrame
3936
diffUIFrames[DIFFCONST.CHANGED_UI_FRAME][item]=ui.changedUIFrame
4037
}
4138
else if(util.isSet(frame, item)) {
4239
let diff=diffPatch.hasOwnProperty(item) ? diffPatch[item] : {}
43-
let ui=getArrayFieldDiffs(diff, item, oldValue, newValue)
40+
// check if defined in metadata
41+
let metaDataConfig = util.gatherMetaDataConfig(frame, item, diffPatch, oldValue, newValue)
42+
let ui=getArrayFieldDiffs(diff, item, oldValue, newValue, metaDataConfig)
4443

4544
diffUIFrames[DIFFCONST.ORIGINAL_UI_FRAME][item]=ui.originalUIFrame
4645
diffUIFrames[DIFFCONST.CHANGED_UI_FRAME][item]=ui.changedUIFrame

0 commit comments

Comments
 (0)