mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 23:13:04 +00:00
69432: Functional profile security form + notifications + metadata form refactoring
This commit is contained in:
@@ -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')
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user