Skip to content

Commit b5986df

Browse files
committed
minor
1 parent f3f5fa8 commit b5986df

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

services/static-webserver/client/source/class/osparc/data/model/Node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ qx.Class.define("osparc.data.model.Node", {
719719
});
720720
} else {
721721
this.fireDataEvent("projectDocumentChanged", {
722-
"op": "delete",
722+
"op": "remove",
723723
"path": `/ui/workbench/${this.getNodeId()}/marker`,
724724
"osparc-resource": "ui",
725725
});

services/static-webserver/client/source/class/osparc/data/model/StudyUI.js

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ qx.Class.define("osparc.data.model.StudyUI", {
146146
if (annotationId in this.getAnnotations()) {
147147
const annotation = this.getAnnotations()[annotationId]
148148
this.fireDataEvent("projectDocumentChanged", {
149-
"op": "delete",
149+
"op": "remove",
150150
"path": `/ui/annotations/${annotation.getId()}`,
151151
"osparc-resource": "study-ui",
152152
});
@@ -297,18 +297,23 @@ qx.Class.define("osparc.data.model.StudyUI", {
297297
if (currentStudy) {
298298
const node = currentStudy.getWorkbench().getNode(nodeId);
299299
if (path.includes("/position")) {
300-
this.__updateNodePositionFromPatch(node, op, path, value);
300+
this.__updateNodePositionFromPatch(node, patch);
301301
}
302302
if (path.includes("/marker")) {
303-
this.__updateNodeMarkerFromPatch(node, op, path, value);
303+
this.__updateNodeMarkerFromPatch(node, patch);
304304
}
305305
}
306+
} else if (path.startsWith("/ui/annotations/")) {
307+
this.__updateAnnotationFromPatch(patch);
306308
}
307309
});
308310
},
309311

310-
__updateNodePositionFromPatch: function(node, op, path, value) {
312+
__updateNodePositionFromPatch: function(node, patch) {
311313
if (node) {
314+
const op = patch.op;
315+
const path = patch.path;
316+
const value = patch.value;
312317
if (op === "replace") {
313318
const newPos = node.getPosition();
314319
if (path.includes("/position/x")) {
@@ -322,8 +327,11 @@ qx.Class.define("osparc.data.model.StudyUI", {
322327
}
323328
},
324329

325-
__updateNodeMarkerFromPatch: function(node, op, path, value) {
330+
__updateNodeMarkerFromPatch: function(node, patch) {
326331
if (node) {
332+
const op = patch.op;
333+
const path = patch.path;
334+
const value = patch.value;
327335
if (op === "delete" || value === null) {
328336
// it was removed
329337
node.setMarker(null);
@@ -339,6 +347,23 @@ qx.Class.define("osparc.data.model.StudyUI", {
339347
}
340348
},
341349

350+
__updateAnnotationFromPatch: function(patch) {
351+
const op = patch.op;
352+
const path = patch.path;
353+
const value = patch.value;
354+
const annotationId = path.split("/")[3];
355+
console.log("Updating annotation from patch", patch);
356+
if (op === "add") {
357+
this.addAnnotation(value, annotationId);
358+
} else if (op === "remove") {
359+
// it was removed
360+
this.removeAnnotation(annotationId);
361+
} else if (op === "replace" && value) {
362+
// it was updated
363+
console.log("Updating annotation", annotationId, "with value", value);
364+
}
365+
},
366+
342367
listenToChanges: function() {
343368
const propertyKeys = Object.keys(qx.util.PropertyUtil.getProperties(osparc.data.model.StudyUI));
344369
this.self().ListenChangesProps.forEach(key => {

0 commit comments

Comments
 (0)