Skip to content

Commit 3d49266

Browse files
committed
Renaming working
1 parent 42d2e07 commit 3d49266

File tree

4 files changed

+39
-11
lines changed

4 files changed

+39
-11
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ qx.Class.define("osparc.store.Conversations", {
2525
this.__projectConversations = {};
2626
},
2727

28+
events: {
29+
"conversationUpdated": "qx.event.type.Data",
30+
},
31+
2832
members: {
2933
__projectConversations: null,
3034

@@ -59,7 +63,10 @@ qx.Class.define("osparc.store.Conversations", {
5963
}
6064
};
6165
return osparc.data.Resources.fetch("conversations", "addConversation", params)
62-
.then
66+
.then(conversation => {
67+
// OM add to cache
68+
return conversation;
69+
})
6370
.catch(err => osparc.FlashMessenger.logError(err));
6471
},
6572

@@ -85,6 +92,13 @@ qx.Class.define("osparc.store.Conversations", {
8592
}
8693
};
8794
return osparc.data.Resources.fetch("conversations", "renameConversation", params)
95+
.then(() => {
96+
this.fireDataEvent("conversationUpdated", {
97+
studyId,
98+
conversationId,
99+
name,
100+
});
101+
})
88102
.catch(err => osparc.FlashMessenger.logError(err));
89103
},
90104

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ qx.Class.define("osparc.workbench.Annotation", {
3939
}
4040
this.set({
4141
id,
42-
type: data.type,
4342
color,
44-
attributes: data.attributes
43+
attributes: data.attributes,
44+
type: data.type,
4545
});
4646
},
4747

@@ -69,7 +69,8 @@ qx.Class.define("osparc.workbench.Annotation", {
6969
"text", // osparc.workbench.Annotation.TYPES.TEXT
7070
"conversation", // osparc.workbench.Annotation.TYPES.CONVERSATION
7171
],
72-
nullable: false
72+
nullable: false,
73+
apply: "__drawAnnotation"
7374
},
7475

7576
color: {
@@ -83,7 +84,6 @@ qx.Class.define("osparc.workbench.Annotation", {
8384
attributes: {
8485
check: "Object",
8586
nullable: false,
86-
apply: "__drawAnnotation"
8787
},
8888

8989
representation: {
@@ -101,11 +101,12 @@ qx.Class.define("osparc.workbench.Annotation", {
101101
members: {
102102
__svgLayer: null,
103103

104-
__drawAnnotation: function(attrs) {
104+
__drawAnnotation: function() {
105105
if (this.__svgLayer === null) {
106106
return;
107107
}
108108

109+
const attrs = this.getAttributes();
109110
let representation = null;
110111
switch (this.getType()) {
111112
case this.self().TYPES.NOTE: {
@@ -120,7 +121,16 @@ qx.Class.define("osparc.workbench.Annotation", {
120121
representation = this.__svgLayer.drawAnnotationText(attrs.x, attrs.y, attrs.text, this.getColor(), attrs.fontSize);
121122
break;
122123
case this.self().TYPES.CONVERSATION: {
123-
representation = this.__svgLayer.drawAnnotationConversation(attrs.x, attrs.y, attrs.title);
124+
representation = this.__svgLayer.drawAnnotationConversation(attrs.x, attrs.y, attrs.text);
125+
const conversationId = attrs.conversationId;
126+
if (conversationId) {
127+
osparc.store.Conversations.getInstance().addListener("conversationUpdated", e => {
128+
const data = e.getData();
129+
if (data.conversationId === conversationId) {
130+
this.setText(data.name);
131+
}
132+
}, this);
133+
}
124134
break;
125135
}
126136
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1997,7 +1997,7 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
19971997
osparc.store.Conversations.getInstance().addConversation(this.getStudy().getUuid(), conversationTitle, osparc.study.Conversations.TYPES.PROJECT_ANNOTATION)
19981998
.then(conversationData => {
19991999
serializeData.attributes.conversationId = conversationData["conversationId"];
2000-
serializeData.attributes.title = conversationData["name"];
2000+
serializeData.attributes.text = conversationData["name"];
20012001
this.__addAnnotation(serializeData);
20022002
osparc.study.Conversations.popUpInWindow(this.getStudy().serialize(), conversationData["conversationId"]);
20032003
});

services/static-webserver/client/source/class/osparc/wrapper/Svg.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ qx.Class.define("osparc.wrapper.Svg", {
321321
})
322322
.move(padding + iconSize + 8, ((bubbleHeight - titleFontSize) / 2) - 3);
323323
bubble.add(label);
324+
bubble.label = label; // store reference for renaming
324325

325326
// Compute available width for text
326327
const availableWidth = bubbleWidth - padding * 2 - iconSize - 8;
@@ -363,12 +364,15 @@ qx.Class.define("osparc.wrapper.Svg", {
363364
return bubble;
364365
},
365366

366-
updateText: function(representation, label) {
367+
updateText: function(representation, newText) {
367368
if (representation.type === "text") {
368-
representation.text(label);
369+
representation.text(newText);
369370
} else if (representation.type === "svg") {
370371
// nested
371-
representation["textChild"].innerText = label;
372+
representation["textChild"].innerText = newText;
373+
} else if (representation.type === "g") {
374+
// group
375+
representation.label.text(newText);
372376
}
373377
},
374378

0 commit comments

Comments
 (0)