Skip to content

Commit 0574cb8

Browse files
committed
SuggestedQuestion
1 parent 320b4b8 commit 0574cb8

File tree

2 files changed

+83
-5
lines changed

2 files changed

+83
-5
lines changed

services/static-webserver/client/source/class/osparc/support/Conversation.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,23 @@ qx.Class.define("osparc.support.Conversation", {
103103
},
104104

105105
__applyConversationId: function(conversationId) {
106+
this.__reloadMessages(true);
107+
106108
const supportSuggestion = this.getChildControl("support-suggestion");
107-
if (conversationId) {
108-
supportSuggestion.exclude();
109-
this.__reloadMessages(true);
110-
} else {
111-
// new conversation, collect context data
109+
supportSuggestion.exclude();
110+
if (conversationId === null && osparc.store.Store.getInstance().getCurrentStudy()) {
112111
supportSuggestion.show();
112+
const suggestedQuestion = new osparc.support.SuggestedQuestion();
113+
const answers = [
114+
{ label: this.tr("No"), key: "no" },
115+
{ label: this.tr("Yes"), key: "yes" },
116+
];
117+
suggestedQuestion.isProjectRelated(answers);
118+
suggestedQuestion.addListener("questionAnswered", e => {
119+
const answer = e.getData();
120+
console.log(answer);
121+
});
122+
supportSuggestion.add(suggestedQuestion);
113123
}
114124
},
115125

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/* ************************************************************************
2+
3+
osparc - the simcore frontend
4+
5+
https://osparc.io
6+
7+
Copyright:
8+
2025 IT'IS Foundation, https://itis.swiss
9+
10+
License:
11+
MIT: https://opensource.org/licenses/MIT
12+
13+
Authors:
14+
* Odei Maiz (odeimaiz)
15+
16+
************************************************************************ */
17+
18+
19+
qx.Class.define("osparc.support.SuggestedQuestion", {
20+
extend: qx.ui.core.Widget,
21+
22+
construct: function() {
23+
this.base(arguments);
24+
25+
const layout = new qx.ui.layout.Grid(12, 4);
26+
layout.setColumnFlex(1, 1); // content
27+
this._setLayout(layout);
28+
this.setPadding(5);
29+
},
30+
31+
events: {
32+
"questionAnswered": "qx.event.type.Data",
33+
},
34+
35+
members: {
36+
isProjectRelated: function(answers) {
37+
this._removeAll();
38+
39+
const thumbnail = osparc.utils.Utils.createThumbnail(32).set({
40+
source: osparc.product.Utils.getIconUrl(),
41+
});
42+
this._add(thumbnail, {
43+
row: 0,
44+
column: 0,
45+
});
46+
47+
const question = new qx.ui.basic.Label(this.tr("Is your question related to this project?"));
48+
this._add(question, {
49+
row: 0,
50+
column: 1,
51+
});
52+
53+
const answersContainer = new qx.ui.container.Composite(new qx.ui.layout.HBox(10));
54+
answers.forEach(answer => {
55+
const button = new qx.ui.form.Button(answer.label).set({
56+
appearance: "strong-button",
57+
allowGrowX: false,
58+
});
59+
button.addListener("execute", () => this.fireDataEvent("questionAnswered", answer.key));
60+
answersContainer.add(button);
61+
});
62+
this._add(answersContainer, {
63+
row: 1,
64+
column: 1,
65+
});
66+
},
67+
}
68+
});

0 commit comments

Comments
 (0)