Skip to content

Commit bb29013

Browse files
committed
add members
1 parent aace607 commit bb29013

File tree

1 file changed

+31
-17
lines changed
  • services/static-webserver/client/source/class/osparc/desktop/organizations

1 file changed

+31
-17
lines changed

services/static-webserver/client/source/class/osparc/desktop/organizations/MembersList.js

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ qx.Class.define("osparc.desktop.organizations.MembersList", {
7575
members: {
7676
__currentOrg: null,
7777
__introLabel: null,
78-
__memberInvitation: null,
78+
__memberInvitationButton: null,
7979
__changeRoleLabel: null,
8080
__membersModel: null,
8181

@@ -116,25 +116,39 @@ qx.Class.define("osparc.desktop.organizations.MembersList", {
116116
},
117117

118118
__getMemberInvitation: function() {
119-
const hBox = this.__memberInvitation = new qx.ui.container.Composite(new qx.ui.layout.HBox(10).set({
120-
alignY: "middle"
121-
}));
122-
123-
const newMemberUserName = new qx.ui.form.TextField().set({
124-
required: true,
125-
placeholder: this.tr(" New Member's username")
126-
});
127-
hBox.add(newMemberUserName, {
128-
flex: 1
119+
const addBtn = this.__memberInvitationButton = new qx.ui.form.Button().set({
120+
appearance: "strong-button",
121+
label: this.tr("Add Member..."),
122+
allowGrowX: false,
129123
});
130-
131-
const addBtn = new qx.ui.form.Button(this.tr("Add"));
132124
addBtn.addListener("execute", function() {
133-
this.__addMember(newMemberUserName.getValue());
125+
const serializedData = this.__currentOrg.serialize();
126+
serializedData["resourceType"] = "organization";
127+
const showOrganizations = false;
128+
const collaboratorsManager = new osparc.share.NewCollaboratorsManager(serializedData, showOrganizations);
129+
collaboratorsManager.setCaption("Add Member");
130+
collaboratorsManager.getActionButton().setLabel(this.tr("Add"));
131+
collaboratorsManager.addListener("addCollaborators", e => {
132+
const selectedMembers = e.getData();
133+
if (selectedMembers.length) {
134+
const promises = [];
135+
const usersStore = osparc.store.Users.getInstance();
136+
selectedMembers.forEach(selectedMemberGId => promises.push(usersStore.getUser(selectedMemberGId)));
137+
Promise.all(promises)
138+
.then(users => {
139+
users.forEach(user => this.__addMember(user.getUsername()));
140+
})
141+
.catch(err => {
142+
console.error(err);
143+
})
144+
.finally(collaboratorsManager.close());
145+
} else {
146+
collaboratorsManager.close();
147+
}
148+
}, this);
134149
}, this);
135-
hBox.add(addBtn);
136150

137-
return hBox;
151+
return addBtn;
138152
},
139153

140154
__getRolesToolbar: function() {
@@ -241,7 +255,7 @@ qx.Class.define("osparc.desktop.organizations.MembersList", {
241255
this.tr("You can't add new members to this Organization. Please contact an Administrator or Manager.");
242256
this.__introLabel.setValue(introText);
243257

244-
this.__memberInvitation.set({
258+
this.__memberInvitationButton.set({
245259
enabled: canIWrite
246260
});
247261

0 commit comments

Comments
 (0)