Skip to content

Commit 9f32274

Browse files
committed
diff list view fix
1 parent c36e1a5 commit 9f32274

File tree

3 files changed

+38
-10
lines changed

3 files changed

+38
-10
lines changed

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

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {DiffViewer} from '@terminusdb/terminusdb-documents-ui'
44
import {OLD_VALUE, CHANGED_VALUE} from "./constants"
55
import {getSelectedTypeData} from "./functions"
66
import {oldData, changedData} from "./diff.constants"
7-
import "../../src/css/terminusdb__styles"
7+
import '../../src/css/terminusdb__darkly.css'
88

99
export const Output = () => {
1010
const {
@@ -27,7 +27,7 @@ export const Output = () => {
2727
useEffect(() => {
2828
async function getDiffs(tdbClient) {
2929
//console.log("doc", doc)
30-
let result_patch = await tdbClient.getJSONDiff(oldData["Person"], changedData["Person"])
30+
let result_patch = await tdbClient.getJSONDiff(oldData["Test"], changedData["Test"])
3131
setDiff(result_patch)
3232
}
3333
if(tdbClient) {
@@ -256,10 +256,14 @@ export const Output = () => {
256256
"@type": "Random"
257257
},
258258
"@type": "Class",
259-
"likes": {
259+
"likes": {
260+
"@class": "xsd:string",
261+
"@type": "List"
262+
}
263+
/*"likes": {
260264
"@class": "Animal",
261265
"@type": "List"
262-
},
266+
},*/
263267
/*"favorite_subject": {
264268
"@class": [
265269
{
@@ -277,7 +281,7 @@ export const Output = () => {
277281
"@class": "xsd:string",
278282
"@type": "Optional"
279283
},*/
280-
"manYAddress": {
284+
/*"manYAddress": {
281285
"@class": {
282286
"@class": "Address",
283287
"@subdocument": []
@@ -358,15 +362,26 @@ export const Output = () => {
358362
},
359363
"@type": "Class",
360364
"likes": "Animal"
365+
},
366+
"Test": {
367+
"@key": {
368+
"@type": "Random"
369+
},
370+
"@type": "Class",
371+
"new": {
372+
"@class": "xsd:string",
373+
"@type": "List"
374+
},
375+
361376
}
362377
}
363378

364379
return <div className="w-100">
365380
<DiffViewer
366-
oldValue={oldData["Person"]}
367-
newValue={changedData["Person"]}
381+
oldValue={oldData["Test"]}
382+
newValue={changedData["Test"]}
368383
frame={testFrames}
369-
type={"Person"}
384+
type={"Test"}
370385
onTraverse={handleTraverse}
371386
diffPatch={diff}/>
372387
</div>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/** Review DependencyRelation - boolean field | Geometry */
22
export const oldData = {
3+
"Test": {new: ["X", "Y", "Z", "A", "B"]},
34
"Sys": {
45
"rdfProperty": {
56
"@lang":"ka",
@@ -173,7 +174,7 @@ export const oldData = {
173174

174175

175176
export const changedData = {
176-
177+
"Test": {new: ["X", "Y", "Z"]},
177178
"Sys": {
178179
"rdfProperty": {
179180
"@lang":"ka",

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,20 @@ function getDiffUi (diffPatch, diffState) {
141141
}
142142
// pass @rest object
143143
else {
144+
let uiArray= []
145+
if(diffPatch.hasOwnProperty(DIFFCONST.TO)) {
146+
// keep list till number in @to
147+
// now add @to
148+
for(let count = 0; count < diffPatch[DIFFCONST.TO]; count ++) {
149+
// set default class name
150+
uiArray.push({ [CONST.CLASSNAME]: "tdb__doc__input" })
151+
}
152+
}
153+
144154
let restUi = getDiffUi (diffPatch[DIFFCONST.REST], diffState)
145-
uiFrame=restUi
155+
// merge patchlist & rest list
156+
let merged = [...uiArray, ...restUi];
157+
uiFrame = merged
146158
}
147159
}
148160
else if(diffPatch[DIFFCONST.OPERATION] === DIFFCONST.KEEP_LIST) {

0 commit comments

Comments
 (0)