diff --git a/services/static-webserver/client/source/class/osparc/data/model/Study.js b/services/static-webserver/client/source/class/osparc/data/model/Study.js index a0777d034b43..f95c17a80493 100644 --- a/services/static-webserver/client/source/class/osparc/data/model/Study.js +++ b/services/static-webserver/client/source/class/osparc/data/model/Study.js @@ -699,14 +699,12 @@ qx.Class.define("osparc.data.model.Study", { /** * Call patch Study, but the changes were already applied on the frontend * @param studyDiffs {Object} Diff Object coming from the JsonDiffPatch lib. Use only the keys, not the changes. - * @param sourceStudy {Object} Study object that was used to apply the diffs on the frontend. + * @param studySource {Object} Study object that was used to check the diffs on the frontend. */ - patchStudyDelayed: function(studyDiffs, sourceStudy) { + patchStudyDelayed: function(studyDiffs, studySource) { const promises = []; - let workbenchDiffs = {}; if ("workbench" in studyDiffs) { - workbenchDiffs = studyDiffs["workbench"]; - promises.push(this.getWorkbench().patchWorkbenchDelayed(workbenchDiffs)); + promises.push(this.getWorkbench().patchWorkbenchDelayed(studyDiffs["workbench"], studySource["workbench"])); delete studyDiffs["workbench"]; } const fieldKeys = Object.keys(studyDiffs); @@ -731,7 +729,7 @@ qx.Class.define("osparc.data.model.Study", { } return Promise.all(promises) .then(() => { - return sourceStudy; + return studySource; }); } } diff --git a/services/static-webserver/client/source/class/osparc/data/model/Workbench.js b/services/static-webserver/client/source/class/osparc/data/model/Workbench.js index 02917b2730e7..3e0d3eea769a 100644 --- a/services/static-webserver/client/source/class/osparc/data/model/Workbench.js +++ b/services/static-webserver/client/source/class/osparc/data/model/Workbench.js @@ -784,8 +784,9 @@ qx.Class.define("osparc.data.model.Workbench", { /** * Call patch Node, but the changes were already applied on the frontend * @param workbenchDiffs {Object} Diff Object coming from the JsonDiffPatch lib. Use only the keys, not the changes. + * @param workbenchSource {Object} Workbench object that was used to check the diffs on the frontend. */ - patchWorkbenchDelayed: function(workbenchDiffs) { + patchWorkbenchDelayed: function(workbenchDiffs, workbenchSource) { const promises = []; Object.keys(workbenchDiffs).forEach(nodeId => { const node = this.getNode(nodeId); @@ -793,12 +794,16 @@ qx.Class.define("osparc.data.model.Workbench", { // the node was removed return; } + // use the node data that was used to check the diffs + const nodeData = workbenchSource[nodeId]; + if (!nodeData) { + // skip if nodeData is undefined or null + return; + } - const nodeData = node.serialize(); let patchData = {}; if (workbenchDiffs[nodeId] instanceof Array) { - // if workbenchDiffs is an array means that the node was either added or removed - // the node was added + // if workbenchDiffs is an array means that the node was added patchData = nodeData; } else { // patch only what was changed diff --git a/services/static-webserver/client/source/class/osparc/desktop/StudyEditor.js b/services/static-webserver/client/source/class/osparc/desktop/StudyEditor.js index 65f28d23962b..154c1a837861 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/StudyEditor.js +++ b/services/static-webserver/client/source/class/osparc/desktop/StudyEditor.js @@ -858,20 +858,18 @@ qx.Class.define("osparc.desktop.StudyEditor", { __getStudyDiffs: function() { const sourceStudy = this.getStudy().serialize(); + const studyDiffs = { + sourceStudy, + delta: {}, + } const delta = osparc.wrapper.JsonDiffPatch.getInstance().diff(this.__studyDataInBackend, sourceStudy); if (delta) { // lastChangeDate and creationDate should not be taken into account as data change delete delta["creationDate"]; delete delta["lastChangeDate"]; - return { - sourceStudy, - delta, - }; + studyDiffs.delta = delta; } - return { - sourceStudy, - delta: {}, - }; + return studyDiffs; }, didStudyChange: function() {