Skip to content

Commit

Permalink
Merge branch 'develop' into fix-PRIME-2563_able-to-change-care-settin…
Browse files Browse the repository at this point in the history
…g-to-device-provider
  • Loading branch information
bergomi02 authored Sep 17, 2024
2 parents ae5f136 + e0cfef5 commit 149abb6
Show file tree
Hide file tree
Showing 14 changed files with 231 additions and 122 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
defaults:
run:
working-directory: ./prime-angular-frontend

if: github.ref != 'develop' || (github.ref == 'develop' && github.event.pull_request.merged == true)

runs-on: ubuntu-latest
Expand Down Expand Up @@ -59,15 +59,15 @@ jobs:
- name: Collect Frontend Report
run: |
cc-test-reporter format-coverage -t lcov -o coverage/frontend.json coverage/lcov.info
- name: Create frontend coverage file artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: frontend
path: ./prime-angular-frontend/coverage/frontend.json
retention-days: 1


collect-backend-coverage:
defaults:
run:
Expand Down Expand Up @@ -101,7 +101,7 @@ jobs:
run: |
cd ../
dotnet tool install -g dotnet-reportgenerator-globaltool --version 5.3.6
- uses: amancevice/setup-code-climate@v0
with:
cc_test_reporter_id: ${{ secrets.CC_TEST_REPORTER_ID }}
Expand All @@ -122,12 +122,12 @@ jobs:
cd ../prime-dotnet-webapi
cc-test-reporter format-coverage -t lcov -o ../prime-dotnet-webapi-tests/coverage/backend.json ../prime-dotnet-webapi-tests/coverage/lcov.info -p /home/runner/work/moh-prime/moh-prime/prime-dotnet-webapi
- name: Create backend coverage file artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: backend
path: ./prime-dotnet-webapi-tests/coverage/backend.json
retention-days: 1


codeclimate-sum-coverage:
needs: [ collect-frontend-coverage, collect-backend-coverage ]
Expand All @@ -146,25 +146,25 @@ jobs:
cc_test_reporter_version: latest # optional

- name: Download frontend artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: frontend
# path: frontend/

- name: Download backend artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: backend
# path: backend/

