Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,17 @@ export class UserEditDialogComponent implements OnInit {
});
}

private isValidEmail(email: string): boolean {
if (!email || email.trim() === '') return true; // email is optional
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email.trim());
}

saveChanges(): void {
if (this.changePassword && this.newPassword !== '' ) {
if (this.user.user.email && !this.isValidEmail(this.user.user.email)) {
this.isError = true;
this.message = 'Email format is incorrect';
return;
} else if (this.changePassword && this.newPassword !== '' ) {
this.isError = true;
this.message = 'Cancel or submit new password to save other changes';
} else if(!this.selectedRole || this.selectedRole===null || this.selectedRole.length ===0){
Expand Down Expand Up @@ -225,13 +234,18 @@ export class UserEditDialogComponent implements OnInit {
this.message = 'Unable to edit user';
if (error.error) {
this.isError = true;
this.message = error;
this.message = error.error.message || error.message || 'Unable to edit user';
}
});
}

addUser(): void {
this.isError = false;
if (this.user.user.email && !this.isValidEmail(this.user.user.email)) {
this.isError = true;
this.message = 'Email format is incorrect';
return;
}
if (this.newPassword === this.newPasswordConfirm) {
if(!this.selectedRole || this.selectedRole===null || this.selectedRole.length ===0){
this.message = "Please select a role for this user";
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/registrars/registrars.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ <h3 class="register-header" style = "margin-bottom: 18px;">
</div>
<span *ngFor = "let link of customLinks2; last as isLast; let ind = index">
<a mat-list-item [routerLink] = "['/browse-substance']"
[queryParams]="{facets: link.queryParams}" (click) = "routeToCustom(link)">
[queryParams]="{facets: link.queryParams}">
<div class = "entry2">
<div class = "label2">
{{link.display}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ <h3>Browse Clinical Trials</h3>
<td mat-cell *matCellDef="let element">
<a
class="clinical-trials-browse-edit1"
title="Edit in this tab"
[title]="canEdit ? 'Edit in this tab' : 'View in this tab'"
[routerLink]="['/edit-clinical-trial', element.trialNumber]"
[queryParams]="{}"
>Edit</a
>{{ canEdit ? 'Edit' : 'View' }}</a
>&nbsp;<a
class="clinical-trials-browse-edit2"
target="_blank"
title="Edit in new tab"
[title]="canEdit ? 'Edit in new tab' : 'View in new tab'"
[href]="'edit-clinical-trial/' + element.trialNumber"
>+</a
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ export class ClinicalTrialsBrowseComponent implements OnInit, AfterViewInit, OnD
this.overlayContainer = this.overlayContainerService.getContainerElement();
this.canEdit = await this.authService.hasSpecificPrivilege('Edit');
this.canDelete = await this.authService.hasSpecificPrivilege('Delete Lower Level Items');
const columns = ['trialNumber', 'title', 'lastUpdated'];
if (this.canEdit) { columns.unshift('edit'); }
const columns = ['edit', 'trialNumber', 'title', 'lastUpdated'];
if (this.canDelete) { columns.push('delete'); }
this.displayedColumns = columns;
this.searchTypes = [
Expand Down
Loading