Skip to content

Commit

Permalink
Merge pull request #577 from fecgov/feature/538-committee-lookup
Browse files Browse the repository at this point in the history
Feature/538 committee lookup
  • Loading branch information
mjtravers authored Sep 21, 2022
2 parents 8dbf269 + b63fda6 commit b794aea
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ export class ContactLookupComponent {
@Input() contactTypeOptions: PrimeOptions = [];
@Input() contactTypeInputId = 'entity_type';
@Input() contactTypeFormControl: FormControl = new FormControl();
@Input() contactTypeReadOnly = true;
@Input() contactTypeReadOnly = false;
@Input() contactTypeStyleClass = "";

@Input() maxFecResults = 10;
@Input() maxFecfileResults = 10;
@Input() maxFecCommitteeResults = 5;
@Input() maxFecfileCommitteeResults = 5;
@Input() maxFecfileIndividualResults = 10;
@Input() maxFecfileOrganizationResults = 10;

@Output() fecfileContactSelect =
new EventEmitter<SelectItem<Contact>>();
Expand Down Expand Up @@ -49,22 +51,22 @@ export class ContactLookupComponent {
switch (this.contactTypeFormControl.value) {
case ContactTypes.COMMITTEE:
this.contactService.committeeLookup(
searchTerm, this.maxFecResults,
this.maxFecfileResults).subscribe((response) => {
searchTerm, this.maxFecCommitteeResults,
this.maxFecfileCommitteeResults).subscribe((response) => {
this.contactLookupList = response &&
response.toSelectItemGroups();
});
break;
case ContactTypes.INDIVIDUAL:
this.contactService.individualLookup(searchTerm,
this.maxFecfileResults).subscribe((response) => {
this.maxFecfileIndividualResults).subscribe((response) => {
this.contactLookupList = response &&
response.toSelectItemGroups();
});
break;
case ContactTypes.ORGANIZATION:
this.contactService.organizationLookup(searchTerm,
this.maxFecfileResults).subscribe((response) => {
this.maxFecfileOrganizationResults).subscribe((response) => {
this.contactLookupList = response &&
response.toSelectItemGroups();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,26 @@ describe('TransactionTypeBaseComponent', () => {
testOrganizationName).toBeTrue();
});

it('#onContactLookupSelect COMMITTEE should set fields', () => {
const testEntityType = ContactTypes.COMMITTEE;
const testCommitteeName = 'testCommitteeName';
const testContact = new Contact();
testContact.id = '123';
testContact.type = ContactTypes.COMMITTEE;
testContact.name = testCommitteeName;

const testContactSelectItem: SelectItem<Contact> =
{
value: testContact,
}

component.form.addControl('entity_type', { value: testEntityType });
component.onContactLookupSelect(testContactSelectItem);
const committeeNameFormControlValue =
component.form.get('contributor_organization_name')?.value;

expect(committeeNameFormControlValue ===
testCommitteeName).toBeTrue();
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export abstract class TransactionTypeBaseComponent implements OnInit, OnDestroy
this.form.get('contributor_employer')?.setValue(value.employer);
this.form.get('contributor_occupation')?.setValue(value.occupation);
break;
case ContactTypes.COMMITTEE:
case ContactTypes.ORGANIZATION:
this.form.get('contributor_organization_name')?.setValue(value.name);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ <h3>Contributor</h3>
<div class="col-12">
<label for="entity_type">CONTRIBUTOR TYPE</label>
<app-contact-lookup
contactTypeInputId="entity_type"
[contactTypeFormControl]="$any(form).controls['entity_type']"
[contactTypeOptions]="contactTypeOptions"
[contactTypeReadOnly]="true"
contactTypeStyleClass="readonly"
[maxFecResults]="10"
[maxFecfileResults]="10"
(fecfileContactSelect)="onContactLookupSelect($event)">
</app-contact-lookup>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@ <h3>Contributor</h3>
<div class="field">
<label for="entity_type">CONTRIBUTOR TYPE</label>
<app-contact-lookup
contactTypeInputId="entity_type"
[contactTypeFormControl]="$any(form).controls['entity_type']"
[contactTypeOptions]="contactTypeOptions"
[contactTypeReadOnly]="false"
[maxFecResults]="10"
[maxFecfileResults]="10"
(fecfileContactSelect)="onContactLookupSelect($event)">
</app-contact-lookup>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@ <h3>Contributor</h3>
<div class="field">
<label for="entity_type">CONTRIBUTOR TYPE</label>
<app-contact-lookup
contactTypeInputId="entity_type"
[contactTypeFormControl]="$any(form).controls['entity_type']"
[contactTypeOptions]="contactTypeOptions"
[contactTypeReadOnly]="false"
[maxFecResults]="10"
[maxFecfileResults]="10"
(fecfileContactSelect)="onContactLookupSelect($event)">
</app-contact-lookup>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ <h3>Contributor</h3>
<div class="field">
<label for="entity_type">CONTRIBUTOR TYPE</label>
<app-contact-lookup
contactTypeInputId="entity_type"
[contactTypeFormControl]="$any(form).controls['entity_type']"
[contactTypeOptions]="contactTypeOptions"
[contactTypeReadOnly]="true"
contactTypeStyleClass="readonly"
[maxFecResults]="10"
[maxFecfileResults]="10"
(fecfileContactSelect)="onContactLookupSelect($event)">
</app-contact-lookup>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ <h3>Contributor</h3>
<div class="col-6">
<div class="field">
<label for="entity_type">CONTRIBUTOR TYPE</label>
<p-dropdown
inputId="entity_type"
formControlName="entity_type"
[options]="contactTypeOptions"
optionLabel="name"
optionValue="code"
[readonly]="true"
styleClass="readonly"
></p-dropdown>
<app-contact-lookup
[contactTypeFormControl]="$any(form).controls['entity_type']"
[contactTypeOptions]="contactTypeOptions"
[contactTypeReadOnly]="true"
contactTypeStyleClass="readonly"
(fecfileContactSelect)="onContactLookupSelect($event)">
</app-contact-lookup>
</div>
</div>
</div>
Expand Down

0 comments on commit b794aea

Please sign in to comment.