- name: Sum files
run: |
run: |
cc-test-reporter sum-coverage -p 2 frontend.json backend.json
cc-test-reporter upload-coverage -i ./coverage/codeclimate.json
- name: Create summed report
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: summed
path: ./coverage/codeclimate.json
retention-days: 1
retention-days: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { DefaultValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import {
Directive,
ElementRef,
HostListener,
Renderer2,
forwardRef,
} from '@angular/core';

@Directive({
selector: 'input[appTrimSpace]',
providers: [
{
provide: NG_VALUE_ACCESSOR,
multi: true,
useExisting: forwardRef(() => TrimSpaceInputDirective),
},
],
})

export class TrimSpaceInputDirective extends DefaultValueAccessor {
@HostListener('input', ['$event']) input($event: InputEvent) {
const target = $event.target as HTMLInputElement;
const start = target.selectionStart;

target.value = target.value.trim();
target.setSelectionRange(start, start);
this.onChange(target.value);
}

constructor(renderer: Renderer2, elementRef: ElementRef) {
super(renderer, elementRef, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@
</ng-container>
</app-page-subheader>

<form [formGroup]="form">
<form [formGroup]="emailForm">
<div class="row">
<div class="col col-sm-8"
[formArrayName]="formArrayName">
<ng-container *ngFor="let email of formArray.controls; let i = index;"
[formGroupName]="i">
<app-email-form [form]="email"
[index]="i"
[validate]="true"
[validateFormat]="true"
[showRemoveButton]="i>0"
(remove)="removeEmail(settingCode, healthAuthorityCode, $event)">
</app-email-form>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
import { FormArray, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { FormArray, FormBuilder, FormGroup } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router';
import { AuthService } from '@auth/shared/services/auth.service';
Expand Down Expand Up @@ -35,6 +35,7 @@ import { exhaustMap } from 'rxjs/operators';
export class NextStepsComponent extends BaseEnrolmentProfilePage implements OnInit {
public title: string;
public enrolment: Enrolment;
public emailForm: FormGroup;
public hasReadAgreement: boolean;

public CareSettingEnum = CareSettingEnum;
Expand Down Expand Up @@ -104,39 +105,39 @@ export class NextStepsComponent extends BaseEnrolmentProfilePage implements OnIn
}

public get communityHealthEmails(): FormArray {
return this.form.get('communityHealthEmails') as FormArray;
return this.emailForm.get('communityHealthEmails') as FormArray;
}

public get pharmacistEmails(): FormArray {
return this.form.get('pharmacistEmails') as FormArray;
return this.emailForm.get('pharmacistEmails') as FormArray;
}

public get healthAuthorityFraserEmails(): FormArray {
return this.form.get('healthAuthorityFraserEmails') as FormArray;
return this.emailForm.get('healthAuthorityFraserEmails') as FormArray;
}

public get healthAuthorityNorthernEmails(): FormArray {
return this.form.get('healthAuthorityNorthernEmails') as FormArray;
return this.emailForm.get('healthAuthorityNorthernEmails') as FormArray;
}

public get healthAuthorityIslandEmails(): FormArray {
return this.form.get('healthAuthorityIslandEmails') as FormArray;
return this.emailForm.get('healthAuthorityIslandEmails') as FormArray;
}

public get healthAuthorityInteriorEmails(): FormArray {
return this.form.get('healthAuthorityInteriorEmails') as FormArray;
return this.emailForm.get('healthAuthorityInteriorEmails') as FormArray;
}

public get healthAuthorityPHSAEmails(): FormArray {
return this.form.get('healthAuthorityPHSAEmails') as FormArray;
return this.emailForm.get('healthAuthorityPHSAEmails') as FormArray;
}

public get healthAuthorityVancouverCoastalEmails(): FormArray {
return this.form.get('healthAuthorityVancouverCoastalEmails') as FormArray;
return this.emailForm.get('healthAuthorityVancouverCoastalEmails') as FormArray;
}

public get deviceProviderEmails(): FormArray {
return this.form.get('deviceProviderEmails') as FormArray;
return this.emailForm.get('deviceProviderEmails') as FormArray;
}

public getAgreementDescription() {
Expand Down Expand Up @@ -171,38 +172,52 @@ export class NextStepsComponent extends BaseEnrolmentProfilePage implements OnIn
}

public sendProvisionerAccessLink() {
const data: DialogOptions = {
title: 'Confirm Email',
message: `Are you sure you want to send your Approval Notification?`,
actionText: 'Send',
};
this.busy = this.dialog.open(ConfirmDialogComponent, { data })
.afterClosed()
.pipe(
exhaustMap((result: boolean) => {
if (result) {
this.complete = true;

let emailPairs = this.careSettingConfigs.map((config) => {
return {
emails: config.formArray.value.map(email => email.email),
careSettingCode: config.settingCode,
healthAuthorityCode: config.settingCode === CareSettingEnum.HEALTH_AUTHORITY ? config.healthAuthorityCode : null,
}
});

return this.enrolmentResource.sendProvisionerAccessLink(emailPairs, this.enrolment.id);
} else {
return EMPTY;
}
})
)
.subscribe(() => {
this.toastService.openSuccessToast('Email was successfully sent');
this.router.navigate([EnrolmentRoutes.PHARMANET_ENROLMENT_SUMMARY],
{ relativeTo: this.route.parent, queryParams: { initialEnrolment: this.initialEnrolment } });
});
this.onPageChange({ atEnd: true });
if (!this.atLeastOneEmailFilled()) {
const data: DialogOptions = {
title: 'Missing Email',
message: `Please enter at least one email for the Approval Notification.`,
cancelText: 'Close',
actionType: 'warn',
actionHide: true,
};
this.dialog.open(ConfirmDialogComponent, { data }).afterClosed();

} else {

const data: DialogOptions = {
title: 'Confirm Email',
message: `Are you sure you want to send your Approval Notification?`,
actionText: 'Send',
};
this.busy = this.dialog.open(ConfirmDialogComponent, { data })
.afterClosed()
.pipe(
exhaustMap((result: boolean) => {
if (result) {
this.complete = true;

let emailPairs = this.careSettingConfigs.map((config) => {
return {
emails: config.formArray.value.map(email => email.email).filter(e => e),
careSettingCode: config.settingCode,
healthAuthorityCode: config.settingCode === CareSettingEnum.HEALTH_AUTHORITY ? config.healthAuthorityCode : null,
}
});

return this.enrolmentResource.sendProvisionerAccessLink(emailPairs.filter((ep) => ep.emails && ep.emails[0]), this.enrolment.id);
} else {
return EMPTY;
}
})
)
.subscribe(() => {
this.toastService.openSuccessToast('Email was successfully sent');
this.router.navigate([EnrolmentRoutes.PHARMANET_ENROLMENT_SUMMARY],
{ relativeTo: this.route.parent, queryParams: { initialEnrolment: this.initialEnrolment } });
});
this.onPageChange({ atEnd: true });
}
}

public getEmailsGroup(careSettingCode: number, healthAuthorityCode: number) {
Expand Down Expand Up @@ -387,7 +402,7 @@ export class NextStepsComponent extends BaseEnrolmentProfilePage implements OnIn
}

protected createFormInstance(): void {
this.form = this.buildEmailGroup();
this.emailForm = this.buildEmailGroup();
}

protected nextRouteAfterSubmit() {
Expand All @@ -409,15 +424,31 @@ export class NextStepsComponent extends BaseEnrolmentProfilePage implements OnIn

private buildEmailGroup(): FormGroup {
return this.fb.group({
communityHealthEmails: this.fb.array([], [Validators.required]),
pharmacistEmails: this.fb.array([], [Validators.required]),
healthAuthorityFraserEmails: this.fb.array([], [Validators.required]),
healthAuthorityInteriorEmails: this.fb.array([], [Validators.required]),
healthAuthorityIslandEmails: this.fb.array([], [Validators.required]),
healthAuthorityNorthernEmails: this.fb.array([], [Validators.required]),
healthAuthorityPHSAEmails: this.fb.array([], [Validators.required]),
healthAuthorityVancouverCoastalEmails: this.fb.array([], [Validators.required]),
deviceProviderEmails: this.fb.array([], [Validators.required]),
communityHealthEmails: this.fb.array([], []),
pharmacistEmails: this.fb.array([], []),
healthAuthorityFraserEmails: this.fb.array([], []),
healthAuthorityInteriorEmails: this.fb.array([], []),
healthAuthorityIslandEmails: this.fb.array([], []),
healthAuthorityNorthernEmails: this.fb.array([], []),
healthAuthorityPHSAEmails: this.fb.array([], []),
healthAuthorityVancouverCoastalEmails: this.fb.array([], []),
deviceProviderEmails: this.fb.array([], []),
});
}

public atLeastOneEmailFilled(): boolean {
let emailFilled = false;

Object.keys(this.emailForm.controls).forEach((emailArrayKey) => {
const emailArray = this.emailForm.controls[emailArrayKey] as FormArray;
Object.keys(emailArray.controls).forEach((emailKey) => {
let emailControl = emailArray.controls[emailKey] as FormGroup;
if (emailControl.controls['email'].value && emailControl.controls['email'].value !== "") {
emailFilled = true;
}
});
});

return emailFilled;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
[formGroupName]="i">
<app-email-form [form]="email"
[index]="i"
[validate]="true"
[validateFormat]="true"
[showRemoveButton]="i>0"
(remove)="removeEmail(settingCode, healthAuthorityCode, $event)">
</app-email-form>
Expand Down
Loading

0 comments on commit 149abb6

Please sign in to comment.