Skip to content

Commit d3602f9

Browse files
committed
it moves
1 parent b6a63b3 commit d3602f9

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,30 @@ qx.Class.define("osparc.data.model.StudyUI", {
156156
this.getSlideshow().removeNode(nodeId);
157157
},
158158

159+
updateUiFromDiff: function(uiDiff) {
160+
if (uiDiff["workbench"]) {
161+
const currentStudy = osparc.store.Store.getInstance().getCurrentStudy();
162+
if (currentStudy) {
163+
Object.keys(uiDiff["workbench"]).forEach(nodeId => {
164+
const node = currentStudy.getWorkbench().getNode(nodeId);
165+
if (node) {
166+
if ("position" in uiDiff["workbench"][nodeId]) {
167+
const position = uiDiff["workbench"][nodeId]["position"];
168+
const newPos = node.getPosition();
169+
if ("x" in position) {
170+
newPos.x = position["x"][1];
171+
}
172+
if ("y" in position) {
173+
newPos.y = position["y"][1];
174+
}
175+
node.setPosition(newPos);
176+
}
177+
}
178+
});
179+
}
180+
}
181+
},
182+
159183
listenToChanges: function() {
160184
const propertyKeys = Object.keys(qx.util.PropertyUtil.getProperties(osparc.data.model.StudyUI));
161185
this.self().ListenChangesProps.forEach(key => {

services/static-webserver/client/source/class/osparc/desktop/StudyEditor.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,10 @@ qx.Class.define("osparc.desktop.StudyEditor", {
331331

332332
const delta = osparc.wrapper.JsonDiffPatch.getInstance().diff(myStudy, updatedStudy);
333333
console.log("projectDocument:updated delta", myStudy, updatedStudy, delta);
334+
if ("ui" in delta) {
335+
this.getStudy().getUi().updateUiFromDiff(delta["ui"]);
336+
delete delta["ui"];
337+
}
334338
}
335339
}, this);
336340
}

services/static-webserver/client/source/class/osparc/workbench/NodeUI.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,10 @@ qx.Class.define("osparc.workbench.NodeUI", {
341341
},
342342

343343
__applyNode: function(node) {
344+
node.addListener("changePosition", e => {
345+
this.moveNodeTo(e.getData());
346+
});
347+
344348
if (node.isDynamic()) {
345349
const startButton = new qx.ui.menu.Button().set({
346350
label: this.tr("Start"),

0 commit comments

Comments
 (0)