Skip to content

Commit cca8054

Browse files
authored
🎨 [Frontend] Display Contact information (#8302)
1 parent 95dde06 commit cca8054

File tree

6 files changed

+250
-77
lines changed

6 files changed

+250
-77
lines changed

services/static-webserver/client/source/class/osparc/auth/ui/RequestAccount.js

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -83,27 +83,12 @@ qx.Class.define("osparc.auth.ui.RequestAccount", {
8383
this._form.add(phone, this.tr("Phone Number"), null, "phone");
8484

8585

86-
const organization = new qx.ui.form.TextField();
87-
doubleSpaced.push(organization);
88-
switch (osparc.product.Utils.getProductName()) {
89-
case "s4l":
90-
this._form.add(organization, this.tr("Company Name"), null, "company");
91-
organization.setRequired(true);
92-
break;
93-
case "s4lacad":
94-
case "s4ldesktopacad":
95-
this._form.add(organization, this.tr("University"), null, "university");
96-
organization.setRequired(true);
97-
break;
98-
case "tiplite":
99-
this._form.add(organization, this.tr("University"), null, "university");
100-
break;
101-
case "tis":
102-
this._form.add(organization, this.tr("Organization"), null, "organization");
103-
break;
104-
case "osparc":
105-
this._form.add(organization, this.tr("Research Group/Organization"), null, "organization");
106-
break;
86+
const institution = new qx.ui.form.TextField();
87+
doubleSpaced.push(institution);
88+
const institutionAlias = osparc.product.Utils.getInstitutionAlias();
89+
this._form.add(institution, institutionAlias.label, null, institutionAlias.key);
90+
if (institutionAlias.required) {
91+
institution.setRequired(true);
10792
}
10893

10994

services/static-webserver/client/source/class/osparc/conversation/AddMessage.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,9 @@ qx.Class.define("osparc.conversation.AddMessage", {
7070
}
7171
case "thumbnail": {
7272
control = osparc.utils.Utils.createThumbnail(32);
73-
const authData = osparc.auth.Data.getInstance();
74-
const myUsername = authData.getUsername();
75-
const myEmail = authData.getEmail();
73+
const meGroup = osparc.store.Groups.getInstance().getGroupMe();
7674
control.set({
77-
source: osparc.utils.Avatar.emailToThumbnail(myEmail, myUsername, 32),
75+
source: meGroup.getThumbnail(),
7876
alignX: "center",
7977
alignY: "middle",
8078
marginRight: 8,

services/static-webserver/client/source/class/osparc/data/model/User.js

Lines changed: 85 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,6 @@ qx.Class.define("osparc.data.model.User", {
4444
} else if (userData["lastName"]) {
4545
lastName = userData["lastName"];
4646
}
47-
let description = [firstName, lastName].join(" ").trim(); // the null values will be replaced by empty strings
48-
if (email) {
49-
if (description) {
50-
description += " - "
51-
}
52-
description += email;
53-
}
5447

5548
this.set({
5649
userId,
@@ -60,10 +53,32 @@ qx.Class.define("osparc.data.model.User", {
6053
lastName,
6154
email,
6255
phoneNumber: userData["phone"] || null,
56+
});
57+
58+
let description = this.getFullName();
59+
if (email) {
60+
if (description) {
61+
description += " - "
62+
}
63+
description += email;
64+
}
65+
this.set({
6366
label: userData["userName"] || description,
6467
description,
6568
});
6669

70+
if (userData["contact"]) {
71+
const contact = userData["contact"];
72+
this.set({
73+
institution: contact["institution"] || null,
74+
address: contact["address"] || null,
75+
city: contact["city"] || null,
76+
state: contact["state"] || null,
77+
country: contact["country"] || null,
78+
postalCode: contact["postalCode"] || null,
79+
});
80+
}
81+
6782
// create the thumbnail after setting email and username
6883
this.set({
6984
thumbnail: this.createThumbnail(),
@@ -140,11 +155,74 @@ qx.Class.define("osparc.data.model.User", {
140155
init: "",
141156
event: "changeThumbnail",
142157
},
158+
159+
institution: {
160+
check: "String",
161+
nullable: true,
162+
init: null,
163+
event: "changeInstitution",
164+
},
165+
166+
address: {
167+
check: "String",
168+
nullable: true,
169+
init: null,
170+
event: "changeAddress",
171+
},
172+
173+
city: {
174+
check: "String",
175+
nullable: true,
176+
init: null,
177+
event: "changeCity",
178+
},
179+
180+
state: {
181+
check: "String",
182+
nullable: true,
183+
init: null,
184+
event: "changeState",
185+
},
186+
187+
country: {
188+
check: "String",
189+
nullable: true,
190+
init: null,
191+
event: "changeCountry",
192+
},
193+
194+
postalCode: {
195+
check: "String",
196+
nullable: true,
197+
init: null,
198+
event: "changePostalCode",
199+
},
200+
},
201+
202+
statics: {
203+
concatFullName: function(firstName, lastName) {
204+
return [firstName, lastName].filter(Boolean).join(" ");
205+
},
206+
207+
userDataToDescription: function(firstName, lastName, email) {
208+
let description = this.concatFullName(firstName, lastName);
209+
if (email) {
210+
if (description) {
211+
description += " - "
212+
}
213+
description += email;
214+
}
215+
return description;
216+
},
143217
},
144218

145219
members: {
146220
createThumbnail: function(size) {
147221
return osparc.utils.Avatar.emailToThumbnail(this.getEmail(), this.getUsername(), size);
148222
},
223+
224+
getFullName: function() {
225+
return this.self().concatFullName(this.getFirstName(), this.getLastName());
226+
},
149227
},
150228
});

services/static-webserver/client/source/class/osparc/desktop/account/MyAccount.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,18 @@ qx.Class.define("osparc.desktop.account.MyAccount", {
4646
},
4747

4848
statics: {
49-
createMiniProfileView: function(withSpacer = true) {
49+
createMiniProfileView: function(userData) {
5050
const layout = new qx.ui.container.Composite(new qx.ui.layout.VBox(6)).set({
5151
alignX: "center",
5252
minWidth: 120,
5353
maxWidth: 150
5454
});
5555

56-
const authData = osparc.auth.Data.getInstance();
57-
const username = authData.getUsername();
58-
const email = authData.getEmail();
56+
if (!userData) {
57+
userData = osparc.auth.Data.getInstance();
58+
}
59+
const username = userData.getUsername();
60+
const email = userData.getEmail();
5961
const avatarSize = 80;
6062
const img = new qx.ui.basic.Image().set({
6163
source: osparc.utils.Avatar.emailToThumbnail(email, username, avatarSize),
@@ -73,33 +75,31 @@ qx.Class.define("osparc.desktop.account.MyAccount", {
7375
font: "text-14",
7476
alignX: "center"
7577
});
76-
authData.bind("username", usernameLabel, "value");
78+
userData.bind("username", usernameLabel, "value");
7779
layout.add(usernameLabel);
7880

7981
const fullNameLabel = new qx.ui.basic.Label().set({
8082
font: "text-13",
8183
alignX: "center"
8284
});
8385
layout.add(fullNameLabel);
84-
authData.bind("firstName", fullNameLabel, "value", {
85-
converter: () => authData.getFullName()
86+
userData.bind("firstName", fullNameLabel, "value", {
87+
converter: () => userData.getFullName()
8688
});
87-
authData.bind("lastName", fullNameLabel, "value", {
88-
converter: () => authData.getFullName()
89+
userData.bind("lastName", fullNameLabel, "value", {
90+
converter: () => userData.getFullName()
8991
});
9092

91-
if (authData.getRole() !== "user") {
92-
const role = authData.getFriendlyRole();
93+
if (userData.getRole() !== "user") {
94+
const role = userData.getFriendlyRole();
9395
const roleLabel = new qx.ui.basic.Label(role).set({
9496
font: "text-13",
9597
alignX: "center"
9698
});
9799
layout.add(roleLabel);
98100
}
99101

100-
if (withSpacer) {
101-
layout.add(new qx.ui.core.Spacer(15, 15));
102-
}
102+
layout.add(new qx.ui.core.Spacer(15, 15));
103103

104104
return layout;
105105
}

0 commit comments

Comments
 (0)