From e6167509aec88229d9918b4ffb716e439ef5ce5f Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Tue, 28 Jun 2022 17:16:27 +0300 Subject: [PATCH] RED-4418: show change language only on dev --- .../user-profile-screen.component.html | 4 ++- .../user-profile-screen.component.ts | 30 +++++++++---------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile-screen/user-profile-screen.component.html b/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile-screen/user-profile-screen.component.html index e984688de..5291221dd 100644 --- a/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile-screen/user-profile-screen.component.html +++ b/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile-screen/user-profile-screen.component.html @@ -15,7 +15,8 @@ -
+ +
@@ -23,6 +24,7 @@
+ diff --git a/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile-screen/user-profile-screen.component.ts b/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile-screen/user-profile-screen.component.ts index 6d904d8e0..e835758e3 100644 --- a/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile-screen/user-profile-screen.component.ts +++ b/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile-screen/user-profile-screen.component.ts @@ -10,6 +10,7 @@ import { UserService } from '@services/user.service'; import { ConfigService } from '@services/config.service'; import { LanguageService } from '../../../../../i18n/language.service'; import { firstValueFrom } from 'rxjs'; +import { UserPreferenceService } from '../../../../../services/user-preference.service'; @Component({ selector: 'redaction-user-profile-screen', @@ -18,30 +19,29 @@ import { firstValueFrom } from 'rxjs'; changeDetection: ChangeDetectionStrategy.OnPush, }) export class UserProfileScreenComponent extends BaseFormComponent implements OnInit { - changePasswordUrl: SafeResourceUrl; - translations = languagesTranslations; + readonly changePasswordUrl: SafeResourceUrl; + readonly translations = languagesTranslations; - private _profileModel: IProfile; + #profileModel: IProfile; constructor( - readonly permissionsService: PermissionsService, - private readonly _formBuilder: UntypedFormBuilder, + domSanitizer: DomSanitizer, + configService: ConfigService, private readonly _userService: UserService, - private readonly _configService: ConfigService, - private readonly _languageService: LanguageService, - private readonly _domSanitizer: DomSanitizer, + readonly permissionsService: PermissionsService, + readonly userPreferences: UserPreferenceService, private readonly _loadingService: LoadingService, + private readonly _formBuilder: UntypedFormBuilder, + private readonly _languageService: LanguageService, protected readonly _translateService: TranslateService, ) { super(); this._loadingService.start(); - this.changePasswordUrl = this._domSanitizer.bypassSecurityTrustResourceUrl( - `${this._configService.values.OAUTH_URL}/account/password`, - ); + this.changePasswordUrl = domSanitizer.bypassSecurityTrustResourceUrl(`${configService.values.OAUTH_URL}/account/password`); } get languageChanged(): boolean { - return this._profileModel['language'] !== this.form.get('language').value; + return this.#profileModel['language'] !== this.form.get('language').value; } get profileChanged(): boolean { @@ -49,7 +49,7 @@ export class UserProfileScreenComponent extends BaseFormComponent implements OnI keys.splice(keys.indexOf('language'), 1); for (const key of keys) { - if (this._profileModel[key] !== this.form.get(key).value) { + if (this.#profileModel[key] !== this.form.get(key).value) { return true; } } @@ -101,7 +101,7 @@ export class UserProfileScreenComponent extends BaseFormComponent implements OnI private _initializeForm(): void { try { this.form = this._getForm(); - this._profileModel = { + this.#profileModel = { email: this._userService.currentUser.email, firstName: this._userService.currentUser.firstName, lastName: this._userService.currentUser.lastName, @@ -111,7 +111,7 @@ export class UserProfileScreenComponent extends BaseFormComponent implements OnI // disable email if it's already set this.form.get('email').disable(); } - this.form.patchValue(this._profileModel, { emitEvent: false }); + this.form.patchValue(this.#profileModel, { emitEvent: false }); this.initialFormValue = this.form.getRawValue(); } catch (e) { } finally {