Skip to content

Commit cc6f505

Browse files
committed
more refactoring!
1 parent 400a13c commit cc6f505

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

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

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ qx.Class.define("osparc.data.model.StudyUI", {
3838
});
3939

4040
if ("annotations" in studyDataUI) {
41-
this.__annotationsInitData = studyDataUI["annotations"];
41+
Object.entries(studyDataUI["annotations"]).forEach(([annotationId, annotationData]) => {
42+
const annotation = new osparc.workbench.Annotation(annotationData, annotationId);
43+
this.addAnnotation(annotation);
44+
});
4245
}
4346
},
4447

@@ -99,22 +102,12 @@ qx.Class.define("osparc.data.model.StudyUI", {
99102
},
100103

101104
members: {
102-
__annotationsInitData: null,
103-
104105
__applyMode: function(mode) {
105106
if (mode === "guided") {
106107
this.setMode("app");
107108
}
108109
},
109110

110-
getAnnotationsInitData: function() {
111-
return this.__annotationsInitData;
112-
},
113-
114-
nullAnnotationsInitData: function() {
115-
this.__annotationsInitData = null;
116-
},
117-
118111
addAnnotation: function(annotation) {
119112
this.getAnnotations()[annotation.getId()] = annotation;
120113
},

services/static-webserver/client/source/class/osparc/workbench/WorkbenchUI.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,15 +1188,10 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
11881188
},
11891189

11901190
__renderAnnotations: function(studyUI) {
1191-
const initData = studyUI.getAnnotationsInitData();
1192-
const annotations = initData ? initData : studyUI.getAnnotations();
1193-
Object.entries(annotations).forEach(([annotationId, annotation]) => {
1194-
const annotationData = annotation instanceof osparc.workbench.Annotation ? annotation.serialize() : annotation;
1195-
this.__addAnnotation(annotationData, annotationId);
1191+
const annotations = studyUI.getAnnotations();
1192+
Object.values(annotations).forEach(annotation => {
1193+
this.__renderAnnotation(annotation);
11961194
});
1197-
if (initData) {
1198-
studyUI.nullAnnotationsInitData();
1199-
}
12001195
},
12011196

12021197
__setSelectedItem: function(newID) {
@@ -2009,12 +2004,18 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
20092004
this.__toolHint.setValue(null);
20102005
},
20112006

2012-
__addAnnotation: function(data, id) {
2013-
const annotation = new osparc.workbench.Annotation(data, id);
2007+
__addAnnotation: function(annotationData, id) {
2008+
const annotation = new osparc.workbench.Annotation(annotationData, id);
2009+
this.getStudy().getUi().addAnnotation(annotation);
2010+
2011+
this.__renderAnnotation(annotation);
2012+
},
2013+
2014+
__renderAnnotation: function(annotation) {
20142015
annotation.setSvgCanvas(this.__svgLayer);
2016+
20152017
this.__addAnnotationListeners(annotation);
20162018
this.__annotations[annotation.getId()] = annotation;
2017-
this.getStudy().getUi().addAnnotation(annotation);
20182019

20192020
if (annotation.getType() === osparc.workbench.Annotation.TYPES.CONVERSATION) {
20202021
osparc.store.Conversations.getInstance().addListener("conversationDeleted", e => {

0 commit comments

Comments
 (0)