diff --git a/front-end/src/app/transactions/transaction-group-b/transaction-group-b.component.html b/front-end/src/app/transactions/transaction-group-b/transaction-group-b.component.html index 360d70ea23..7777a79742 100644 --- a/front-end/src/app/transactions/transaction-group-b/transaction-group-b.component.html +++ b/front-end/src/app/transactions/transaction-group-b/transaction-group-b.component.html @@ -18,7 +18,7 @@

Contributor

- +
@@ -38,7 +38,7 @@

Contributor

- +
diff --git a/front-end/src/app/transactions/transaction-group-b/transaction-group-b.component.spec.ts b/front-end/src/app/transactions/transaction-group-b/transaction-group-b.component.spec.ts index 819cd475a4..7ff19d48ec 100644 --- a/front-end/src/app/transactions/transaction-group-b/transaction-group-b.component.spec.ts +++ b/front-end/src/app/transactions/transaction-group-b/transaction-group-b.component.spec.ts @@ -100,7 +100,7 @@ describe('TransactionGroupBComponent', () => { component.form.patchValue({ entity_type: ContactTypes.INDIVIDUAL, }); - expect(component.form.get('contributor_organization_name')?.value).toBe(''); + expect(component.form.get('contributor_organization_name')?.value).toBe(null); expect(component.form.get('contributor_last_name')?.value).toBe('last name'); expect(component.form.get('contributor_first_name')?.value).toBe('first name'); @@ -113,8 +113,8 @@ describe('TransactionGroupBComponent', () => { entity_type: ContactTypes.ORGANIZATION, }); expect(component.form.get('contributor_organization_name')?.value).toBe('org name'); - expect(component.form.get('contributor_last_name')?.value).toBe(''); - expect(component.form.get('contributor_first_name')?.value).toBe(''); + expect(component.form.get('contributor_last_name')?.value).toBe(null); + expect(component.form.get('contributor_first_name')?.value).toBe(null); }); it('#save() should save a new record', () => { diff --git a/front-end/src/app/transactions/transaction-group-b/transaction-group-b.component.ts b/front-end/src/app/transactions/transaction-group-b/transaction-group-b.component.ts index c9176dcd34..28d7aa4417 100644 --- a/front-end/src/app/transactions/transaction-group-b/transaction-group-b.component.ts +++ b/front-end/src/app/transactions/transaction-group-b/transaction-group-b.component.ts @@ -42,7 +42,9 @@ export class TransactionGroupBComponent implements OnInit, OnDestroy { 'memo_text_description', ]; ContactTypes = ContactTypes; - contactTypeOptions: PrimeOptions = LabelUtils.getPrimeOptions(ContactTypeLabels); + contactTypeOptions: PrimeOptions = LabelUtils.getPrimeOptions(ContactTypeLabels).filter( + option => [ContactTypes.INDIVIDUAL, ContactTypes.ORGANIZATION].includes(option.code as ContactTypes) + ); stateOptions: PrimeOptions = LabelUtils.getPrimeOptions(LabelUtils.getStateCodeLabelsWithoutMilitary()); destroy$: Subject = new Subject(); formSubmitted = false; @@ -78,16 +80,15 @@ export class TransactionGroupBComponent implements OnInit, OnDestroy { ?.get('entity_type') ?.valueChanges.pipe(takeUntil(this.destroy$)) .subscribe((value: string) => { - if ([ContactTypes.INDIVIDUAL, ContactTypes.CANDIDATE].includes(value as ContactTypes)) { - this.form.patchValue({ - contributor_organization_name: '', - }); + if (value === ContactTypes.INDIVIDUAL) { + this.form.get('contributor_organization_name')?.reset(); } - if ([ContactTypes.ORGANIZATION, ContactTypes.COMMITTEE].includes(value as ContactTypes)) { - this.form.patchValue({ - contributor_last_name: '', - contributor_first_name: '', - }); + if (value === ContactTypes.ORGANIZATION) { + this.form.get('contributor_last_name')?.reset(); + this.form.get('contributor_first_name')?.reset(); + this.form.get('contributor_middle_name')?.reset(); + this.form.get('contributor_prefix')?.reset(); + this.form.get('contributor_suffix')?.reset(); } }); }