From d6b51a0bee371d0af1f9f2b70919b27850b4ea5f Mon Sep 17 00:00:00 2001 From: Elaine Krauss Date: Mon, 12 Sep 2022 12:17:04 -0400 Subject: [PATCH 01/15] Removes Report Creation Step 2 --- .../create-f3x-step1.component.spec.ts | 2 +- .../create-f3x-step1.component.ts | 10 +- .../create-f3x-step2.component.html | 157 ------------------ .../create-f3x-step2.component.spec.ts | 122 -------------- .../create-f3x-step2.component.ts | 126 -------------- .../report-list/report-list.component.spec.ts | 4 +- .../report-list/report-list.component.ts | 6 +- .../src/app/reports/reports-routing.module.ts | 7 - front-end/src/app/reports/reports.module.ts | 2 - 9 files changed, 14 insertions(+), 422 deletions(-) delete mode 100644 front-end/src/app/reports/f3x/create-workflow/create-f3x-step2.component.html delete mode 100644 front-end/src/app/reports/f3x/create-workflow/create-f3x-step2.component.spec.ts delete mode 100644 front-end/src/app/reports/f3x/create-workflow/create-f3x-step2.component.ts diff --git a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.spec.ts b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.spec.ts index bba4f14782..8506c13044 100644 --- a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.spec.ts +++ b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.spec.ts @@ -82,7 +82,7 @@ describe('CreateF3XStep1Component', () => { navigateSpy.calls.reset(); component.form.patchValue({ ...f3x }); component.save('continue'); - expect(navigateSpy).toHaveBeenCalledWith('/reports/f3x/create/step2/999'); + expect(navigateSpy).toHaveBeenCalledWith('/reports/f3x/create/cash-on-hand/999'); }); it('#save should not save with invalid f3x record', () => { diff --git a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts index 7e77271a1b..034574c4de 100644 --- a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts +++ b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts @@ -26,6 +26,8 @@ import { MessageService } from 'primeng/api'; import { Subject, takeUntil } from 'rxjs'; import { LabelList } from '../../../shared/utils/label.utils'; import { ReportService } from 'app/shared/services/report.service'; +import { CashOnHand } from '../../../shared/interfaces/report.interface'; +import { selectCashOnHand } from '../../../store/cash-on-hand.selectors'; @Component({ selector: 'app-create-f3x-step1', @@ -240,7 +242,13 @@ export class CreateF3XStep1Component implements OnInit, OnDestroy { // Save report to Cash On Hand in the store if necessary by pulling the reports table data. this.reportService.getTableData().subscribe(); - this.router.navigateByUrl(`/reports/f3x/create/step2/${report.id}`); + this.store.select(selectCashOnHand).subscribe((cashOnHand) => { + if (cashOnHand.report_id === report.id) { + this.router.navigateByUrl(`/reports/f3x/create/cash-on-hand/${report.id}`); + } else { + this.router.navigateByUrl(`/transactions/report/${report.id}/list`); + } + }); } else { this.router.navigateByUrl('/reports'); this.messageService.add({ diff --git a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step2.component.html b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step2.component.html deleted file mode 100644 index dc0c6f4036..0000000000 --- a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step2.component.html +++ /dev/null @@ -1,157 +0,0 @@ - - -
-

FEC Form 3X

-
REPORT OF RECEIPTS AND DISBURSEMENTS FOR OTHER THAN AN AUTHORIZED COMMITTEE
- -
-
-
-
-

Committee address

-
Has your address changed in the last 10 days?
-
- -
-
- -
- -
-
-
- -
- Within 10 days of an address change you must notify the FEC by amending your Form 1, in addition to updating - your address here. - Update your committee address. -
-
-
-
- - - -
-
-
-
- - - -
-
-
-
-
-
- - - -
-
-
-
- - - -
-
-
-
- - - -
-
-
-
- -
-
-

Committee status

-
- This committee has - NOT - qualified as a multicandidate committee. -
- -
-
- -
-
-
-

Memo

- -
This step is optional and can be entered later in the filing process.
-
-
-
- -
-
-
REPORT LEVEL MEMO (OPTIONAL)
-
- -
-
-
-
- -
-
- -
-
-
- -
-
- -
-
-
-
diff --git a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step2.component.spec.ts b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step2.component.spec.ts deleted file mode 100644 index 0c4bd66372..0000000000 --- a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step2.component.spec.ts +++ /dev/null @@ -1,122 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { RouterTestingModule } from '@angular/router/testing'; -import { Router, ActivatedRoute } from '@angular/router'; -import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; -import { provideMockStore } from '@ngrx/store/testing'; -import { testMockStore } from 'app/shared/utils/unit-test.utils'; -import { FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { of } from 'rxjs'; -import { MessageService, SharedModule } from 'primeng/api'; -import { DividerModule } from 'primeng/divider'; -import { CheckboxModule } from 'primeng/checkbox'; -import { RadioButtonModule } from 'primeng/radiobutton'; -import { CreateF3xStep2Component } from './create-f3x-step2.component'; -import { F3xSummary } from 'app/shared/models/f3x-summary.model'; -import { environment } from '../../../../environments/environment'; -import { CommitteeAccount } from '../../../shared/models/committee-account.model'; -import { ValidateService } from '../../../shared/services/validate.service'; -import { F3xSummaryService } from '../../../shared/services/f3x-summary.service'; -import { ReportsModule } from '../../reports.module'; - -describe('CreateF3xStep2Component', () => { - let component: CreateF3xStep2Component; - let fixture: ComponentFixture; - let router: Router; - let httpTestingController: HttpTestingController; - let reportService: F3xSummaryService; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [ - FormsModule, - ReactiveFormsModule, - RouterTestingModule.withRoutes([]), - HttpClientTestingModule, - DividerModule, - CheckboxModule, - RadioButtonModule, - SharedModule, - ReportsModule, - ], - declarations: [CreateF3xStep2Component], - providers: [ - ValidateService, - FormBuilder, - F3xSummaryService, - MessageService, - provideMockStore(testMockStore), - { - provide: ActivatedRoute, - useValue: { - snapshot: { - data: { - report: F3xSummary.fromJSON({}), - }, - }, - }, - }, - ], - }).compileComponents(); - }); - - beforeEach(() => { - router = TestBed.inject(Router); - reportService = TestBed.inject(F3xSummaryService); - httpTestingController = TestBed.inject(HttpTestingController); - fixture = TestBed.createComponent(CreateF3xStep2Component); - component = fixture.componentInstance; - spyOn(reportService, 'get').and.returnValue(of(F3xSummary.fromJSON({}))); - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); - - it('#save should go back when back button clicked', () => { - const navigateSpy = spyOn(router, 'navigateByUrl'); - component.report = F3xSummary.fromJSON({ - id: '999', - }); - component.form.patchValue({ change_of_address: true }); - - component.save('back'); - let req = httpTestingController.expectOne( - `${environment.apiUrl}/f3x-summaries/${component.report.id}/?fields_to_validate=change_of_address,street_1,street_2,city,state,zip,memo_checkbox,memo` - ); - expect(req.request.method).toEqual('PUT'); - req.flush(component.report); - expect(navigateSpy).toHaveBeenCalledWith('/reports'); - - navigateSpy.calls.reset(); - component.save('continue'); - req = httpTestingController.expectOne( - `${environment.apiUrl}/f3x-summaries/${component.report.id}/?fields_to_validate=change_of_address,street_1,street_2,city,state,zip,memo_checkbox,memo` - ); - expect(req.request.method).toEqual('PUT'); - req.flush(component.report); - expect(navigateSpy).toHaveBeenCalledWith('/transactions/report/999/list'); - }); - - it('#save should not save when form data invalid', () => { - component.report = F3xSummary.fromJSON({ - id: '999', - change_of_address: 'A', - street_1: '123 Main St', - street_2: 'Apt A', - city: 'Washington', - state: 'DC', - zip: '20001', - }); - component.setDefaultFormValues({ - street_1: '3 Oak St', - street_2: null, - city: 'Pheonix', - state: 'AZ', - zip: '12345', - } as CommitteeAccount); - - component.save(); - expect(component.form.invalid).toBe(true); - }); -}); diff --git a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step2.component.ts b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step2.component.ts deleted file mode 100644 index bfc2d02454..0000000000 --- a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step2.component.ts +++ /dev/null @@ -1,126 +0,0 @@ -import { Component, OnDestroy, OnInit } from '@angular/core'; -import { Router } from '@angular/router'; -import { FormBuilder, FormGroup } from '@angular/forms'; -import { Observable, Subject, takeUntil } from 'rxjs'; -import { Store } from '@ngrx/store'; -import { MessageService } from 'primeng/api'; -import { selectCommitteeAccount } from 'app/store/committee-account.selectors'; -import { selectCashOnHand } from 'app/store/cash-on-hand.selectors'; -import { selectActiveReport } from 'app/store/active-report.selectors'; -import { LabelUtils, PrimeOptions, StatesCodeLabels, CountryCodeLabels } from 'app/shared/utils/label.utils'; -import { ValidateService } from 'app/shared/services/validate.service'; -import { schema as f3xSchema } from 'fecfile-validate/fecfile_validate_js/dist/F3X'; -import { F3xSummary } from 'app/shared/models/f3x-summary.model'; -import { F3xSummaryService } from 'app/shared/services/f3x-summary.service'; -import { CommitteeAccount } from 'app/shared/models/committee-account.model'; -import { CashOnHand } from 'app/shared/interfaces/report.interface'; - -@Component({ - selector: 'app-create-f3x-step2', - templateUrl: './create-f3x-step2.component.html', -}) -export class CreateF3xStep2Component implements OnInit, OnDestroy { - formProperties: string[] = [ - 'change_of_address', - 'street_1', - 'street_2', - 'city', - 'state', - 'zip', - 'memo_checkbox', - 'memo', - ]; - report: F3xSummary | undefined; - stateOptions: PrimeOptions = []; - countryOptions: PrimeOptions = []; - formSubmitted = false; - destroy$: Subject = new Subject(); - committeeAccount$: Observable = this.store.select(selectCommitteeAccount); - cashOnHand: CashOnHand = { - report_id: undefined, - value: null, - }; - - form: FormGroup = this.fb.group(this.validateService.getFormGroupFields(this.formProperties)); - - constructor( - private router: Router, - private f3xSummaryService: F3xSummaryService, - private validateService: ValidateService, - private fb: FormBuilder, - private store: Store, - private messageService: MessageService - ) {} - - ngOnInit(): void { - this.stateOptions = LabelUtils.getPrimeOptions(StatesCodeLabels); - this.countryOptions = LabelUtils.getPrimeOptions(CountryCodeLabels); - - this.store - .select(selectActiveReport) - .pipe(takeUntil(this.destroy$)) - .subscribe((report) => (this.report = report as F3xSummary)); - this.store - .select(selectCommitteeAccount) - .pipe(takeUntil(this.destroy$)) - .subscribe((committeeAccount) => this.setDefaultFormValues(committeeAccount)); - this.store - .select(selectCashOnHand) - .pipe(takeUntil(this.destroy$)) - .subscribe((cashOnHand) => (this.cashOnHand = cashOnHand)); - - // Initialize validation tracking of current JSON schema and form data - this.validateService.formValidatorSchema = f3xSchema; - this.validateService.formValidatorForm = this.form; - } - - setDefaultFormValues(committeeAccount: CommitteeAccount) { - this.form.patchValue({ - change_of_address: this.report?.change_of_address !== null ? this.report?.change_of_address : null, - street_1: this.report?.street_1 ? this.report.street_1 : committeeAccount?.street_1, - street_2: this.report?.street_2 ? this.report.street_2 : committeeAccount?.street_2, - city: this.report?.city ? this.report.city : committeeAccount?.city, - state: this.report?.state ? this.report.state : committeeAccount?.state, - zip: this.report?.zip ? this.report.zip : committeeAccount?.zip, - memo_checkbox: false, - memo: '', - }); - } - - ngOnDestroy(): void { - this.destroy$.next(true); - this.destroy$.complete(); - } - - public save(jump: 'continue' | 'back' | null = null): void { - this.formSubmitted = true; - - if (this.form.invalid) { - return; - } - - const payload: F3xSummary = F3xSummary.fromJSON({ - ...this.report, - ...this.validateService.getFormValues(this.form, this.formProperties), - }); - - this.f3xSummaryService.update(payload, this.formProperties).subscribe(() => { - if (jump === 'continue' && this.report?.id) { - if (this.cashOnHand.report_id === this.report.id) { - this.router.navigateByUrl(`/reports/f3x/create/cash-on-hand/${this.report.id}`); - } else { - this.router.navigateByUrl(`/transactions/report/${this.report.id}/list`); - } - } - if (jump === 'back' && this.report?.id) { - this.router.navigateByUrl('/reports'); - } - this.messageService.add({ - severity: 'success', - summary: 'Successful', - detail: 'Report Updated', - life: 3000, - }); - }); - } -} diff --git a/front-end/src/app/reports/report-list/report-list.component.spec.ts b/front-end/src/app/reports/report-list/report-list.component.spec.ts index d931c1d22f..a4c5988cef 100644 --- a/front-end/src/app/reports/report-list/report-list.component.spec.ts +++ b/front-end/src/app/reports/report-list/report-list.component.spec.ts @@ -49,10 +49,8 @@ describe('ReportListComponent', () => { it('#editItem should route properly', () => { const navigateSpy = spyOn(router, 'navigateByUrl'); - component.editItem({ id: 999, change_of_address: null } as F3xSummary); - expect(navigateSpy).toHaveBeenCalledWith('/reports/f3x/create/step2/999'); - component.editItem({ id: 999, change_of_address: true } as F3xSummary); + component.editItem({ id: 999 } as F3xSummary); expect(navigateSpy).toHaveBeenCalledWith('/reports/f3x/create/cash-on-hand/999'); }); diff --git a/front-end/src/app/reports/report-list/report-list.component.ts b/front-end/src/app/reports/report-list/report-list.component.ts index 48888fbb46..36e978dc59 100644 --- a/front-end/src/app/reports/report-list/report-list.component.ts +++ b/front-end/src/app/reports/report-list/report-list.component.ts @@ -69,9 +69,9 @@ export class ReportListComponent extends TableListBaseComponent implemen } public override editItem(item: Report): void { - if ((item as F3xSummary).change_of_address === null) { - this.router.navigateByUrl(`/reports/f3x/create/step2/${item.id}`); - } else if (!this.itemService.isEditable(item)) { + //if ((item as F3xSummary).change_of_address === null) { + // this.router.navigateByUrl(`/reports/f3x/create/step2/${item.id}`); + if (!this.itemService.isEditable(item)) { this.router.navigateByUrl(`/reports/f3x/submit/status/${item.id}`); } else if (item.id === this.cashOnHand.report_id) { this.router.navigateByUrl(`/reports/f3x/create/cash-on-hand/${item.id}`); diff --git a/front-end/src/app/reports/reports-routing.module.ts b/front-end/src/app/reports/reports-routing.module.ts index 252f7f524a..ad915930ef 100644 --- a/front-end/src/app/reports/reports-routing.module.ts +++ b/front-end/src/app/reports/reports-routing.module.ts @@ -2,7 +2,6 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { ReportListComponent } from './report-list/report-list.component'; import { CreateF3XStep1Component } from './f3x/create-workflow/create-f3x-step1.component'; -import { CreateF3xStep2Component } from './f3x/create-workflow/create-f3x-step2.component'; import { ReportSummaryComponent } from './f3x/report-summary/report-summary.component'; import { ReportDetailedSummaryComponent } from './f3x/report-detailed-summary/report-detailed-summary.component'; import { ReportResolver } from 'app/shared/resolvers/report.resolver'; @@ -47,12 +46,6 @@ const routes: Routes = [ component: CreateF3XStep1Component, canActivate: [ReportIsEditableGuard], }, - { - path: 'f3x/create/step2/:reportId', - title: 'Report Form 3X', - component: CreateF3xStep2Component, - canActivate: [ReportIsEditableGuard], - }, { path: 'f3x/summary/:reportId', title: 'View summary page', diff --git a/front-end/src/app/reports/reports.module.ts b/front-end/src/app/reports/reports.module.ts index 300227099b..2ce3a1c0d1 100644 --- a/front-end/src/app/reports/reports.module.ts +++ b/front-end/src/app/reports/reports.module.ts @@ -21,7 +21,6 @@ import { TooltipModule } from 'primeng/tooltip'; import { SharedModule } from '../../app/shared/shared.module'; import { CreateF3XStep1Component } from './f3x/create-workflow/create-f3x-step1.component'; -import { CreateF3xStep2Component } from './f3x/create-workflow/create-f3x-step2.component'; import { ReportDetailedSummaryComponent } from './f3x/report-detailed-summary/report-detailed-summary.component'; import { ReportLevelMemoComponent } from './f3x/report-level-memo/report-level-memo.component'; import { ReportSummaryComponent } from './f3x/report-summary/report-summary.component'; @@ -40,7 +39,6 @@ import { InputNumberModule } from 'primeng/inputnumber'; declarations: [ ReportListComponent, CreateF3XStep1Component, - CreateF3xStep2Component, SubmitF3xStep1Component, SubmitF3xStep2Component, ReportSummaryComponent, From 0f52526a6b3059edd787fdd693dfde5214d45c0f Mon Sep 17 00:00:00 2001 From: Elaine Krauss Date: Mon, 12 Sep 2022 14:46:40 -0400 Subject: [PATCH 02/15] Fixes a redirect bug caused by an unterminated subscription --- .../create-f3x-step1.component.ts | 17 ++++++++++------- .../report-list/report-list.component.ts | 2 -- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts index 034574c4de..2fa67baf92 100644 --- a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts +++ b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts @@ -242,13 +242,16 @@ export class CreateF3XStep1Component implements OnInit, OnDestroy { // Save report to Cash On Hand in the store if necessary by pulling the reports table data. this.reportService.getTableData().subscribe(); - this.store.select(selectCashOnHand).subscribe((cashOnHand) => { - if (cashOnHand.report_id === report.id) { - this.router.navigateByUrl(`/reports/f3x/create/cash-on-hand/${report.id}`); - } else { - this.router.navigateByUrl(`/transactions/report/${report.id}/list`); - } - }); + this.store + .select(selectCashOnHand) + .pipe(takeUntil(this.destroy$)) + .subscribe((cashOnHand) => { + if (cashOnHand.report_id === report.id) { + this.router.navigateByUrl(`/reports/f3x/create/cash-on-hand/${report.id}`); + } else { + this.router.navigateByUrl(`/transactions/report/${report.id}/list`); + } + }); } else { this.router.navigateByUrl('/reports'); this.messageService.add({ diff --git a/front-end/src/app/reports/report-list/report-list.component.ts b/front-end/src/app/reports/report-list/report-list.component.ts index 36e978dc59..d1a5f94c27 100644 --- a/front-end/src/app/reports/report-list/report-list.component.ts +++ b/front-end/src/app/reports/report-list/report-list.component.ts @@ -69,8 +69,6 @@ export class ReportListComponent extends TableListBaseComponent implemen } public override editItem(item: Report): void { - //if ((item as F3xSummary).change_of_address === null) { - // this.router.navigateByUrl(`/reports/f3x/create/step2/${item.id}`); if (!this.itemService.isEditable(item)) { this.router.navigateByUrl(`/reports/f3x/submit/status/${item.id}`); } else if (item.id === this.cashOnHand.report_id) { From 0c3a5374fd73d2c7e10d858757c00ca62d514673 Mon Sep 17 00:00:00 2001 From: Elaine Krauss Date: Mon, 12 Sep 2022 14:51:26 -0400 Subject: [PATCH 03/15] Removes unused import --- .../reports/f3x/create-workflow/create-f3x-step1.component.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts index 2fa67baf92..13604d65bf 100644 --- a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts +++ b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts @@ -26,7 +26,6 @@ import { MessageService } from 'primeng/api'; import { Subject, takeUntil } from 'rxjs'; import { LabelList } from '../../../shared/utils/label.utils'; import { ReportService } from 'app/shared/services/report.service'; -import { CashOnHand } from '../../../shared/interfaces/report.interface'; import { selectCashOnHand } from '../../../store/cash-on-hand.selectors'; @Component({ From e05e8b871f63a68945c5680f04e6143e30457648 Mon Sep 17 00:00:00 2001 From: Elaine Krauss Date: Tue, 13 Sep 2022 13:54:55 -0400 Subject: [PATCH 04/15] Updates commenting --- .../create-f3x-step1.component.ts | 57 +++++++++++-------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts index 13604d65bf..b54b394720 100644 --- a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts +++ b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts @@ -23,7 +23,7 @@ import { selectActiveReport } from 'app/store/active-report.selectors'; import { environment } from 'environments/environment'; import { schema as f3xSchema } from 'fecfile-validate/fecfile_validate_js/dist/F3X'; import { MessageService } from 'primeng/api'; -import { Subject, takeUntil } from 'rxjs'; +import { combineLatestWith, Subject, switchMap, of, takeUntil, zip } from 'rxjs'; import { LabelList } from '../../../shared/utils/label.utils'; import { ReportService } from 'app/shared/services/report.service'; import { selectCashOnHand } from '../../../store/cash-on-hand.selectors'; @@ -236,31 +236,40 @@ export class CreateF3XStep1Component implements OnInit, OnDestroy { summary.form_type = F3xFormTypes.F3XT; } - this.f3xSummaryService.create(summary, this.formProperties).subscribe((report: F3xSummary) => { - if (jump === 'continue') { - // Save report to Cash On Hand in the store if necessary by pulling the reports table data. - this.reportService.getTableData().subscribe(); + //Observables are *defined* here ahead of their execution + const create = this.f3xSummaryService.create(summary, this.formProperties); + // Save report to Cash On Hand in the store if necessary by pulling the reports table data. + const tableData = this.reportService.getTableData(); + const cashOnHand = this.store.select(selectCashOnHand); - this.store - .select(selectCashOnHand) - .pipe(takeUntil(this.destroy$)) - .subscribe((cashOnHand) => { - if (cashOnHand.report_id === report.id) { - this.router.navigateByUrl(`/reports/f3x/create/cash-on-hand/${report.id}`); - } else { - this.router.navigateByUrl(`/transactions/report/${report.id}/list`); - } + //Create the report, update cashOnHand based on all reports, and then retrieve cashOnHand in that order + create + .pipe( + switchMap((report) => { + return zip(of(report), tableData); + }), + switchMap(([report, _tableData]) => { + return zip(of(report), cashOnHand); + }), + takeUntil(this.destroy$) + ) + .subscribe(([report, coh]) => { + if (jump === 'continue') { + if (coh.report_id != undefined && coh.report_id != report.id) { + this.router.navigateByUrl(`/transactions/report/${report.id}/list`); + } else { + this.router.navigateByUrl(`/reports/f3x/create/cash-on-hand/${report.id}`); + } + } else { + this.router.navigateByUrl('/reports'); + this.messageService.add({ + severity: 'success', + summary: 'Successful', + detail: 'Contact Updated', + life: 3000, }); - } else { - this.router.navigateByUrl('/reports'); - this.messageService.add({ - severity: 'success', - summary: 'Successful', - detail: 'Contact Updated', - life: 3000, - }); - } - }); + } + }); } } From 8d4831bc65898c2ffd269b876a9a6b71648dcaff Mon Sep 17 00:00:00 2001 From: Elaine Krauss Date: Tue, 13 Sep 2022 14:03:57 -0400 Subject: [PATCH 05/15] Linting updates --- .../reports/f3x/create-workflow/create-f3x-step1.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts index b54b394720..54bed5100b 100644 --- a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts +++ b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts @@ -23,7 +23,7 @@ import { selectActiveReport } from 'app/store/active-report.selectors'; import { environment } from 'environments/environment'; import { schema as f3xSchema } from 'fecfile-validate/fecfile_validate_js/dist/F3X'; import { MessageService } from 'primeng/api'; -import { combineLatestWith, Subject, switchMap, of, takeUntil, zip } from 'rxjs'; +import { Subject, switchMap, of, takeUntil, zip } from 'rxjs'; import { LabelList } from '../../../shared/utils/label.utils'; import { ReportService } from 'app/shared/services/report.service'; import { selectCashOnHand } from '../../../store/cash-on-hand.selectors'; @@ -248,7 +248,7 @@ export class CreateF3XStep1Component implements OnInit, OnDestroy { switchMap((report) => { return zip(of(report), tableData); }), - switchMap(([report, _tableData]) => { + switchMap(([report, _]) => { return zip(of(report), cashOnHand); }), takeUntil(this.destroy$) From f3ee257d8dfb2fcb5d46d2fc1e0bdccd5da87a83 Mon Sep 17 00:00:00 2001 From: Elaine Krauss Date: Tue, 13 Sep 2022 14:32:00 -0400 Subject: [PATCH 06/15] Reworks one of the switchMaps so that there isn't an unused variable... --- .../reports/f3x/create-workflow/create-f3x-step1.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts index 54bed5100b..1e52dc15cf 100644 --- a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts +++ b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts @@ -248,8 +248,8 @@ export class CreateF3XStep1Component implements OnInit, OnDestroy { switchMap((report) => { return zip(of(report), tableData); }), - switchMap(([report, _]) => { - return zip(of(report), cashOnHand); + switchMap((responses: [F3xSummary, any]) => { + return zip(of(responses[0]), cashOnHand); }), takeUntil(this.destroy$) ) From ff9a904e98fa1564af29f5b6a5f6b464d7695ff0 Mon Sep 17 00:00:00 2001 From: Elaine Krauss Date: Tue, 13 Sep 2022 14:36:13 -0400 Subject: [PATCH 07/15] Removes 'any' type --- .../reports/f3x/create-workflow/create-f3x-step1.component.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts index 1e52dc15cf..11f0867f81 100644 --- a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts +++ b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts @@ -27,6 +27,7 @@ import { Subject, switchMap, of, takeUntil, zip } from 'rxjs'; import { LabelList } from '../../../shared/utils/label.utils'; import { ReportService } from 'app/shared/services/report.service'; import { selectCashOnHand } from '../../../store/cash-on-hand.selectors'; +import { ListRestResponse } from '../../../shared/models/rest-api.model'; @Component({ selector: 'app-create-f3x-step1', @@ -248,7 +249,7 @@ export class CreateF3XStep1Component implements OnInit, OnDestroy { switchMap((report) => { return zip(of(report), tableData); }), - switchMap((responses: [F3xSummary, any]) => { + switchMap((responses: [F3xSummary, ListRestResponse]) => { return zip(of(responses[0]), cashOnHand); }), takeUntil(this.destroy$) From 6202a66eb2fb7e4ca2f1ea4399f58539e00e5d0f Mon Sep 17 00:00:00 2001 From: Elaine Krauss Date: Tue, 13 Sep 2022 15:18:03 -0400 Subject: [PATCH 08/15] Add $ to observable variables --- .../create-workflow/create-f3x-step1.component.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts index 11f0867f81..c028ba8433 100644 --- a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts +++ b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts @@ -238,21 +238,20 @@ export class CreateF3XStep1Component implements OnInit, OnDestroy { } //Observables are *defined* here ahead of their execution - const create = this.f3xSummaryService.create(summary, this.formProperties); + const create$ = this.f3xSummaryService.create(summary, this.formProperties).pipe(takeUntil(this.destroy$)); // Save report to Cash On Hand in the store if necessary by pulling the reports table data. - const tableData = this.reportService.getTableData(); - const cashOnHand = this.store.select(selectCashOnHand); + const tableData$ = this.reportService.getTableData().pipe(takeUntil(this.destroy$)); + const cashOnHand$ = this.store.select(selectCashOnHand).pipe(takeUntil(this.destroy$)); //Create the report, update cashOnHand based on all reports, and then retrieve cashOnHand in that order - create + create$ .pipe( switchMap((report) => { - return zip(of(report), tableData); + return zip(of(report), tableData$); }), switchMap((responses: [F3xSummary, ListRestResponse]) => { - return zip(of(responses[0]), cashOnHand); - }), - takeUntil(this.destroy$) + return zip(of(responses[0]), cashOnHand$); + }) ) .subscribe(([report, coh]) => { if (jump === 'continue') { From d099e3a19287c2a08d49410ae7c069f862da034f Mon Sep 17 00:00:00 2001 From: Elaine Krauss Date: Tue, 13 Sep 2022 15:44:27 -0400 Subject: [PATCH 09/15] changes pathing for imports in order that VSCode can work a little smoother --- .../reports/f3x/create-workflow/create-f3x-step1.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts index c028ba8433..5b767133f3 100644 --- a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts +++ b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts @@ -25,7 +25,7 @@ import { schema as f3xSchema } from 'fecfile-validate/fecfile_validate_js/dist/F import { MessageService } from 'primeng/api'; import { Subject, switchMap, of, takeUntil, zip } from 'rxjs'; import { LabelList } from '../../../shared/utils/label.utils'; -import { ReportService } from 'app/shared/services/report.service'; +import { ReportService } from '../../../shared/services/report.service'; import { selectCashOnHand } from '../../../store/cash-on-hand.selectors'; import { ListRestResponse } from '../../../shared/models/rest-api.model'; From beffb43182e8bd5b9e2f2be84edb852253ee4076 Mon Sep 17 00:00:00 2001 From: Elaine Krauss Date: Tue, 13 Sep 2022 15:44:38 -0400 Subject: [PATCH 10/15] Fixes unit test --- .../create-f3x-step1.component.spec.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.spec.ts b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.spec.ts index 8506c13044..71ecd779ee 100644 --- a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.spec.ts +++ b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.spec.ts @@ -4,7 +4,7 @@ import { Router } from '@angular/router'; import { AbstractControl, FormBuilder, ReactiveFormsModule } from '@angular/forms'; import { RouterTestingModule } from '@angular/router/testing'; import { provideMockStore } from '@ngrx/store/testing'; -import { testMockStore } from 'app/shared/utils/unit-test.utils'; +import { testMockStore } from '../../../shared/utils/unit-test.utils'; import { of } from 'rxjs'; import { F3xReportCodes, F3xSummary } from 'app/shared/models/f3x-summary.model'; import { F3xSummaryService } from 'app/shared/services/f3x-summary.service'; @@ -18,12 +18,15 @@ import { CreateF3XStep1Component, F3xReportTypeCategories } from './create-f3x-s import { FecDatePipe } from 'app/shared/pipes/fec-date.pipe'; import { F3xCoverageDates } from '../../../shared/models/f3x-summary.model'; import { AppSelectButtonComponent } from '../../../shared/components/app-selectbutton'; +import { ReportService } from '../../../shared/services/report.service'; +import { ListRestResponse } from '../../../shared/models/rest-api.model'; describe('CreateF3XStep1Component', () => { let component: CreateF3XStep1Component; let router: Router; let fixture: ComponentFixture; let f3xSummaryService: F3xSummaryService; + let reportService: ReportService; const f3x: F3xSummary = F3xSummary.fromJSON({ id: 999, coverage_from_date: '2022-05-25', @@ -50,6 +53,7 @@ describe('CreateF3XStep1Component', () => { beforeEach(() => { router = TestBed.inject(Router); f3xSummaryService = TestBed.inject(F3xSummaryService); + reportService = TestBed.inject(ReportService); fixture = TestBed.createComponent(CreateF3XStep1Component); component = fixture.componentInstance; fixture.detectChanges(); @@ -73,8 +77,16 @@ describe('CreateF3XStep1Component', () => { }); it('#save should save a new f3x record', () => { + let lrr: ListRestResponse = { + count: 0, + next: '/', + previous: '/', + results: [], + }; spyOn(f3xSummaryService, 'create').and.returnValue(of(f3x)); + spyOn(reportService, 'getTableData').and.returnValue(of(lrr)); const navigateSpy = spyOn(router, 'navigateByUrl'); + component.form.patchValue({ ...f3x }); component.save(); expect(navigateSpy).toHaveBeenCalledWith('/reports'); From 2ae2c6696238c4ff761f18cb399d28b8cd16d9ba Mon Sep 17 00:00:00 2001 From: Elaine Krauss Date: Tue, 13 Sep 2022 15:48:05 -0400 Subject: [PATCH 11/15] 'let lrr' -> 'const listResponse' --- .../f3x/create-workflow/create-f3x-step1.component.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.spec.ts b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.spec.ts index 71ecd779ee..d9e7d7b035 100644 --- a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.spec.ts +++ b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.spec.ts @@ -77,14 +77,14 @@ describe('CreateF3XStep1Component', () => { }); it('#save should save a new f3x record', () => { - let lrr: ListRestResponse = { + const listResponse = { count: 0, next: '/', previous: '/', results: [], }; spyOn(f3xSummaryService, 'create').and.returnValue(of(f3x)); - spyOn(reportService, 'getTableData').and.returnValue(of(lrr)); + spyOn(reportService, 'getTableData').and.returnValue(of(listResponse)); const navigateSpy = spyOn(router, 'navigateByUrl'); component.form.patchValue({ ...f3x }); From 629d51fba5c71a84d884a8267840b80cd283dc49 Mon Sep 17 00:00:00 2001 From: Elaine Krauss Date: Tue, 13 Sep 2022 15:50:13 -0400 Subject: [PATCH 12/15] 'let lrr' -> 'const listResponse' --- .../f3x/create-workflow/create-f3x-step1.component.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.spec.ts b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.spec.ts index d9e7d7b035..b331f0d05b 100644 --- a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.spec.ts +++ b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.spec.ts @@ -82,7 +82,7 @@ describe('CreateF3XStep1Component', () => { next: '/', previous: '/', results: [], - }; + } as ListRestResponse; spyOn(f3xSummaryService, 'create').and.returnValue(of(f3x)); spyOn(reportService, 'getTableData').and.returnValue(of(listResponse)); const navigateSpy = spyOn(router, 'navigateByUrl'); From 8f718075cd2c1293f0ce10e347bdd2ffa5b7a86b Mon Sep 17 00:00:00 2001 From: Elaine Krauss Date: Tue, 13 Sep 2022 16:21:48 -0400 Subject: [PATCH 13/15] tableData$ is now run and mapped to ()=>report --- .../f3x/create-workflow/create-f3x-step1.component.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts index 5b767133f3..215f6a4006 100644 --- a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts +++ b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts @@ -23,7 +23,7 @@ import { selectActiveReport } from 'app/store/active-report.selectors'; import { environment } from 'environments/environment'; import { schema as f3xSchema } from 'fecfile-validate/fecfile_validate_js/dist/F3X'; import { MessageService } from 'primeng/api'; -import { Subject, switchMap, of, takeUntil, zip } from 'rxjs'; +import { Subject, switchMap, of, takeUntil, zip, map } from 'rxjs'; import { LabelList } from '../../../shared/utils/label.utils'; import { ReportService } from '../../../shared/services/report.service'; import { selectCashOnHand } from '../../../store/cash-on-hand.selectors'; @@ -246,11 +246,9 @@ export class CreateF3XStep1Component implements OnInit, OnDestroy { //Create the report, update cashOnHand based on all reports, and then retrieve cashOnHand in that order create$ .pipe( + switchMap((report) => tableData$.pipe(map(() => report))), switchMap((report) => { - return zip(of(report), tableData$); - }), - switchMap((responses: [F3xSummary, ListRestResponse]) => { - return zip(of(responses[0]), cashOnHand$); + return zip(of(report), cashOnHand$); }) ) .subscribe(([report, coh]) => { From f0976d92a083438dc4205dcaf2d2dca312ea7dd5 Mon Sep 17 00:00:00 2001 From: Elaine Krauss Date: Tue, 13 Sep 2022 16:23:29 -0400 Subject: [PATCH 14/15] Removes unused import --- .../reports/f3x/create-workflow/create-f3x-step1.component.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts index 215f6a4006..fb506b17c6 100644 --- a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts +++ b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts @@ -27,7 +27,6 @@ import { Subject, switchMap, of, takeUntil, zip, map } from 'rxjs'; import { LabelList } from '../../../shared/utils/label.utils'; import { ReportService } from '../../../shared/services/report.service'; import { selectCashOnHand } from '../../../store/cash-on-hand.selectors'; -import { ListRestResponse } from '../../../shared/models/rest-api.model'; @Component({ selector: 'app-create-f3x-step1', From 293a9ca2ea3c94cdcf6e390009a31460b87fad2c Mon Sep 17 00:00:00 2001 From: Matt Travers Date: Tue, 13 Sep 2022 17:03:06 -0400 Subject: [PATCH 15/15] Consolidated completing observables to call after switchMaps --- .../f3x/create-workflow/create-f3x-step1.component.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts index fb506b17c6..cc082f05d1 100644 --- a/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts +++ b/front-end/src/app/reports/f3x/create-workflow/create-f3x-step1.component.ts @@ -237,10 +237,10 @@ export class CreateF3XStep1Component implements OnInit, OnDestroy { } //Observables are *defined* here ahead of their execution - const create$ = this.f3xSummaryService.create(summary, this.formProperties).pipe(takeUntil(this.destroy$)); + const create$ = this.f3xSummaryService.create(summary, this.formProperties); // Save report to Cash On Hand in the store if necessary by pulling the reports table data. - const tableData$ = this.reportService.getTableData().pipe(takeUntil(this.destroy$)); - const cashOnHand$ = this.store.select(selectCashOnHand).pipe(takeUntil(this.destroy$)); + const tableData$ = this.reportService.getTableData(); + const cashOnHand$ = this.store.select(selectCashOnHand); //Create the report, update cashOnHand based on all reports, and then retrieve cashOnHand in that order create$ @@ -248,7 +248,8 @@ export class CreateF3XStep1Component implements OnInit, OnDestroy { switchMap((report) => tableData$.pipe(map(() => report))), switchMap((report) => { return zip(of(report), cashOnHand$); - }) + }), + takeUntil(this.destroy$) ) .subscribe(([report, coh]) => { if (jump === 'continue') {