Skip to content

Commit ec4b52b

Browse files
committed
marker and position
1 parent f65be44 commit ec4b52b

File tree

1 file changed

+39
-4
lines changed
  • services/static-webserver/client/source/class/osparc/data/model

1 file changed

+39
-4
lines changed

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

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ qx.Class.define("osparc.data.model.Node", {
171171
check: "qx.core.Object",
172172
init: null,
173173
nullable: true,
174-
event: "changeMarker"
174+
event: "changeMarker",
175+
apply: "__applyMarker",
175176
},
176177

177178
inputConnected: {
@@ -683,6 +684,30 @@ qx.Class.define("osparc.data.model.Node", {
683684
this.setMarker(null);
684685
},
685686

687+
__applyMarker: function(marker, oldMarker) {
688+
if (marker && oldMarker) {
689+
this.fireDataEvent("updateStudyDocument", {
690+
"op": "replace",
691+
"path": `/ui/workbench/${this.getNodeId()}/marker`,
692+
"value": marker.getColor(),
693+
"osparc-resource": "ui",
694+
});
695+
} else if (marker && oldMarker === null) {
696+
this.fireDataEvent("updateStudyDocument", {
697+
"op": "add",
698+
"path": `/ui/workbench/${this.getNodeId()}/marker`,
699+
"value": marker.getColor(),
700+
"osparc-resource": "ui",
701+
});
702+
} else {
703+
this.fireDataEvent("updateStudyDocument", {
704+
"op": "delete",
705+
"path": `/ui/workbench/${this.getNodeId()}/marker`,
706+
"osparc-resource": "ui",
707+
});
708+
}
709+
},
710+
686711
__setInputData: function(inputs) {
687712
if (this.__settingsForm && inputs) {
688713
const inputData = {};
@@ -1207,6 +1232,17 @@ qx.Class.define("osparc.data.model.Node", {
12071232
// keep positions positive
12081233
this.__posX = parseInt(x) < 0 ? 0 : parseInt(x);
12091234
this.__posY = parseInt(y) < 0 ? 0 : parseInt(y);
1235+
1236+
const nodeId = this.getNodeId();
1237+
this.fireDataEvent("updateStudyDocument", {
1238+
"op": "replace",
1239+
"path": `/ui/workbench/${nodeId}/position`,
1240+
"value": {
1241+
"x": this.__posX,
1242+
"y": this.__posY,
1243+
},
1244+
"osparc-resource": "ui",
1245+
});
12101246
},
12111247

12121248
getPosition: function() {
@@ -1311,9 +1347,8 @@ qx.Class.define("osparc.data.model.Node", {
13111347
},
13121348

13131349
serializeUI: function() {
1314-
const uiInfo = {
1315-
"position": this.getPosition(),
1316-
};
1350+
const uiInfo = {}
1351+
uiInfo["position"] = this.getPosition();
13171352
const marker = this.getMarker();
13181353
if (marker) {
13191354
uiInfo["marker"] = {

0 commit comments

Comments
 (0)