Skip to content

Commit f64d366

Browse files
committed
refactor
1 parent bcc60b5 commit f64d366

File tree

1 file changed

+37
-25
lines changed

1 file changed

+37
-25
lines changed

services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", {
1010

1111
construct: function(resourceData, showOrganizations = true) {
1212
this.base(arguments, "collaboratorsManager", this.tr("Share with"));
13+
1314
this.set({
1415
layout: new qx.ui.layout.VBox(5),
1516
allowMinimize: false,
@@ -43,42 +44,54 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", {
4344
members: {
4445
__resourceData: null,
4546
__showOrganizations: null,
46-
__textFilter: null,
47+
4748
__collabButtonsContainer: null,
4849
__searchingCollaborators: null,
4950
__searchDelayer: null,
5051
__shareButton: null,
5152
__selectedCollaborators: null,
5253
__potentialCollaborators: null,
5354

55+
_createChildControlImpl: function(id) {
56+
let control;
57+
switch (id) {
58+
case "intro-text": {
59+
let text = this.__showOrganizations ?
60+
this.tr("Select users or organizations from the list below.") :
61+
this.tr("Select users from the list below.");
62+
text += this.tr("<br>Search them if they aren't listed.");
63+
control = new qx.ui.basic.Label().set({
64+
value: text,
65+
rich: true,
66+
wrap: true,
67+
paddingBottom: 5
68+
});
69+
this.add(control);
70+
break;
71+
}
72+
case "text-filter": {
73+
control = new osparc.filter.TextFilter("name", "collaboratorsManager");
74+
control.setCompact(true);
75+
const filterTextField = control.getChildControl("textfield");
76+
filterTextField.setPlaceholder(this.tr("Search"));
77+
filterTextField.setBackgroundColor("transparent");
78+
this.addListener("appear", () => filterTextField.focus());
79+
this.add(control);
80+
break;
81+
}
82+
}
83+
return control || this.base(arguments, id);
84+
},
85+
5486
getActionButton: function() {
5587
return this.__shareButton;
5688
},
5789

5890
__renderLayout: function() {
59-
let text = this.__showOrganizations ?
60-
this.tr("Select users or organizations from the list below.") :
61-
this.tr("Select users from the list below.");
62-
text += this.tr("<br>Search them if they aren't listed.");
63-
const introLabel = new qx.ui.basic.Label().set({
64-
value: text,
65-
rich: true,
66-
wrap: true,
67-
paddingBottom: 5
68-
});
69-
this.add(introLabel);
91+
this.getChildControl("intro-text");
7092

71-
const toolbar = new qx.ui.container.Composite(new qx.ui.layout.HBox(10).set({
72-
alignY: "middle",
73-
}));
74-
const filter = this.__textFilter = new osparc.filter.TextFilter("name", "collaboratorsManager");
75-
filter.setCompact(true);
76-
const filterTextField = filter.getChildControl("textfield");
77-
filterTextField.setPlaceholder(this.tr("Search"));
78-
this.addListener("appear", () => filterTextField.focus());
79-
toolbar.add(filter, {
80-
flex: 1
81-
});
93+
const textFilter = this.getChildControl("text-filter");
94+
const filterTextField = textFilter.getChildControl("textfield");
8295
filterTextField.addListener("input", e => {
8396
const filterValue = e.getData();
8497
if (this.__searchDelayer) {
@@ -91,7 +104,6 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", {
91104
}, waitBeforeSearching);
92105
}
93106
});
94-
this.add(toolbar);
95107

96108
const collabButtonsContainer = this.__collabButtonsContainer = new qx.ui.container.Composite(new qx.ui.layout.VBox());
97109
const scrollContainer = new qx.ui.container.Scroll();
@@ -118,7 +130,7 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", {
118130

119131
__searchUsers: function() {
120132
this.__searchingCollaborators.show();
121-
const text = this.__textFilter.getChildControl("textfield").getValue();
133+
const text = this.getChildControl("text-filter").getChildControl("textfield").getValue();
122134
osparc.store.Users.getInstance().searchUsers(text)
123135
.then(users => {
124136
users.forEach(user => user["collabType"] = 2);

0 commit comments

Comments
 (0)