Skip to content

Commit 7602c9c

Browse files
committed
__createPersonalInfoSection
1 parent 9d945d5 commit 7602c9c

File tree

1 file changed

+115
-28
lines changed
  • services/static-webserver/client/source/class/osparc/desktop/account

1 file changed

+115
-28
lines changed

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

Lines changed: 115 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
3737
this._add(this.__create2FASection());
3838
}
3939
this._add(this.__createPasswordSection());
40+
this._add(this.__createPersonalInfoSection());
4041
this._add(this.__createDeleteAccount());
4142

4243
this.__userProfileData = {};
@@ -57,6 +58,16 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
5758
},
5859
},
5960

61+
statics: {
62+
createSectionBox: function(title) {
63+
const box = osparc.ui.window.TabbedView.createSectionBox(this.tr(title)).set({
64+
alignX: "left",
65+
maxWidth: 500
66+
});
67+
return box;
68+
},
69+
},
70+
6071
members: {
6172
__userProfileData: null,
6273
__userProfileModel: null,
@@ -137,13 +148,17 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
137148
this.__updatePrivacyBtn.setEnabled(false);
138149
},
139150

151+
__resetUserData: function() {
152+
this.__setDataToProfile(this.__userProfileData);
153+
},
154+
155+
__resetPrivacyData: function() {
156+
this.__setDataToPrivacy(this.__userPrivacyData);
157+
},
158+
140159
__createProfileUser: function() {
141160
// layout
142-
const box = osparc.ui.window.TabbedView.createSectionBox(this.tr("User"));
143-
box.set({
144-
alignX: "left",
145-
maxWidth: 500
146-
});
161+
const box = this.self().createSectionBox(this.tr("User"));
147162

148163
const username = new qx.ui.form.TextField().set({
149164
placeholder: this.tr("username")
@@ -307,11 +322,7 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
307322

308323
const privacyModel = this.__userPrivacyModel = qx.data.marshal.Json.createModel(defaultModel, true);
309324

310-
const box = osparc.ui.window.TabbedView.createSectionBox(this.tr("Privacy"));
311-
box.set({
312-
alignX: "left",
313-
maxWidth: 500
314-
});
325+
const box = this.self().createSectionBox(this.tr("Privacy"));
315326

316327
const label = osparc.ui.window.TabbedView.createHelpLabel(this.tr("Choose what other see."));
317328
box.add(label);
@@ -427,7 +438,7 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
427438
},
428439

429440
__create2FASection: function() {
430-
const box = osparc.ui.window.TabbedView.createSectionBox(this.tr("Two-Factor Authentication"));
441+
const box = this.self().createSectionBox(this.tr("Two-Factor Authentication"));
431442

432443
const label = osparc.ui.window.TabbedView.createHelpLabel(this.tr("Set your preferred method to use for two-factor authentication when signing in:"));
433444
box.add(label);
@@ -497,21 +508,9 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
497508
return box;
498509
},
499510

500-
__resetUserData: function() {
501-
this.__setDataToProfile(this.__userProfileData);
502-
},
503-
504-
__resetPrivacyData: function() {
505-
this.__setDataToPrivacy(this.__userPrivacyData);
506-
},
507-
508511
__createPasswordSection: function() {
509512
// layout
510-
const box = osparc.ui.window.TabbedView.createSectionBox(this.tr("Password"));
511-
box.set({
512-
alignX: "left",
513-
maxWidth: 500
514-
});
513+
const box = this.self().createSectionBox(this.tr("Password"));
515514

516515
const currentPassword = new osparc.ui.form.PasswordField().set({
517516
required: true,
@@ -577,12 +576,100 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
577576
return box;
578577
},
579578

580-
__createDeleteAccount: function() {
579+
__createPersonalInfoSection: function() {
581580
// layout
582-
const box = osparc.ui.window.TabbedView.createSectionBox(this.tr("Danger Zone")).set({
583-
alignX: "left",
584-
maxWidth: 500
581+
const box = this.self().createSectionBox(this.tr("Personal Information"));
582+
583+
const username = new qx.ui.form.TextField().set({
584+
placeholder: this.tr("username")
585+
});
586+
587+
const firstName = new qx.ui.form.TextField().set({
588+
placeholder: this.tr("First Name")
589+
});
590+
const lastName = new qx.ui.form.TextField().set({
591+
placeholder: this.tr("Last Name")
592+
});
593+
594+
const email = new qx.ui.form.TextField().set({
595+
placeholder: this.tr("Email"),
596+
readOnly: true
597+
});
598+
599+
const phoneNumber = new qx.ui.form.TextField().set({
600+
placeholder: this.tr("Phone Number"),
601+
readOnly: true
602+
});
603+
604+
const profileForm = this.__userProfileForm = new qx.ui.form.Form();
605+
profileForm.add(username, "Username", null, "username");
606+
profileForm.add(firstName, "First Name", null, "firstName");
607+
profileForm.add(lastName, "Last Name", null, "lastName");
608+
profileForm.add(email, "Email", null, "email");
609+
if (osparc.store.StaticInfo.is2FARequired()) {
610+
profileForm.add(phoneNumber, "Phone Number", null, "phoneNumber");
611+
}
612+
this.__userProfileRenderer = new osparc.ui.form.renderer.SingleWithWidget(profileForm);
613+
box.add(this.__userProfileRenderer);
614+
615+
const expirationLayout = new qx.ui.container.Composite(new qx.ui.layout.HBox(5)).set({
616+
paddingLeft: 16,
617+
visibility: "excluded"
618+
});
619+
const expirationDateLabel = new qx.ui.basic.Label(this.tr("Expiration date:")).set({
620+
textColor: "danger-red"
621+
});
622+
expirationLayout.add(expirationDateLabel);
623+
const expirationDate = new qx.ui.basic.Label();
624+
expirationLayout.add(expirationDate);
625+
const infoLabel = this.tr("Please contact us via email:<br>");
626+
const infoExtension = new osparc.ui.hint.InfoHint(infoLabel);
627+
const supportEmail = osparc.store.VendorInfo.getSupportEmail();
628+
infoExtension.setHintText(infoLabel + supportEmail);
629+
expirationLayout.add(infoExtension);
630+
box.add(expirationLayout);
631+
632+
// binding to a model
633+
const raw = {
634+
"username": "",
635+
"firstName": "",
636+
"lastName": "",
637+
"email": "",
638+
"phone": "",
639+
"expirationDate": null,
640+
};
641+
642+
const model = this.__userProfileModel = qx.data.marshal.Json.createModel(raw);
643+
const controller = new qx.data.controller.Object(model);
644+
645+
controller.addTarget(username, "value", "username", true);
646+
controller.addTarget(email, "value", "email", true);
647+
controller.addTarget(firstName, "value", "firstName", true, null, {
648+
converter: function(data) {
649+
return data.replace(/^\w/, c => c.toUpperCase());
650+
}
585651
});
652+
controller.addTarget(lastName, "value", "lastName", true);
653+
controller.addTarget(phoneNumber, "value", "phone", true);
654+
controller.addTarget(expirationDate, "value", "expirationDate", false, {
655+
converter: expirationDay => {
656+
if (expirationDay) {
657+
expirationLayout.show();
658+
return osparc.utils.Utils.formatDate(new Date(expirationDay));
659+
}
660+
return "";
661+
}
662+
});
663+
664+
return box;
665+
},
666+
667+
__createDeleteAccount: function() {
668+
// layout
669+
const box = this.self().createSectionBox(this.tr("Delete Account"));
670+
671+
const label = osparc.ui.window.TabbedView.createHelpLabel(this.tr("Request the deletion of your account."));
672+
box.add(label);
586673

587674
const deleteBtn = new qx.ui.form.Button(this.tr("Delete Account")).set({
588675
appearance: "danger-button",

0 commit comments

Comments
 (0)