Skip to content

Commit c7b1efe

Browse files
committed
listenToStudyChanges
1 parent 18d423a commit c7b1efe

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ qx.Class.define("osparc.data.model.Study", {
259259
// ------ ignore for serializing ------
260260
},
261261

262+
events: {
263+
"updateStudyDocument": "qx.event.type.Data",
264+
},
265+
262266
statics: {
263267
IgnoreSerializationProps: [
264268
"permalink",
@@ -375,6 +379,22 @@ qx.Class.define("osparc.data.model.Study", {
375379
},
376380

377381
members: {
382+
listenToStudyChanges: function() {
383+
const propertyKeys = this.self().getProperties();
384+
propertyKeys.forEach(key => {
385+
if (!this.self().IgnoreSerializationProps.includes(key)) {
386+
this.addListener("change" + qx.lang.String.firstUp(key), e => {
387+
const data = e.getData();
388+
this.fireDataEvent("updateStudyDocument", {
389+
"op": "replace",
390+
"path": "/" + key,
391+
"value": data
392+
});
393+
}, this);
394+
}
395+
});
396+
},
397+
378398
serialize: function(clean = true) {
379399
let jsonObject = {};
380400
const propertyKeys = this.self().getProperties();

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ qx.Class.define("osparc.desktop.StudyEditor", {
146146

147147
study.openStudy()
148148
.then(studyData => {
149+
study.listenToStudyChanges();
150+
149151
this.__setStudyDataInBackend(studyData);
150152

151153
this.__workbenchView.setStudy(study);

0 commit comments

Comments
 (0)