Skip to content

Commit 8b45ad4

Browse files
committed
rename and refactor
1 parent cd09172 commit 8b45ad4

File tree

7 files changed

+47
-33
lines changed

7 files changed

+47
-33
lines changed

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

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ qx.Class.define("osparc.data.model.Node", {
193193
},
194194

195195
events: {
196-
"updateStudyDocument": "qx.event.type.Data",
196+
"updateStudyDocument": "qx.event.type.Event",
197+
"projectDocumentChanged": "qx.event.type.Data",
197198
"reloadModel": "qx.event.type.Event",
198199
"retrieveInputs": "qx.event.type.Data",
199200
"keyChanged": "qx.event.type.Event",
@@ -701,22 +702,22 @@ qx.Class.define("osparc.data.model.Node", {
701702

702703
__applyMarker: function(marker) {
703704
if (marker) {
704-
this.fireDataEvent("updateStudyDocument", {
705+
this.fireDataEvent("projectDocumentChanged", {
705706
"op": "add",
706707
"path": `/ui/workbench/${this.getNodeId()}/marker`,
707708
"value": marker.getColor(),
708709
"osparc-resource": "ui",
709710
});
710711
marker.addListener("changeColor", e => {
711-
this.fireDataEvent("updateStudyDocument", {
712+
this.fireDataEvent("projectDocumentChanged", {
712713
"op": "replace",
713714
"path": `/ui/workbench/${this.getNodeId()}/marker`,
714715
"value": e.getData(),
715716
"osparc-resource": "ui",
716717
});
717718
});
718719
} else {
719-
this.fireDataEvent("updateStudyDocument", {
720+
this.fireDataEvent("projectDocumentChanged", {
720721
"op": "delete",
721722
"path": `/ui/workbench/${this.getNodeId()}/marker`,
722723
"osparc-resource": "ui",
@@ -1240,7 +1241,7 @@ qx.Class.define("osparc.data.model.Node", {
12401241
this.__posY = parseInt(y) < 0 ? 0 : parseInt(y);
12411242

12421243
const nodeId = this.getNodeId();
1243-
this.fireDataEvent("updateStudyDocument", {
1244+
this.fireDataEvent("projectDocumentChanged", {
12441245
"op": "replace",
12451246
"path": `/ui/workbench/${nodeId}/position`,
12461247
"value": {
@@ -1307,7 +1308,7 @@ qx.Class.define("osparc.data.model.Node", {
13071308
// listen to changes in the props form
13081309
this.getPropsForm()._form.addListener("changeData", () => {
13091310
const data = this.__getInputData();
1310-
this.fireDataEvent("updateStudyDocument", {
1311+
this.fireDataEvent("projectDocumentChanged", {
13111312
"op": "replace",
13121313
"path": `/workbench/${nodeId}/inputs`,
13131314
"value": data,
@@ -1317,7 +1318,7 @@ qx.Class.define("osparc.data.model.Node", {
13171318
// listen to changes in link and unlink of ports
13181319
this.getPropsForm().addListener("linkFieldModified", () => {
13191320
const data = this.__getInputData();
1320-
this.fireDataEvent("updateStudyDocument", {
1321+
this.fireDataEvent("projectDocumentChanged", {
13211322
"op": "replace",
13221323
"path": `/workbench/${nodeId}/inputs`,
13231324
"value": data,
@@ -1330,7 +1331,7 @@ qx.Class.define("osparc.data.model.Node", {
13301331
if (this.hasPropsForm()) {
13311332
this.getPropsForm().addListener("unitChanged", () => {
13321333
const data = this.__getInputUnits();
1333-
this.fireDataEvent("updateStudyDocument", {
1334+
this.fireDataEvent("projectDocumentChanged", {
13341335
"op": "replace",
13351336
"path": `/workbench/${nodeId}/inputsUnits`,
13361337
"value": data,
@@ -1342,7 +1343,7 @@ qx.Class.define("osparc.data.model.Node", {
13421343
case "inputNodes":
13431344
this.addListener("changeInputNodes", () => {
13441345
const data = this.getInputNodes();
1345-
this.fireDataEvent("updateStudyDocument", {
1346+
this.fireDataEvent("projectDocumentChanged", {
13461347
"op": "replace",
13471348
"path": `/workbench/${nodeId}/inputNodes`,
13481349
"value": data,
@@ -1353,7 +1354,7 @@ qx.Class.define("osparc.data.model.Node", {
13531354
case "inputsRequired":
13541355
this.addListener("changeInputsRequired", () => {
13551356
const data = this.getInputsRequired();
1356-
this.fireDataEvent("updateStudyDocument", {
1357+
this.fireDataEvent("projectDocumentChanged", {
13571358
"op": "replace",
13581359
"path": `/workbench/${nodeId}/inputsRequired`,
13591360
"value": data,
@@ -1365,7 +1366,7 @@ qx.Class.define("osparc.data.model.Node", {
13651366
if (this.isFilePicker()) {
13661367
this.getStatus().addListener("changeProgress", e => {
13671368
const data = e.getData();
1368-
this.fireDataEvent("updateStudyDocument", {
1369+
this.fireDataEvent("projectDocumentChanged", {
13691370
"op": "replace",
13701371
"path": `/workbench/${nodeId}/progress`,
13711372
"value": data,
@@ -1383,7 +1384,7 @@ qx.Class.define("osparc.data.model.Node", {
13831384
} else if (this.isParameter()) {
13841385
data = this.__getOutputsData();
13851386
}
1386-
this.fireDataEvent("updateStudyDocument", {
1387+
this.fireDataEvent("projectDocumentChanged", {
13871388
"op": "replace",
13881389
"path": `/workbench/${nodeId}/outputs`,
13891390
"value": data,
@@ -1396,7 +1397,7 @@ qx.Class.define("osparc.data.model.Node", {
13961397
if (propertyKeys.includes(key)) {
13971398
this.addListener("change" + qx.lang.String.firstUp(key), e => {
13981399
const data = e.getData();
1399-
this.fireDataEvent("updateStudyDocument", {
1400+
this.fireDataEvent("projectDocumentChanged", {
14001401
"op": "replace",
14011402
"path": `/workbench/${nodeId}/` + key,
14021403
"value": data,

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ qx.Class.define("osparc.data.model.Study", {
258258
},
259259

260260
events: {
261-
"updateStudyDocument": "qx.event.type.Data",
261+
"updateStudyDocument": "qx.event.type.Event",
262+
"projectDocumentChanged": "qx.event.type.Data",
262263
},
263264

264265
statics: {
@@ -399,23 +400,23 @@ qx.Class.define("osparc.data.model.Study", {
399400
this.self().ListenChangesProps.forEach(key => {
400401
switch (key) {
401402
case "workbench":
402-
this.getWorkbench().addListener("updateStudyDocument", e => {
403+
this.getWorkbench().addListener("projectDocumentChanged", e => {
403404
const data = e.getData();
404-
this.fireDataEvent("updateStudyDocument", data);
405+
this.fireDataEvent("projectDocumentChanged", data);
405406
}, this);
406407
break;
407408
case "ui":
408409
this.getUi().listenToChanges();
409-
this.getUi().addListener("updateStudyDocument", e => {
410+
this.getUi().addListener("projectDocumentChanged", e => {
410411
const data = e.getData();
411-
this.fireDataEvent("updateStudyDocument", data);
412+
this.fireDataEvent("projectDocumentChanged", data);
412413
}, this);
413414
break;
414415
default:
415416
if (propertyKeys.includes(key)) {
416417
this.addListener("change" + qx.lang.String.firstUp(key), e => {
417418
const data = e.getData();
418-
this.fireDataEvent("updateStudyDocument", {
419+
this.fireDataEvent("projectDocumentChanged", {
419420
"op": "replace",
420421
"path": "/" + key,
421422
"value": data,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ qx.Class.define("osparc.data.model.StudyUI", {
8686
},
8787

8888
events: {
89-
"updateStudyDocument": "qx.event.type.Data",
89+
"projectDocumentChanged": "qx.event.type.Data",
9090
},
9191

9292
statics: {
@@ -135,7 +135,7 @@ qx.Class.define("osparc.data.model.StudyUI", {
135135
if (propertyKeys.includes(key)) {
136136
this.addListener(`change${qx.lang.String.firstUp(key)}`, () => {
137137
const data = this.serialize();
138-
this.fireDataEvent("updateStudyDocument", {
138+
this.fireDataEvent("projectDocumentChanged", {
139139
"op": "replace",
140140
"path": `/ui/${key}`,
141141
"value": data,

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ qx.Class.define("osparc.data.model.Workbench", {
5050
},
5151

5252
events: {
53-
"updateStudyDocument": "qx.event.type.Data",
53+
"updateStudyDocument": "qx.event.type.Event",
54+
"projectDocumentChanged": "qx.event.type.Data",
5455
"restartAutoSaveTimer": "qx.event.type.Event",
5556
"pipelineChanged": "qx.event.type.Event",
5657
"reloadModel": "qx.event.type.Event",
@@ -275,11 +276,12 @@ qx.Class.define("osparc.data.model.Workbench", {
275276
const node = new osparc.data.model.Node(study, metadata, uuid);
276277
if (osparc.utils.Utils.eventDrivenPatch()) {
277278
node.listenToChanges();
279+
node.addListener("projectDocumentChanged", e => this.fireDataEvent("projectDocumentChanged", e.getData()), this);
278280
}
279-
node.addListener("updateStudyDocument", e => this.fireDataEvent("updateStudyDocument", e.getData()), this);
280281
node.addListener("keyChanged", () => this.fireEvent("reloadModel"), this);
281282
node.addListener("changeInputNodes", () => this.fireDataEvent("pipelineChanged"), this);
282283
node.addListener("reloadModel", () => this.fireEvent("reloadModel"), this);
284+
node.addListener("updateStudyDocument", e => this.fireEvent("updateStudyDocument"), this);
283285
osparc.utils.Utils.localCache.serviceToFavs(metadata.key);
284286
return node;
285287
},

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ qx.Class.define("osparc.desktop.StudyEditor", {
248248

249249
if (osparc.utils.Utils.eventDrivenPatch()) {
250250
study.listenToChanges(); // this includes the listener on the workbench and ui
251-
study.addListener("updateStudyDocument", e => this.updateStudyDocument(e.getData()), this);
251+
study.addListener("projectDocumentChanged", e => this.projectDocumentChanged(e.getData()), this);
252252
} else {
253253
workbench.addListener("updateStudyDocument", () => this.updateStudyDocument());
254254
workbench.addListener("restartAutoSaveTimer", () => this.__restartAutoSaveTimer());
@@ -906,17 +906,21 @@ qx.Class.define("osparc.desktop.StudyEditor", {
906906
/**
907907
* @param {JSON Patch} data It will soon be used to patch the study document https://datatracker.ietf.org/doc/html/rfc6902
908908
*/
909-
updateStudyDocument: function(data = null) {
909+
projectDocumentChanged: function(data) {
910+
if (osparc.utils.Utils.isDevelopmentPlatform()) {
911+
console.log("projectDocumentChanged", data);
912+
}
913+
914+
this.updateStudyDocument();
915+
},
916+
917+
updateStudyDocument: function() {
910918
if (!osparc.data.model.Study.canIWrite(this.getStudy().getAccessRights())) {
911919
return new Promise(resolve => {
912920
resolve();
913921
});
914922
}
915923

916-
if (osparc.utils.Utils.isDevelopmentPlatform()) {
917-
console.log("updateStudyDocument", data || "forced"); // For debugging purposes
918-
}
919-
920924
this.__updatingStudy++;
921925
const studyDiffs = this.__getStudyDiffs();
922926
return this.getStudy().patchStudyDelayed(studyDiffs.delta, studyDiffs.sourceStudy)

services/static-webserver/client/source/class/osparc/node/BootOptionsView.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ qx.Class.define("osparc.node.BootOptionsView", {
5454
"boot_mode": newBootModeId
5555
};
5656
node.setBootOptions(data);
57-
node.fireDataEvent("updateStudyDocument", {
57+
node.fireEvent("updateStudyDocument");
58+
// OM not sure it's needed
59+
node.fireDataEvent("projectDocumentChanged", {
5860
"op": "replace",
5961
"path": `/workbench/${nodeId}/bootOptions`,
6062
"value": data,

services/static-webserver/client/source/class/osparc/node/LifeCycleView.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,17 @@ qx.Class.define("osparc.node.LifeCycleView", {
111111
updateButton.addListener("execute", () => {
112112
updateButton.setFetching(true);
113113
const latestCompatible = osparc.store.Services.getLatestCompatible(node.getKey(), node.getVersion());
114+
const newData = {};
114115
if (node.getKey() !== latestCompatible["key"]) {
115-
node.setKey(latestCompatible["key"]);
116+
newData["key"] = latestCompatible["key"];
116117
}
117118
if (node.getVersion() !== latestCompatible["version"]) {
118-
node.setVersion(latestCompatible["version"]);
119+
newData["version"] = latestCompatible["version"];
119120
}
120-
node.fireDataEvent("updateStudyDocument", [{
121+
node.set(newData);
122+
node.fireEvent("updateStudyDocument");
123+
// OM not sure it's needed
124+
node.fireDataEvent("projectDocumentChanged", [{
121125
"op": "replace",
122126
"path": `/workbench/${nodeId}/key`,
123127
"value": latestCompatible["key"],

0 commit comments

Comments
 (0)