Skip to content

Commit f5107dc

Browse files
committed
profileFields
1 parent f0f4e0f commit f5107dc

File tree

1 file changed

+21
-2
lines changed
  • services/static-webserver/client/source/class/osparc/desktop/account

1 file changed

+21
-2
lines changed

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
4949
__userProfileData: null,
5050
__userProfileModel: null,
5151
__userProfileRenderer: null,
52+
__updateProfileBtn: null,
5253
__userPrivacyData: null,
5354
__userPrivacyModel: null,
55+
__updatePrivacyBtn: null,
5456
__userProfileForm: null,
5557

5658
__fetchProfile: function() {
@@ -73,6 +75,7 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
7375
"expirationDate": data["expirationDate"] || null,
7476
});
7577
}
78+
this.__updateProfileBtn.setEnabled(false);
7679
},
7780

7881
__setDataToPrivacy: function(privacyData) {
@@ -184,7 +187,7 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
184187
namesValidator.add(firstName, qx.util.Validate.regExp(/[^\.\d]+/), this.tr("Avoid dots or numbers in text"));
185188
namesValidator.add(lastName, qx.util.Validate.regExp(/^$|[^\.\d]+/), this.tr("Avoid dots or numbers in text")); // allow also empty last name
186189

187-
const updateProfileBtn = new qx.ui.form.Button().set({
190+
const updateProfileBtn = this.__updateProfileBtn = new qx.ui.form.Button().set({
188191
label: this.tr("Update Profile"),
189192
appearance: "form-button",
190193
alignX: "right",
@@ -200,7 +203,7 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
200203
}
201204

202205
const patchData = {};
203-
if (this.__userProfileData["username"] !== model.getUsername()) {
206+
if (this.__userProfileData["userName"] !== model.getUsername()) {
204207
patchData["userName"] = model.getUsername();
205208
}
206209
if (this.__userProfileData["first_name"] !== model.getFirstName()) {
@@ -230,6 +233,21 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
230233
}
231234
});
232235

236+
const profileFields = [
237+
username,
238+
firstName,
239+
lastName,
240+
]
241+
const valueChanged = () => {
242+
const anyChanged =
243+
username.getValue() !== this.__userProfileData["userName"] ||
244+
firstName.getValue() !== this.__userProfileData["first_name"] ||
245+
lastName.getValue() !== this.__userProfileData["last_name"];
246+
updateProfileBtn.setEnabled(anyChanged);
247+
};
248+
valueChanged();
249+
profileFields.forEach(privacyField => privacyField.addListener("changeValue", () => valueChanged()));
250+
233251
return box;
234252
},
235253

@@ -337,6 +355,7 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
337355
});
338356
optOutMessage.getChildControl("icon").setTextColor("warning-yellow")
339357
box.add(optOutMessage);
358+
340359
const privacyFields = [
341360
hideUsername,
342361
hideFullname,

0 commit comments

Comments
 (0)