mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-09 11:03:05 +00:00
69432: Profile page - missing JSDocs
This commit is contained in:
@@ -23,12 +23,24 @@ import { NotificationsService } from '../../shared/notifications/notifications.s
|
|||||||
selector: 'ds-profile-page-metadata-form',
|
selector: 'ds-profile-page-metadata-form',
|
||||||
templateUrl: './profile-page-metadata-form.component.html'
|
templateUrl: './profile-page-metadata-form.component.html'
|
||||||
})
|
})
|
||||||
|
/**
|
||||||
|
* Component for a user to edit their metadata
|
||||||
|
* Displays a form containing:
|
||||||
|
* - readonly email field,
|
||||||
|
* - required first name text field
|
||||||
|
* - required last name text field
|
||||||
|
* - phone text field
|
||||||
|
* - language dropdown
|
||||||
|
*/
|
||||||
export class ProfilePageMetadataFormComponent implements OnInit {
|
export class ProfilePageMetadataFormComponent implements OnInit {
|
||||||
/**
|
/**
|
||||||
* The user to display the form for
|
* The user to display the form for
|
||||||
*/
|
*/
|
||||||
@Input() user: EPerson;
|
@Input() user: EPerson;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The form's input models
|
||||||
|
*/
|
||||||
formModel: DynamicFormControlModel[] = [
|
formModel: DynamicFormControlModel[] = [
|
||||||
new DynamicInputModel({
|
new DynamicInputModel({
|
||||||
id: 'email',
|
id: 'email',
|
||||||
@@ -72,14 +84,24 @@ export class ProfilePageMetadataFormComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
formGroup: FormGroup;
|
formGroup: FormGroup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prefix for the form's label messages of this component
|
||||||
|
*/
|
||||||
LABEL_PREFIX = 'profile.metadata.form.label.';
|
LABEL_PREFIX = 'profile.metadata.form.label.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prefix for the form's error messages of this component
|
||||||
|
*/
|
||||||
ERROR_PREFIX = 'profile.metadata.form.error.';
|
ERROR_PREFIX = 'profile.metadata.form.error.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prefix for the notification messages of this component
|
||||||
|
*/
|
||||||
NOTIFICATION_PREFIX = 'profile.metadata.form.notifications.';
|
NOTIFICATION_PREFIX = 'profile.metadata.form.notifications.';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All of the configured active languages
|
* All of the configured active languages
|
||||||
|
* Used to populate the language dropdown
|
||||||
*/
|
*/
|
||||||
activeLangs: LangConfig[];
|
activeLangs: LangConfig[];
|
||||||
|
|
||||||
@@ -101,6 +123,10 @@ export class ProfilePageMetadataFormComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loop over all the form's input models and set their values depending on the user's metadata
|
||||||
|
* Create the FormGroup
|
||||||
|
*/
|
||||||
setFormValues() {
|
setFormValues() {
|
||||||
this.formModel.forEach(
|
this.formModel.forEach(
|
||||||
(fieldModel: DynamicInputModel | DynamicSelectModel<string>) => {
|
(fieldModel: DynamicInputModel | DynamicSelectModel<string>) => {
|
||||||
@@ -118,6 +144,9 @@ export class ProfilePageMetadataFormComponent implements OnInit {
|
|||||||
this.formGroup = this.formBuilderService.createFormGroup(this.formModel);
|
this.formGroup = this.formBuilderService.createFormGroup(this.formModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the translations of the field labels and error messages
|
||||||
|
*/
|
||||||
updateFieldTranslations() {
|
updateFieldTranslations() {
|
||||||
this.formModel.forEach(
|
this.formModel.forEach(
|
||||||
(fieldModel: DynamicInputModel) => {
|
(fieldModel: DynamicInputModel) => {
|
||||||
@@ -132,6 +161,15 @@ export class ProfilePageMetadataFormComponent implements OnInit {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the user's metadata
|
||||||
|
*
|
||||||
|
* Sends a patch request for updating the user's metadata when at least one value changed or got added/removed and the
|
||||||
|
* form is valid.
|
||||||
|
* Nothing happens when the form is invalid or no metadata changed.
|
||||||
|
*
|
||||||
|
* Returns false when nothing happened.
|
||||||
|
*/
|
||||||
updateProfile(): boolean {
|
updateProfile(): boolean {
|
||||||
if (!this.formGroup.valid) {
|
if (!this.formGroup.valid) {
|
||||||
return false;
|
return false;
|
||||||
|
@@ -16,12 +16,19 @@ import { NotificationsService } from '../../shared/notifications/notifications.s
|
|||||||
selector: 'ds-profile-page-security-form',
|
selector: 'ds-profile-page-security-form',
|
||||||
templateUrl: './profile-page-security-form.component.html'
|
templateUrl: './profile-page-security-form.component.html'
|
||||||
})
|
})
|
||||||
|
/**
|
||||||
|
* Component for a user to edit their security information
|
||||||
|
* Displays a form containing a password field and a confirmation of the password
|
||||||
|
*/
|
||||||
export class ProfilePageSecurityFormComponent implements OnInit {
|
export class ProfilePageSecurityFormComponent implements OnInit {
|
||||||
/**
|
/**
|
||||||
* The user to display the form for
|
* The user to display the form for
|
||||||
*/
|
*/
|
||||||
@Input() user: EPerson;
|
@Input() user: EPerson;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The form's input models
|
||||||
|
*/
|
||||||
formModel: DynamicFormControlModel[] = [
|
formModel: DynamicFormControlModel[] = [
|
||||||
new DynamicInputModel({
|
new DynamicInputModel({
|
||||||
id: 'password',
|
id: 'password',
|
||||||
@@ -40,8 +47,14 @@ export class ProfilePageSecurityFormComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
formGroup: FormGroup;
|
formGroup: FormGroup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prefix for the notification messages of this component
|
||||||
|
*/
|
||||||
NOTIFICATIONS_PREFIX = 'profile.security.form.notifications.';
|
NOTIFICATIONS_PREFIX = 'profile.security.form.notifications.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prefix for the form's label messages of this component
|
||||||
|
*/
|
||||||
LABEL_PREFIX = 'profile.security.form.label.';
|
LABEL_PREFIX = 'profile.security.form.label.';
|
||||||
|
|
||||||
constructor(protected formService: DynamicFormService,
|
constructor(protected formService: DynamicFormService,
|
||||||
@@ -59,6 +72,9 @@ export class ProfilePageSecurityFormComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the translations of the field labels
|
||||||
|
*/
|
||||||
updateFieldTranslations() {
|
updateFieldTranslations() {
|
||||||
this.formModel.forEach(
|
this.formModel.forEach(
|
||||||
(fieldModel: DynamicInputModel) => {
|
(fieldModel: DynamicInputModel) => {
|
||||||
@@ -67,6 +83,10 @@ export class ProfilePageSecurityFormComponent implements OnInit {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if both password fields are filled in and equal
|
||||||
|
* @param group The FormGroup to validate
|
||||||
|
*/
|
||||||
checkPasswords(group: FormGroup) {
|
checkPasswords(group: FormGroup) {
|
||||||
const pass = group.get('password').value;
|
const pass = group.get('password').value;
|
||||||
const repeatPass = group.get('passwordrepeat').value;
|
const repeatPass = group.get('passwordrepeat').value;
|
||||||
@@ -74,6 +94,16 @@ export class ProfilePageSecurityFormComponent implements OnInit {
|
|||||||
return isEmpty(repeatPass) || pass === repeatPass ? null : { notSame: true };
|
return isEmpty(repeatPass) || pass === repeatPass ? null : { notSame: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the user's security details
|
||||||
|
*
|
||||||
|
* Sends a patch request for changing the user's password when a new password is present and the password confirmation
|
||||||
|
* matches the new password.
|
||||||
|
* Nothing happens when no passwords are filled in.
|
||||||
|
* An error notification is displayed when the password confirmation does not match the new password.
|
||||||
|
*
|
||||||
|
* Returns false when nothing happened
|
||||||
|
*/
|
||||||
updateSecurity() {
|
updateSecurity() {
|
||||||
const pass = this.formGroup.get('password').value;
|
const pass = this.formGroup.get('password').value;
|
||||||
const passEntered = isNotEmpty(pass);
|
const passEntered = isNotEmpty(pass);
|
||||||
|
@@ -25,9 +25,14 @@ import { followLink } from '../shared/utils/follow-link-config.model';
|
|||||||
* Component for a user to edit their profile information
|
* Component for a user to edit their profile information
|
||||||
*/
|
*/
|
||||||
export class ProfilePageComponent implements OnInit {
|
export class ProfilePageComponent implements OnInit {
|
||||||
|
/**
|
||||||
|
* A reference to the metadata form component
|
||||||
|
*/
|
||||||
@ViewChild(ProfilePageMetadataFormComponent, { static: false }) metadataForm: ProfilePageMetadataFormComponent;
|
@ViewChild(ProfilePageMetadataFormComponent, { static: false }) metadataForm: ProfilePageMetadataFormComponent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A reference to the security form component
|
||||||
|
*/
|
||||||
@ViewChild(ProfilePageSecurityFormComponent, { static: false }) securityForm: ProfilePageSecurityFormComponent;
|
@ViewChild(ProfilePageSecurityFormComponent, { static: false }) securityForm: ProfilePageSecurityFormComponent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,6 +45,9 @@ export class ProfilePageComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
groupsRD$: Observable<RemoteData<PaginatedList<Group>>>;
|
groupsRD$: Observable<RemoteData<PaginatedList<Group>>>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prefix for the notification messages of this component
|
||||||
|
*/
|
||||||
NOTIFICATIONS_PREFIX = 'profile.notifications.';
|
NOTIFICATIONS_PREFIX = 'profile.notifications.';
|
||||||
|
|
||||||
constructor(private store: Store<AppState>,
|
constructor(private store: Store<AppState>,
|
||||||
@@ -59,6 +67,10 @@ export class ProfilePageComponent implements OnInit {
|
|||||||
this.groupsRD$ = this.user$.pipe(switchMap((user: EPerson) => user.groups));
|
this.groupsRD$ = this.user$.pipe(switchMap((user: EPerson) => user.groups));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fire an update on both the metadata and security forms
|
||||||
|
* Show a warning notification when no changes were made in both forms
|
||||||
|
*/
|
||||||
updateProfile() {
|
updateProfile() {
|
||||||
const metadataChanged = this.metadataForm.updateProfile();
|
const metadataChanged = this.metadataForm.updateProfile();
|
||||||
const securityChanged = this.securityForm.updateSecurity();
|
const securityChanged = this.securityForm.updateSecurity();
|
||||||
|
Reference in New Issue
Block a user