generated from Tailormap/tailormap-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto-fill data for new planregistraties
- Loading branch information
1 parent
ee97e55
commit 76fbf27
Showing
13 changed files
with
158 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
projects/planmonitor-wonen/src/lib/api/planmonitor-wonen-api.service.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
projects/planmonitor-wonen/src/lib/models/autofill-data.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { WoonmilieuAbf13Enum } from './woonmilieu-abf13.enum'; | ||
|
||
export interface AutofillDataModel { | ||
woonmilieus: WoonmilieuAbf13Enum[]; | ||
gemeentes: string[]; | ||
provincies: string[]; | ||
regios: string[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export interface GemeenteModel { | ||
id: string; | ||
naam: string; | ||
provincie: string; | ||
geometry: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
projects/planmonitor-wonen/src/lib/services/autofill-data.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { BehaviorSubject, catchError, Observable, of, take } from 'rxjs'; | ||
import { GemeenteModel } from '../models/gemeente.model'; | ||
import { Inject, Injectable } from '@angular/core'; | ||
import { PLANMONITOR_WONEN_API_SERVICE } from '../api/planmonitor-wonen-api.service.injection-token'; | ||
import { PlanmonitorWonenApiServiceModel } from '../api/planmonitor-wonen-api.service.model'; | ||
import { AutofillDataModel } from '../models'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class AutofillDataService { | ||
|
||
private gemeentesSubject = new BehaviorSubject<GemeenteModel[]>([]); | ||
|
||
constructor( | ||
@Inject(PLANMONITOR_WONEN_API_SERVICE) private api: PlanmonitorWonenApiServiceModel, | ||
) { | ||
} | ||
|
||
public loadGemeentes(provincie?: string): void { | ||
this.api.getGemeentes$({ provincie }) | ||
.pipe(take(1), catchError(() => of([]))) | ||
.subscribe(gemeentes => { | ||
const newGemeenteNames = new Set(gemeentes.map(gemeente => gemeente.naam)); | ||
const current = this.gemeentesSubject.value; | ||
const filteredGemeentes = current.filter(gemeente => !newGemeenteNames.has(gemeente.naam)); | ||
this.gemeentesSubject.next([ ...gemeentes, ...filteredGemeentes ]); | ||
}); | ||
} | ||
|
||
public getGemeentes$() { | ||
return this.gemeentesSubject.asObservable(); | ||
} | ||
|
||
public loadAutofillData$(geometry: string): Observable<AutofillDataModel> { | ||
return this.api.autofillByGeometry$(geometry) | ||
.pipe(catchError(() => of({ | ||
gemeentes: [], | ||
regios: [], | ||
provincies: [], | ||
woonmilieus: [], | ||
}))); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters