diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant-base/add-participant-base.component.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant-base/add-participant-base.component.ts index 4bbdb32a5..7fabd4d33 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant-base/add-participant-base.component.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant-base/add-participant-base.component.ts @@ -171,11 +171,7 @@ export abstract class AddParticipantBaseDirective extends BookingBaseComponent i if (this.form.valid && this.validEmail()) { this.disableCaseAndHearingRoles(); - if (this.editMode) { - this.displayNext(); - } else { - this.displayAdd(); - } + this.displayAdd(); } } diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.html b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.html index b79e09113..13f687264 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.html +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.html @@ -213,7 +213,7 @@

Client details

-
+
Add icon with sign plus Client details
-
+
Clear fields icon Clear details diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.spec.ts index 0700bf285..fc9298520 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.spec.ts @@ -970,14 +970,14 @@ describe('AddParticipantComponent', () => { it('should return errorAlternativeEmail & errorJohAccountNotFound as false if called with notFoundEmailEvent as false', () => { component.errorAlternativeEmail = true; component.errorJohAccountNotFound = true; - component.subcribeForSeachEmailEvents(); + component.subscribeForSearchEmailEvents(); component.searchEmail.notFoundEmailEvent.next(false); expect(component.errorAlternativeEmail).toBeFalsy(); expect(component.errorJohAccountNotFound).toBeFalsy(); }); it('should have called Not Found Participant if Not Found Email Event has been called', () => { spyOn(component, 'notFoundParticipant'); - component.subcribeForSeachEmailEvents(); + component.subscribeForSearchEmailEvents(); component.searchEmail.notFoundEmailEvent.next(true); expect(component.notFoundParticipant).toHaveBeenCalledTimes(1); }); @@ -1158,10 +1158,10 @@ describe('AddParticipantComponent edit mode', () => { expect(videoHearingsServiceSpy.getParticipantRoles).toHaveBeenCalled(); expect(component.showDetails).toBeTruthy(); expect(component.selectedParticipantEmail).toBe('test3@hmcts.net'); - expect(component.displayNextButton).toBeTruthy(); - expect(component.displayClearButton).toBeFalsy(); + expect(component.displayNextButton).toBeFalsy(); + expect(component.displayClearButton).toBeTruthy(); expect(component.displayAddButton).toBeFalsy(); - expect(component.displayUpdateButton).toBeFalsy(); + expect(component.displayUpdateButton).toBeTruthy(); }); tick(100); fixture.detectChanges(); @@ -1514,17 +1514,6 @@ describe('AddParticipantComponent edit mode no participants added', () => { expect(component.showDetails).toBeTruthy(); })); - it('should show update participant and clear details links when tries to edit a participant in hearing', fakeAsync(() => { - const debugElement = fixture.debugElement; - component.selectedParticipantEmail = 'test2@hmcts.net'; - fixture.detectChanges(); - const clearFormBtn = debugElement.query(By.css('#clearFormBtn')); - const updateFormBtn = debugElement.query(By.css('#updateParticipantBtn')); - tick(600); - expect(updateFormBtn).toBeTruthy(); - expect(clearFormBtn).toBeTruthy(); - })); - it('should show confirmation to remove participant', fakeAsync(() => { component.ngAfterContentInit(); component.ngAfterViewInit(); diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.ts index 538d50c49..c0e5a6c45 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.ts @@ -1,6 +1,6 @@ import { AfterContentInit, AfterViewInit, Component, OnDestroy, OnInit, ViewChild } from '@angular/core'; import { Router } from '@angular/router'; -import { Observable, Subject, Subscription, combineLatest } from 'rxjs'; +import { combineLatest, Observable, Subject, Subscription } from 'rxjs'; import { PageUrls } from 'src/app/shared/page-url.constants'; import { Constants } from '../../common/constants'; import { SanitizeInputText } from '../../common/formatters/sanitize-input-text'; @@ -148,12 +148,12 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme if (this.editMode) { if (this.searchEmail && this.participantDetails) { this.setParticipantEmail(); - this.subcribeForSeachEmailEvents(); + this.subscribeForSearchEmailEvents(); } } } - subcribeForSeachEmailEvents() { + subscribeForSearchEmailEvents() { this.searchEmail.notFoundEmailEvent$.subscribe(notFound => { if (notFound) { this.notFoundParticipant(); @@ -178,18 +178,17 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme const self = this; this.$subscriptions.push( - this.form.valueChanges.subscribe(result => { + this.form.valueChanges.subscribe(() => { setTimeout(() => { if ( - (self.showDetails && - self.role.value === self.constants.PleaseSelect && - self.party.value === self.constants.PleaseSelect && - self.title.value === self.constants.PleaseSelect && - self.firstName.value === '' && - self.lastName.value === '' && - self.phone.value === '' && - self.displayName.value === '') || - self.editMode + self.showDetails && + self.role.value === self.constants.PleaseSelect && + self.party.value === self.constants.PleaseSelect && + self.title.value === self.constants.PleaseSelect && + self.firstName.value === '' && + self.lastName.value === '' && + self.phone.value === '' && + self.displayName.value === '' ) { self.displayNext(); } else if ( @@ -289,17 +288,15 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme } validateJudiciaryEmailAndRole() { - if (this.searchEmail && this.searchEmail.email.length) { + if (this.searchEmail?.email?.length) { this.searchService.searchJudiciaryEntries(this.searchEmail.email).subscribe(judiciaryEntries => { this.errorJudiciaryAccount = false; - if (judiciaryEntries && judiciaryEntries.length) { + if (judiciaryEntries?.length) { if (!this.judiciaryRoles.includes(this.role.value)) { this.setErrorForJudiciaryAccount(); } - } else { - if (this.judiciaryRoles.includes(this.role.value)) { - this.setErrorForJudiciaryAccount(); - } + } else if (this.judiciaryRoles.includes(this.role.value)) { + this.setErrorForJudiciaryAccount(); } }); } @@ -342,7 +339,7 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme this.hearing.participants.push(newParticipant); this.hearing.participants = [...this.hearing.participants]; - this.hearing = Object.assign({}, this.hearing); + this.hearing = { ...this.hearing }; this.populateInterpretedForList(); this.videoHearingService.updateHearingRequest(this.hearing); @@ -367,8 +364,7 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme username: newParticipant.username }); this.showConfirmationPopup = true; - const message = `You have already added ${newParticipant.first_name} ${newParticipant.last_name} to this hearing`; - this.confirmationMessage = message; + this.confirmationMessage = `You have already added ${newParticipant.first_name} ${newParticipant.last_name} to this hearing`; } } else { this.isShowErrorSummary = true; @@ -400,7 +396,7 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme } }); this.hearing.participants = [...this.hearing.participants]; - this.hearing = Object.assign({}, this.hearing); + this.hearing = { ...this.hearing }; this.clearForm(); this.participantDetails = null; this.form.markAsPristine(); @@ -424,7 +420,7 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme confirmRemoveParticipant() { if (this.selectedParticipantEmail) { const participant = this.hearing.participants.find(x => x.email.toLowerCase() === this.selectedParticipantEmail.toLowerCase()); - const title = participant && participant.title ? `${participant.title}` : ''; + const title = participant?.title ? `${participant.title}` : ''; this.removerFullName = participant ? `${title} ${participant.first_name} ${participant.last_name}` : ''; const anyParticipants = this.hearing.participants.filter(x => !x.is_judge); this.bookingHasParticipants = anyParticipants && anyParticipants.length > 1; @@ -449,7 +445,7 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme } this.participantService.removeParticipant(this.hearing, this.selectedParticipantEmail); this.removeLinkedParticipant(this.selectedParticipantEmail); - this.hearing = Object.assign({}, this.hearing); + this.hearing = { ...this.hearing }; this.videoHearingService.updateHearingRequest(this.hearing); this.videoHearingService.setBookingHasChanged(true); } @@ -478,10 +474,9 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme } private getUserRoleName(newParticipant: ParticipantModel): string { - const userRole = this.caseAndHearingRoles + return this.caseAndHearingRoles .find(c => c.name === newParticipant.case_role_name) ?.hearingRoles.find(h => h.name === newParticipant.hearing_role_name)?.userRole; - return userRole; } private addUpdateLinkedParticipant(newParticipant: ParticipantModel): LinkedParticipantModel[] { @@ -745,7 +740,7 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme } this.participantService.removeParticipant(this.hearing, this.selectedParticipantEmail); this.removeLinkedParticipant(this.selectedParticipantEmail); - this.hearing = Object.assign({}, this.hearing); + this.hearing = { ...this.hearing }; this.videoHearingService.updateHearingRequest(this.hearing); this.videoHearingService.setBookingHasChanged(true); }