Skip to content

Commit

Permalink
Merge pull request #1768 from fecgov/patch-of-patch
Browse files Browse the repository at this point in the history
Patch of patch
  • Loading branch information
toddlees authored Mar 8, 2024
2 parents 98e6d40 + 5c19413 commit e10a95a
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ <h2 *ngIf="transactionType?.formTitle">
<h3>{{ transactionType?.contactTitle }}</h3>
<form id="form" [formGroup]="form" [ngClass]="{ 'ng-submitted': formSubmitted }">
<app-transaction-input
[activeReport$]="activeReport$"
[isEditable]="isEditable"
[form]="form"
[formSubmitted]="formSubmitted"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ <h2 *ngIf="transactionType?.formTitle">
<h3>{{ transactionType?.contactTitle }}</h3>
<form [formGroup]="form" [ngClass]="{ 'ng-submitted': formSubmitted }" id="form">
<app-transaction-input
[activeReport$]="activeReport$"
(candidateContactSelect)="updateFormWithCandidateContact($event)"
(primaryContactSelect)="updateFormWithPrimaryContact($event)"
(secondaryContactSelect)="updateFormWithSecondaryContact($event)"
Expand Down Expand Up @@ -87,6 +88,7 @@ <h3>{{ transaction?.reatt_redes?.transactionType?.contactTitle || 'Contact' }}</
[contactTypeOptions]="reattributedData.contactTypeOptions"
[formSubmitted]="formSubmitted"
[form]="reattributedData.form"
[activeReport$]="activeReport$"
[isEditable]="false"
[memoCodeCheckboxLabel$]="reattributedData.memoCodeCheckboxLabel$"
[transaction]="transaction?.reatt_redes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ <h4 class="read-only-tag subtitle" *ngIf="isDebtRepayment(transaction)">DEBT REP
<h2>{{ transactionType?.contactTitle || 'Contact' }}</h2>
<form id="form" [formGroup]="form" [ngClass]="{ 'ng-submitted': formSubmitted }">
<app-transaction-input
[activeReport$]="activeReport$"
[isEditable]="isEditable"
[form]="form"
[formSubmitted]="formSubmitted"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<div
class="grid"
*ngIf="
isEditable && !transactionType?.getUseParentContact(transaction) && !transactionType?.hideContactLookup
"
*ngIf="isEditable && !transactionType?.getUseParentContact(transaction) && !transactionType?.hideContactLookup"
>
<div class="col-12">
<div class="field">
Expand Down Expand Up @@ -50,6 +48,7 @@ <h3>Employer</h3>
<p-divider></p-divider>
<h3>{{ transaction?.transactionType?.amountInputHeader }}</h3>
<app-amount-input
[activeReport$]="activeReport$"
[form]="form"
[formSubmitted]="formSubmitted"
[templateMap]="templateMap"
Expand Down Expand Up @@ -188,14 +187,12 @@ <h3>{{ transactionType.committeeCandidateHeader }}</h3>
<ng-container *ngIf="transaction?.transactionType?.hasSupportOpposeCode()">
<app-support-oppose-input [form]="form" [formSubmitted]="formSubmitted"></app-support-oppose-input>
</ng-container>
<ng-container
*ngIf="transaction?.transactionType?.hasCandidateInformation(form) ">
<ng-container *ngIf=" !transactionType?.hideContactLookup">
<ng-container *ngIf="transaction?.transactionType?.hasCandidateInformation(form)">
<ng-container *ngIf="!transactionType?.hideContactLookup">
<label for="contact_2"
>LOOKUP
<ng-container *ngIf="!transaction?.transactionType?.contact2IsRequired(form) ">(OPTIONAL)</ng-container>
</label
>
>LOOKUP
<ng-container *ngIf="!transaction?.transactionType?.contact2IsRequired(form)">(OPTIONAL)</ng-container>
</label>
<app-transaction-contact-lookup
contactProperty="contact_2"
[transaction]="transaction"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { testContact, testScheduleATransaction } from 'app/shared/utils/unit-test.utils';
import { testContact, testMockStore, testScheduleATransaction } from 'app/shared/utils/unit-test.utils';
import { TransactionInputComponent } from './transaction-input.component';
import { FormBuilder, FormControl } from '@angular/forms';
import { ContactTypes } from 'app/shared/models/contact.model';
import { provideMockStore } from '@ngrx/store/testing';
import { ReportService } from 'app/shared/services/report.service';

