Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -731,7 +729,7 @@ qx.Class.define("osparc.data.model.Study", {
}
return Promise.all(promises)
.then(() => {
return sourceStudy;
return studySource;
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -794,11 +795,11 @@ qx.Class.define("osparc.data.model.Workbench", {
return;
}

const nodeData = node.serialize();
// use the node data that was used to check the diffs
const nodeData = workbenchSource[nodeId];
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Loading