diff --git a/src/app/core/admin/user-management/user-edit-dialog/user-edit-dialog.component.ts b/src/app/core/admin/user-management/user-edit-dialog/user-edit-dialog.component.ts index 1ed593e71..723ae247f 100644 --- a/src/app/core/admin/user-management/user-edit-dialog/user-edit-dialog.component.ts +++ b/src/app/core/admin/user-management/user-edit-dialog/user-edit-dialog.component.ts @@ -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){ @@ -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"; diff --git a/src/app/core/registrars/registrars.component.html b/src/app/core/registrars/registrars.component.html index 326c208d2..5636cf8be 100644 --- a/src/app/core/registrars/registrars.component.html +++ b/src/app/core/registrars/registrars.component.html @@ -297,7 +297,7 @@

+ [queryParams]="{facets: link.queryParams}">
{{link.display}} diff --git a/src/app/fda/clinical-trials/clinical-trials-browse/clinical-trials-browse.component.html b/src/app/fda/clinical-trials/clinical-trials-browse/clinical-trials-browse.component.html index 049beaf4c..5d7f32afc 100644 --- a/src/app/fda/clinical-trials/clinical-trials-browse/clinical-trials-browse.component.html +++ b/src/app/fda/clinical-trials/clinical-trials-browse/clinical-trials-browse.component.html @@ -124,14 +124,14 @@

Browse Clinical Trials

Edit{{ canEdit ? 'Edit' : 'View' }} + diff --git a/src/app/fda/clinical-trials/clinical-trials-browse/clinical-trials-browse.component.ts b/src/app/fda/clinical-trials/clinical-trials-browse/clinical-trials-browse.component.ts index 19791f9ad..99402835f 100644 --- a/src/app/fda/clinical-trials/clinical-trials-browse/clinical-trials-browse.component.ts +++ b/src/app/fda/clinical-trials/clinical-trials-browse/clinical-trials-browse.component.ts @@ -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 = [