Skip to content

Commit 5057505

Browse files
committed
patch
1 parent 35f9409 commit 5057505

File tree

2 files changed

+14
-15
lines changed
  • services/static-webserver/client/source/class/osparc

2 files changed

+14
-15
lines changed

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

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -680,13 +680,7 @@ qx.Class.define("osparc.data.model.Study", {
680680
}
681681

682682
return new Promise((resolve, reject) => {
683-
const params = {
684-
url: {
685-
"studyId": this.getUuid()
686-
},
687-
data: studyChanges
688-
};
689-
osparc.data.Resources.fetch("studies", "patch", params)
683+
osparc.store.Study.patchStudy(this.getUuid(), studyChanges)
690684
.then(() => {
691685
Object.keys(studyChanges).forEach(fieldKey => {
692686
const upKey = qx.lang.String.firstUp(fieldKey);
@@ -717,22 +711,17 @@ qx.Class.define("osparc.data.model.Study", {
717711
}
718712
const fieldKeys = Object.keys(studyDiffs);
719713
if (fieldKeys.length) {
720-
const patchData = {};
721-
const params = {
722-
url: {
723-
"studyId": this.getUuid()
724-
},
725-
data: patchData
726-
};
727714
fieldKeys.forEach(fieldKey => {
715+
// OM: can this be called all together?
716+
const patchData = {};
728717
if (fieldKey === "ui") {
729718
patchData[fieldKey] = this.getUi().serialize();
730719
} else {
731720
const upKey = qx.lang.String.firstUp(fieldKey);
732721
const getter = "get" + upKey;
733722
patchData[fieldKey] = this[getter](studyDiffs[fieldKey]);
734723
}
735-
promises.push(osparc.data.Resources.fetch("studies", "patch", params))
724+
promises.push(osparc.store.Study.patchStudy(this.getUuid(), patchData))
736725
});
737726
}
738727
return Promise.all(promises)

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ qx.Class.define("osparc.store.Study", {
6565
.catch(err => console.error(err));
6666
},
6767

68+
patchStudy: function(studyId, patchData) {
69+
const params = {
70+
url: {
71+
studyId,
72+
},
73+
data: patchData
74+
};
75+
return osparc.data.Resources.fetch("studies", "patch", params);
76+
},
77+
6878
trashStudy: function(studyId) {
6979
const params = {
7080
url: {

0 commit comments

Comments
 (0)