Skip to content

Commit 5a946a4

Browse files
committed
create conversation logic
1 parent 41012f5 commit 5a946a4

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ qx.Class.define("osparc.study.Conversations", {
2222
/**
2323
* @param studyData {Object} Study Data
2424
*/
25-
construct: function(studyData) {
25+
construct: function(studyData, openConversationId = null) {
2626
this.base(arguments);
2727

2828
this._setLayout(new qx.ui.layout.VBox());
2929

3030
this.__conversations = [];
31+
this.__openConversationId = openConversationId;
3132

3233
this.set({
3334
studyData,
@@ -51,7 +52,7 @@ qx.Class.define("osparc.study.Conversations", {
5152
PROJECT_ANNOTATION: "PROJECT_ANNOTATION",
5253
},
5354

54-
popUpInWindow: function(studyData) {
55+
popUpInWindow: function(studyData, openConversationId = null) {
5556
const conversations = new osparc.study.Conversations(studyData);
5657
const title = qx.locale.Manager.tr("Conversations");
5758
const viewWidth = 600;
@@ -161,6 +162,7 @@ qx.Class.define("osparc.study.Conversations", {
161162
},
162163

163164
members: {
165+
__openConversationId: null,
164166
__conversations: null,
165167
__newConversationButton: null,
166168
__wsHandlers: null,
@@ -259,7 +261,17 @@ qx.Class.define("osparc.study.Conversations", {
259261
osparc.data.Resources.fetch("conversations", "getConversationsPage", params)
260262
.then(conversations => {
261263
if (conversations.length) {
264+
// Sort conversations by created date, newest first
265+
conversations.sort((a, b) => new Date(b.created) - new Date(a.created));
262266
conversations.forEach(conversation => this.__addConversationPage(conversation));
267+
if (this.__openConversationId) {
268+
const conversationsLayout = this.getChildControl("conversations-layout");
269+
const conversation = conversationsLayout.getSelectables().find(c => c.getConversationId() === this.__openConversationId);
270+
if (conversation) {
271+
conversationsLayout.setSelection([conversation]);
272+
}
273+
this.__openConversationId = null; // reset it so it does not open again
274+
}
263275
} else {
264276
this.__addTempConversationPage();
265277
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,11 +1976,10 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
19761976
break;
19771977
}
19781978
case annotationTypes.CONVERSATION: {
1979-
const conversationTitle = `${x}, ${y}`;
1979+
const conversationTitle = `${initPos.x}, ${initPos.y}`;
19801980
osparc.study.Conversations.addConversation(this.getStudy().getUuid(), conversationTitle, osparc.study.Conversations.PROJECT_ANNOTATION)
19811981
.then(conversationData => {
1982-
console.log("Conversation created", conversationData);
1983-
osparc.study.Conversations.popUpInWindow(this.getStudy().serialize());
1982+
osparc.study.Conversations.popUpInWindow(this.getStudy().serialize(), conversationData["conversationId"]);
19841983
});
19851984
break;
19861985
}

0 commit comments

Comments
 (0)