69432: Functional profile security form + notifications + metadata form refactoring

This commit is contained in:
Kristof De Langhe
2020-03-11 14:32:38 +01:00
parent 1f1846c487
commit 892a985156
8 changed files with 116 additions and 31 deletions

View File

@@ -5,6 +5,9 @@ import { select, Store } from '@ngrx/store';
import { getAuthenticatedUser } from '../core/auth/selectors';
import { AppState } from '../app.reducer';
import { ProfilePageMetadataFormComponent } from './profile-page-metadata-form/profile-page-metadata-form.component';
import { ProfilePageSecurityFormComponent } from './profile-page-security-form/profile-page-security-form.component';
import { NotificationsService } from '../shared/notifications/notifications.service';
import { TranslateService } from '@ngx-translate/core';
@Component({
selector: 'ds-profile-page',
@@ -17,12 +20,18 @@ export class ProfilePageComponent implements OnInit {
@ViewChild(ProfilePageMetadataFormComponent, { static: false }) metadataForm: ProfilePageMetadataFormComponent;
@ViewChild(ProfilePageSecurityFormComponent, { static: false }) securityForm: ProfilePageSecurityFormComponent;
/**
* The authenticated user
*/
user$: Observable<EPerson>;
constructor(private store: Store<AppState>) {
NOTIFICATIONS_PREFIX = 'profile.notifications.';
constructor(private store: Store<AppState>,
private notificationsService: NotificationsService,
private translate: TranslateService) {
}
ngOnInit(): void {
@@ -30,6 +39,13 @@ export class ProfilePageComponent implements OnInit {
}
updateProfile() {
this.metadataForm.updateProfile();
const metadataChanged = this.metadataForm.updateProfile();
const securityChanged = this.securityForm.updateSecurity();
if (!metadataChanged && !securityChanged) {
this.notificationsService.warning(
this.translate.instant(this.NOTIFICATIONS_PREFIX + 'warning.no-changes.title'),
this.translate.instant(this.NOTIFICATIONS_PREFIX + 'warning.no-changes.content')
);
}
}
}