describe('TransactionInputComponent', () => {
let component: TransactionInputComponent;
let fixture: ComponentFixture<TransactionInputComponent>;
let store;

const selectItem = {
value: testContact,
};

beforeEach(() => {
store = provideMockStore(testMockStore);
TestBed.configureTestingModule({
declarations: [TransactionInputComponent],
providers: [store, ReportService],
});
fixture = TestBed.createComponent(TransactionInputComponent);
component = fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Contact, ContactTypes, ContactTypeLabels } from 'app/shared/models/cont
import { Transaction } from 'app/shared/models/transaction.model';
import { Observable } from 'rxjs';
import { LabelUtils, PrimeOptions } from 'app/shared/utils/label.utils';
import { Report } from 'app/shared/models/report.model';

@Component({
selector: 'app-transaction-input',
Expand All @@ -14,8 +15,9 @@ import { LabelUtils, PrimeOptions } from 'app/shared/utils/label.utils';
export class TransactionInputComponent implements OnInit {
@Input() form: FormGroup = new FormGroup([]);
@Input() formSubmitted = false;
@Input() isEditable = true;
@Input() activeReport$?: Observable<Report>;
@Input() transaction?: Transaction;
@Input() isEditable = true;
@Input() contactTypeOptions: PrimeOptions = LabelUtils.getPrimeOptions(ContactTypeLabels);
@Input() memoCodeCheckboxLabel$?: Observable<string>;
@Input() contributionAmountReadOnly = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ <h2 *ngIf="transactionType?.formTitle">
<h3>{{ transactionType?.contactTitle }}</h3>
<form id="form" [formGroup]="form" [ngClass]="{ 'ng-submitted': formSubmitted }">
<app-transaction-input
[activeReport$]="activeReport$"
[isEditable]="isEditable"
[form]="form"
[formSubmitted]="formSubmitted"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
import { provideMockStore } from '@ngrx/store/testing';
import { MockStore, provideMockStore } from '@ngrx/store/testing';
import { FecDatePipe } from 'app/shared/pipes/fec-date.pipe';
import { getFromJSON } from 'app/shared/utils/transaction-type.utils';
import { testMockStore, testTemplateMap } from 'app/shared/utils/unit-test.utils';
Expand All @@ -13,16 +13,19 @@ import { Tooltip, TooltipModule } from 'primeng/tooltip';
import { ErrorMessagesComponent } from '../../error-messages/error-messages.component';
import { MemoCodeInputComponent } from '../memo-code/memo-code.component';
import { AmountInputComponent } from './amount-input.component';
import { selectActiveReport } from 'app/store/active-report.selectors';

describe('AmountInputComponent', () => {
let component: AmountInputComponent;
let fixture: ComponentFixture<AmountInputComponent>;
let store;

beforeEach(async () => {
store = provideMockStore(testMockStore);
await TestBed.configureTestingModule({
declarations: [AmountInputComponent, ErrorMessagesComponent, FecDatePipe, Dialog, Tooltip],
imports: [CheckboxModule, InputNumberModule, CalendarModule, ReactiveFormsModule, TooltipModule],
providers: [provideMockStore(testMockStore), ConfirmationService],
providers: [store, ConfirmationService],
}).compileComponents();

fixture = TestBed.createComponent(AmountInputComponent);
Expand Down Expand Up @@ -80,6 +83,8 @@ describe('AmountInputComponent', () => {
transaction.loan_id = 'test';
component.transaction = transaction;
component.templateMap = transaction.transactionType.templateMap;
const store = TestBed.inject(MockStore);
component.activeReport$ = store.select(selectActiveReport);
component.ngOnInit();
const dateFormControl = component.form.get(component.templateMap.date);

Expand All @@ -94,7 +99,7 @@ describe('AmountInputComponent', () => {
[transaction.transactionType.templateMap.date]: invalidDate,
});
expect(dateFormControl?.invalid).toBeTrue();

const msg = dateFormControl?.errors?.['invaliddate'].msg;
expect(msg).toEqual('Date must fall within the report date range.');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Store } from '@ngrx/store';
import { SchETransaction } from 'app/shared/models/sche-transaction.model';
import { isDebtRepayment, isLoanRepayment } from 'app/shared/models/transaction.model';
import { DateUtils } from 'app/shared/utils/date.utils';
import { selectActiveReport } from 'app/store/active-report.selectors';
import { InputNumber } from 'primeng/inputnumber';
import { Observable, takeUntil } from 'rxjs';
import { BaseInputComponent } from '../base-input.component';
Expand All @@ -22,6 +21,7 @@ export class AmountInputComponent extends BaseInputComponent implements OnInit,
@Input() negativeAmountValueOnly = false;
@Input() showAggregate = true;
@Input() showCalendarYTD = false;
@Input() activeReport$?: Observable<Report>;

@Input() memoCodeCheckboxLabel = '';
@Input() memoItemHelpText: string | undefined;
Expand All @@ -31,15 +31,13 @@ export class AmountInputComponent extends BaseInputComponent implements OnInit,

dateIsOutsideReport = false; // True if transaction date is outside the report dates
contributionAmountInputStyleClass = '';
activeReport$: Observable<Report>;
reportTypes = ReportTypes;

constructor(
private changeDetectorRef: ChangeDetectorRef,
private store: Store,
) {
super();
this.activeReport$ = this.store.select(selectActiveReport).pipe(takeUntil(this.destroy$));
}

ngOnInit(): void {
Expand Down Expand Up @@ -81,7 +79,7 @@ export class AmountInputComponent extends BaseInputComponent implements OnInit,
}

if (isDebtRepayment(this.transaction) || isLoanRepayment(this.transaction)) {
this.activeReport$.subscribe((report) => {
this.activeReport$?.subscribe((report) => {
this.form.get(this.templateMap.date)?.addValidators((control: AbstractControl): ValidationErrors | null => {
const date = control.value;
if (
Expand Down

0 comments on commit e10a95a

Please sign in to comment.