RED-4418: show change language only on dev

This commit is contained in:
Dan Percic 2022-06-28 17:16:27 +03:00
parent 895990d7ae
commit e6167509ae
2 changed files with 18 additions and 16 deletions

View File

@ -15,7 +15,8 @@
<label translate="user-profile-screen.form.last-name"></label>
<input formControlName="lastName" name="lastName" type="text" />
</div>
<div class="iqser-input-group">
<div *ngIf="userPreferences.areDevFeaturesEnabled" class="iqser-input-group">
<label translate="top-bar.navigation-items.my-account.children.language.label"></label>
<mat-select formControlName="language">
<mat-option *ngFor="let language of languages" [value]="language">
@ -23,6 +24,7 @@
</mat-option>
</mat-select>
</div>
<div class="iqser-input-group">
<a [href]="changePasswordUrl" target="_blank"> {{ 'user-profile-screen.actions.change-password' | translate }}</a>
</div>

View File

@ -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 {