Skip to content

Commit c1f9e7e

Browse files
committed
CommentsList refactor
1 parent f18035e commit c1f9e7e

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

services/static-webserver/client/source/class/osparc/dashboard/ResourceDetails.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -522,14 +522,8 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
522522
this.__addOpenButton(page);
523523

524524
const lazyLoadContent = () => {
525-
const commentsList = new osparc.info.CommentsList(resourceData["uuid"]);
525+
const commentsList = new osparc.info.CommentsList(resourceData);
526526
page.addToContent(commentsList);
527-
if (osparc.data.model.Study.canIWrite(resourceData["accessRights"])) {
528-
const addComment = new osparc.info.CommentAdd(resourceData["uuid"]);
529-
addComment.setPaddingLeft(10);
530-
addComment.addListener("commentAdded", () => commentsList.fetchComments());
531-
page.addToFooter(addComment);
532-
}
533527
}
534528
page.addListenerOnce("appear", lazyLoadContent, this);
535529

services/static-webserver/client/source/class/osparc/info/CommentsList.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ qx.Class.define("osparc.info.CommentsList", {
2020
extend: qx.ui.core.Widget,
2121

2222
/**
23-
* @param studyId {String} Study Id
23+
* @param studyData {String} Study Data
2424
*/
25-
construct: function(studyId) {
25+
construct: function(studyData) {
2626
this.base(arguments);
2727

28-
this.__studyId = studyId;
28+
this.__studyData = studyData;
2929

3030
this._setLayout(new qx.ui.layout.VBox(10));
3131

@@ -35,6 +35,7 @@ qx.Class.define("osparc.info.CommentsList", {
3535
},
3636

3737
members: {
38+
__studyData: null,
3839
__nextRequestParams: null,
3940

4041
_createChildControlImpl: function(id) {
@@ -50,13 +51,23 @@ qx.Class.define("osparc.info.CommentsList", {
5051
control = new qx.ui.container.Composite(new qx.ui.layout.VBox(5)).set({
5152
alignY: "middle"
5253
});
53-
this._add(control);
54+
this._add(control, {
55+
flex: 1
56+
});
5457
break;
5558
case "load-more-button":
5659
control = new osparc.ui.form.FetchButton(this.tr("Load more comments..."));
5760
control.addListener("execute", () => this.fetchComments(false));
5861
this._add(control);
5962
break;
63+
case "add-comment":
64+
if (osparc.data.model.Study.canIWrite(this.__studyData["accessRights"])) {
65+
control = new osparc.info.CommentAdd(this.__studyData["uuid"]);
66+
control.setPaddingLeft(10);
67+
control.addListener("commentAdded", () => this.fetchComments());
68+
this._add(control);
69+
}
70+
break;
6071
}
6172

6273
return control || this.base(arguments, id);
@@ -66,6 +77,7 @@ qx.Class.define("osparc.info.CommentsList", {
6677
this.getChildControl("title");
6778
this.getChildControl("comments-list");
6879
this.getChildControl("load-more-button");
80+
this.getChildControl("add-comment");
6981
},
7082

7183
fetchComments: function(removeComments = true) {
@@ -92,7 +104,7 @@ qx.Class.define("osparc.info.CommentsList", {
92104
__getNextRequest: function() {
93105
const params = {
94106
url: {
95-
studyId: this.__studyId,
107+
studyId: this.__studyData["uuid"],
96108
offset: 0,
97109
limit: 20
98110
}

0 commit comments

Comments
 (0)