From cc3da031e2a8259bd7afe6d8b07b333468b26f05 Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Wed, 7 Apr 2021 12:28:50 +0530 Subject: [PATCH] enhancement: Profile settings accessibility improvements (#2054) * profile settings in to separate form * update locale texts * replce woot-submit-button with woot-button * disable button if value is empty * change condition * code climate fixes --- .../dashboard/i18n/locale/en/settings.json | 12 ++- .../dashboard/settings/profile/Index.vue | 74 ++++++++++++------- 2 files changed, 52 insertions(+), 34 deletions(-) diff --git a/app/javascript/dashboard/i18n/locale/en/settings.json b/app/javascript/dashboard/i18n/locale/en/settings.json index fd915fb0c..314bbbbda 100644 --- a/app/javascript/dashboard/i18n/locale/en/settings.json +++ b/app/javascript/dashboard/i18n/locale/en/settings.json @@ -3,6 +3,8 @@ "LINK": "Profile Settings", "TITLE": "Profile Settings", "BTN_TEXT": "Update Profile", + "UPDATE_SUCCESS": "Your profile has been updated successfully", + "PASSWORD_UPDATE_SUCCESS": "Your password has been changed successfully", "AFTER_EMAIL_CHANGED": "Your profile has been updated successfully, please login again as your login credentials are changed", "FORM": { "AVATAR": "Profile Image", @@ -16,7 +18,8 @@ }, "PASSWORD_SECTION": { "TITLE": "Password", - "NOTE": "Updating your password would reset your logins in multiple devices." + "NOTE": "Updating your password would reset your logins in multiple devices.", + "BTN_TEXT": "Change password" }, "ACCESS_TOKEN": { "TITLE": "Access Token", @@ -64,11 +67,7 @@ }, "AVAILABILITY": { "LABEL": "Availability", - "STATUSES_LIST": [ - "Online", - "Busy", - "Offline" - ] + "STATUSES_LIST": ["Online", "Busy", "Offline"] }, "EMAIL": { "LABEL": "Your email address", @@ -147,6 +146,5 @@ }, "SUBMIT": "Submit" } - } } diff --git a/app/javascript/dashboard/routes/dashboard/settings/profile/Index.vue b/app/javascript/dashboard/routes/dashboard/settings/profile/Index.vue index d84134749..90d6f7012 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/profile/Index.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/profile/Index.vue @@ -1,8 +1,8 @@ @@ -130,7 +138,8 @@ export default { email: '', password: '', passwordConfirmation: '', - isUpdating: false, + isProfileUpdating: false, + isPasswordChanging: false, }; }, validations: { @@ -181,13 +190,17 @@ export default { this.avatarUrl = this.currentUser.avatar_url; this.displayName = this.currentUser.display_name; }, - async updateUser() { + async updateUser(type) { this.$v.$touch(); if (this.$v.$invalid) { this.showAlert(this.$t('PROFILE_SETTINGS.FORM.ERROR')); return; } - this.isUpdating = true; + if (type === 'profile') { + this.isProfileUpdating = true; + } else if (type === 'password') { + this.isPasswordChanging = true; + } const hasEmailChanged = this.currentUser.email !== this.email; try { await this.$store.dispatch('updateProfile', { @@ -198,13 +211,20 @@ export default { displayName: this.displayName, password_confirmation: this.passwordConfirmation, }); - this.isUpdating = false; + this.isProfileUpdating = false; + this.isPasswordChanging = false; if (hasEmailChanged) { clearCookiesOnLogout(); this.showAlert(this.$t('PROFILE_SETTINGS.AFTER_EMAIL_CHANGED')); } + if (type === 'profile') { + this.showAlert(this.$t('PROFILE_SETTINGS.UPDATE_SUCCESS')); + } else if (type === 'password') { + this.showAlert(this.$t('PROFILE_SETTINGS.PASSWORD_UPDATE_SUCCESS')); + } } catch (error) { - this.isUpdating = false; + this.isProfileUpdating = false; + this.isPasswordChanging = false; } }, handleImageUpload({ file, url }) {