Skip to content

Commit def2223

Browse files
authored
Merge branch 'master' into enh/second-app-for-s4l-lite
2 parents 3375a8b + ddd71db commit def2223

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -699,8 +699,9 @@ qx.Class.define("osparc.data.model.Study", {
699699
/**
700700
* Call patch Study, but the changes were already applied on the frontend
701701
* @param studyDiffs {Object} Diff Object coming from the JsonDiffPatch lib. Use only the keys, not the changes.
702+
* @param sourceStudy {Object} Study object that was used to apply the diffs on the frontend.
702703
*/
703-
patchStudyDelayed: function(studyDiffs) {
704+
patchStudyDelayed: function(studyDiffs, sourceStudy) {
704705
const promises = [];
705706
let workbenchDiffs = {};
706707
if ("workbench" in studyDiffs) {
@@ -730,12 +731,7 @@ qx.Class.define("osparc.data.model.Study", {
730731
}
731732
return Promise.all(promises)
732733
.then(() => {
733-
// A bit hacky, but it's not sent back to the backend
734-
this.set({
735-
lastChangeDate: new Date()
736-
});
737-
const studyData = this.serialize();
738-
return studyData;
734+
return sourceStudy;
739735
});
740736
}
741737
}

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -857,20 +857,26 @@ qx.Class.define("osparc.desktop.StudyEditor", {
857857
},
858858

859859
__getStudyDiffs: function() {
860-
const newObj = this.getStudy().serialize();
861-
const delta = osparc.wrapper.JsonDiffPatch.getInstance().diff(this.__studyDataInBackend, newObj);
860+
const sourceStudy = this.getStudy().serialize();
861+
const delta = osparc.wrapper.JsonDiffPatch.getInstance().diff(this.__studyDataInBackend, sourceStudy);
862862
if (delta) {
863863
// lastChangeDate and creationDate should not be taken into account as data change
864864
delete delta["creationDate"];
865865
delete delta["lastChangeDate"];
866-
return delta;
866+
return {
867+
sourceStudy,
868+
delta,
869+
};
867870
}
868-
return {};
871+
return {
872+
sourceStudy,
873+
delta: {},
874+
};
869875
},
870876

871877
didStudyChange: function() {
872878
const studyDiffs = this.__getStudyDiffs();
873-
return Boolean(Object.keys(studyDiffs).length);
879+
return Boolean(Object.keys(studyDiffs.delta).length);
874880
},
875881

876882
__checkStudyChanges: function() {
@@ -893,7 +899,7 @@ qx.Class.define("osparc.desktop.StudyEditor", {
893899

894900
this.__updatingStudy++;
895901
const studyDiffs = this.__getStudyDiffs();
896-
return this.getStudy().patchStudyDelayed(studyDiffs)
902+
return this.getStudy().patchStudyDelayed(studyDiffs.delta, studyDiffs.sourceStudy)
897903
.then(studyData => this.__setStudyDataInBackend(studyData))
898904
.catch(error => {
899905
if ("status" in error && error.status === 409) {

0 commit comments

Comments
 (0)