removed useless stuff and renamed form
This commit is contained in:
parent
7098aa38a6
commit
875b80ab45
@ -21,7 +21,6 @@ export class LanguageService {
|
||||
chooseAndSetInitialLanguage() {
|
||||
let defaultLang: string;
|
||||
const userPreferenceLang = this._userPreferenceService.getLanguage();
|
||||
// const browserLang = this._translateService.getBrowserLang();
|
||||
const browserLang = 'en'; // Force language to english until translations are ready
|
||||
if (this.languageAvailable(userPreferenceLang)) {
|
||||
defaultLang = userPreferenceLang;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<form (submit)="save()" [formGroup]="formGroup">
|
||||
<form (submit)="save()" [formGroup]="form">
|
||||
<div class="dialog-content">
|
||||
<div class="dialog-content-left">
|
||||
<div class="iqser-input-group required">
|
||||
@ -30,7 +30,7 @@
|
||||
</div>
|
||||
|
||||
<div class="dialog-actions">
|
||||
<button [disabled]="formGroup.invalid || !(profileChanged || languageChanged)" color="primary" mat-flat-button type="submit">
|
||||
<button [disabled]="form.invalid || !(profileChanged || languageChanged)" color="primary" mat-flat-button type="submit">
|
||||
{{ 'user-profile-screen.actions.save' | translate }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@ -17,7 +17,7 @@ import { LanguageService } from '../../../../../i18n/language.service';
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class UserProfileScreenComponent implements OnInit {
|
||||
readonly formGroup: FormGroup = this._getForm();
|
||||
readonly form: FormGroup = this._getForm();
|
||||
changePasswordUrl: SafeResourceUrl;
|
||||
translations = languagesTranslations;
|
||||
|
||||
@ -50,16 +50,15 @@ export class UserProfileScreenComponent implements OnInit {
|
||||
}
|
||||
|
||||
get languageChanged(): boolean {
|
||||
console.log('plm');
|
||||
return this._profileModel['language'] !== this.formGroup.get('language').value;
|
||||
return this._profileModel['language'] !== this.form.get('language').value;
|
||||
}
|
||||
|
||||
get profileChanged(): boolean {
|
||||
const keys = Object.keys(this.formGroup.getRawValue());
|
||||
const keys = Object.keys(this.form.getRawValue());
|
||||
keys.splice(keys.indexOf('language'), 1);
|
||||
|
||||
for (const key of keys) {
|
||||
if (this._profileModel[key] !== this.formGroup.get(key).value) {
|
||||
if (this._profileModel[key] !== this.form.get(key).value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -79,11 +78,11 @@ export class UserProfileScreenComponent implements OnInit {
|
||||
this._loadingService.start();
|
||||
|
||||
if (this.languageChanged) {
|
||||
await this._languageService.changeLanguage(this.formGroup.get('language').value);
|
||||
await this._languageService.changeLanguage(this.form.get('language').value);
|
||||
}
|
||||
|
||||
if (this.profileChanged) {
|
||||
const value = this.formGroup.value as IProfile;
|
||||
const value = this.form.value as IProfile;
|
||||
delete value.language;
|
||||
|
||||
await this._userService
|
||||
@ -109,9 +108,9 @@ export class UserProfileScreenComponent implements OnInit {
|
||||
};
|
||||
if (this._userService.currentUser.email) {
|
||||
// disable email if it's already set
|
||||
this.formGroup.get('email').disable();
|
||||
this.form.get('email').disable();
|
||||
}
|
||||
this.formGroup.patchValue(this._profileModel, { emitEvent: false });
|
||||
this.form.patchValue(this._profileModel, { emitEvent: false });
|
||||
} catch (e) {
|
||||
} finally {
|
||||
this._loadingService.stop();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user