Skip to content

Commit

Permalink
[Closes #339] Filter State Data Set list by state id (#454)
Browse files Browse the repository at this point in the history
  • Loading branch information
francisli authored Oct 6, 2024
1 parent 9b29d49 commit 8a09b59
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ <h1 class="h2">Edit Agency</h1>
<shared-form *ngIf="id" type="agencies" [id]="id" (load)="onLoad($event)">
<ng-template let-record="record" let-error="error">
<div *ngIf="states.length > 0" class="mb-3">
<shared-select-field id="stateId" label="State" [source]="record" [target]="record" [error]="error">
<shared-select-field
id="stateId"
label="State"
[source]="record"
[target]="record"
[error]="error"
(valueChange)="onStateChange($event)">
<option *ngFor="let state of states" [value]="state.id">{{ state.name }}</option>
</shared-select-field>
</div>
Expand All @@ -33,7 +39,8 @@ <h1 class="h2">Edit Agency</h1>
[target]="record"
[error]="error"
objectNameProperty="displayVersion"
objectApiPath="nemsisStateDataSets"></shared-object-field>
objectApiPath="nemsisStateDataSets"
[objectApiSearchParams]="stateSearchParams"></shared-object-field>
</div>
<div class="mb-3">
<shared-text-field
Expand Down
12 changes: 12 additions & 0 deletions angular/projects/admin/src/app/agencies/edit-agency.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class EditAgencyComponent {
states: any = [];
canonicalAgencyId: string = '';
claimedAgencyId: string = '';
stateSearchParams = new HttpParams();

constructor(
private api: ApiService,
Expand All @@ -29,5 +30,16 @@ export class EditAgencyComponent {
onLoad(agency: any) {
this.canonicalAgencyId = agency.canonicalAgencyId;
this.claimedAgencyId = agency.claimedAgency?.id;
this.stateSearchParams = new HttpParams();
if (agency.stateId) {
this.stateSearchParams = this.stateSearchParams.set('stateId', agency.stateId);
}
}

onStateChange(stateId: string | undefined) {
this.stateSearchParams = new HttpParams();
if (stateId) {
this.stateSearchParams = this.stateSearchParams.set('stateId', stateId);
}
}
}

0 comments on commit 8a09b59

Please sign in to comment.