diff --git a/dmp-frontend/src/app/ui/user-profile/user-profile-editor.model.ts b/dmp-frontend/src/app/ui/user-profile/user-profile-editor.model.ts index f5fcd46b7..d5fe69071 100644 --- a/dmp-frontend/src/app/ui/user-profile/user-profile-editor.model.ts +++ b/dmp-frontend/src/app/ui/user-profile/user-profile-editor.model.ts @@ -29,7 +29,7 @@ export class UserProfileEditorModel { const formGroup = new UntypedFormBuilder().group({ id: new UntypedFormControl(this.id), name: new UntypedFormControl(this.name), - language: new UntypedFormControl(this.language ? availableLanguages.filter(x => x.value === this.language.value).pop() : '', [Validators.required]), + language: new UntypedFormControl(this.language ? availableLanguages.filter(x => x === this.language).pop() : '', [Validators.required]), timezone: new UntypedFormControl(this.timezone, [Validators.required]), culture: new UntypedFormControl(this.culture, [Validators.required]), organization: new UntypedFormControl(this.organization), diff --git a/dmp-frontend/src/app/ui/user-profile/user-profile.component.html b/dmp-frontend/src/app/ui/user-profile/user-profile.component.html index c8bb717cb..644698ab0 100644 --- a/dmp-frontend/src/app/ui/user-profile/user-profile.component.html +++ b/dmp-frontend/src/app/ui/user-profile/user-profile.component.html @@ -16,7 +16,7 @@
-
{{'USER-PROFILE.SETTINGS.NAME' | translate}} *
+
{{'USER-PROFILE.SETTINGS.NAME' | translate}} *
@@ -73,7 +73,7 @@
-
{{'USER-PROFILE.SETTINGS.ORGANIZATION' | translate}}
+
{{'USER-PROFILE.SETTINGS.ORGANIZATION' | translate}}
@@ -88,7 +88,7 @@
-
{{'USER-PROFILE.SETTINGS.ROLE' | translate}}
+
{{'USER-PROFILE.SETTINGS.ROLE' | translate}}
@@ -118,7 +118,7 @@
-
{{'USER-PROFILE.SETTINGS.TIMEZONE' | translate}} *
+
{{'USER-PROFILE.SETTINGS.TIMEZONE' | translate}} *
@@ -139,7 +139,7 @@
-
{{'USER-PROFILE.SETTINGS.CULTURE' | translate}} *
+
{{'USER-PROFILE.SETTINGS.CULTURE' | translate}} *
@@ -160,14 +160,16 @@
-
{{'USER-PROFILE.SETTINGS.LANGUAGE' | translate}} *
+
{{'USER-PROFILE.SETTINGS.LANGUAGE' | translate}} *
+ - + + - {{ language.label | translate }} + {{ "GENERAL.LANGUAGES."+ language | translate }} {{'GENERAL.VALIDATION.REQUIRED' | translate}} @@ -185,4 +187,4 @@
-
\ No newline at end of file +
diff --git a/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts b/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts index 5091cfe19..9d58964c7 100644 --- a/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts +++ b/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts @@ -26,6 +26,8 @@ import { Observable, of } from 'rxjs'; import { map, takeUntil } from 'rxjs/operators'; import { AddAccountDialogComponent } from './add-account/add-account-dialog.component'; import { UserProfileEditorModel } from './user-profile-editor.model'; +import { nameof } from 'ts-simple-nameof'; +import { Guid } from '@common/types/guid'; @Component({ selector: 'app-user-profile', @@ -83,12 +85,24 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes .pipe(takeUntil(this._destroyed)) .subscribe((params: Params) => { this.currentUserId = this.authService.userId()?.toString(); - const userId = !params['id'] ? 'me' : params['id']; - this.user = this.userService.getSingle(userId).pipe(map(result => { + this.user = this.userService.getSingle( + Guid.parse(this.currentUserId), + [ + nameof(x => x.id), + nameof(x => x.name), + nameof(x => x.additionalInfo.language), + nameof(x => x.additionalInfo.timezone), + nameof(x => x.additionalInfo.culture), + nameof(x => x.additionalInfo.organization), + nameof(x => x.additionalInfo.roleOrganization), + ] + ) + .pipe(map(result => { //result['additionalinfo'] = JSON.parse(result['additionalinfo']); this.userProfileEditorModel = new UserProfileEditorModel().fromModel(result); this.formGroup = this.userProfileEditorModel.buildForm(this.languageService.getAvailableLanguagesCodes()); + // this.formGroup = new FormBuilder().group({ // language: new FormControl(result['language'] ? availableLanguages.filter(x => x.value === result['language']['value']).pop() : '', [Validators.required]), // timezone: new FormControl(result['timezone'], [Validators.required]), @@ -149,7 +163,13 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes } displayFn(culture?: CultureInfo): string | undefined { - return culture ? culture.displayName + '-' + culture.nativeName : undefined; + + if (culture == null + || culture.displayName == null + || culture.nativeName == null) + return undefined; + + return culture.displayName + '-' + culture.nativeName; } save() {