From 2a11af2df2878d7e452e19ff77d2adc0dd1e0d9c Mon Sep 17 00:00:00 2001 From: Philippe Lafreniere Date: Mon, 25 Apr 2022 10:29:03 -0400 Subject: [PATCH 01/12] feat(ogc-filter/dom): allow domain of values to fill ogc-filter select / add autocomplete ogc-filter form --- packages/common/src/lib/dom/dom.interfaces.ts | 10 + packages/common/src/lib/dom/dom.module.ts | 17 ++ packages/common/src/lib/dom/dom.service.ts | 32 +++ packages/common/src/lib/dom/index.ts | 2 + packages/common/src/public_api.ts | 2 + .../shared/datasources/wfs-datasource.ts | 3 + .../shared/datasources/wms-datasource.ts | 5 +- packages/geo/src/lib/filter/filter.module.ts | 4 +- .../ogc-filter-button.component.html | 6 +- .../ogc-filter-button.component.ts | 18 +- .../ogc-filter-selection.component.html | 46 +++- .../ogc-filter-selection.component.scss | 1 + .../ogc-filter-selection.component.ts | 250 ++++++++++++++++-- .../ogc-filterable-item.component.ts | 3 +- .../shared/filterable-datasource.pipe.ts | 3 +- .../lib/filter/shared/ogc-filter.interface.ts | 22 +- .../geo/src/lib/filter/shared/ogc-filter.ts | 16 +- .../lib/map/map-tools/map-tools.component.ts | 2 +- 18 files changed, 394 insertions(+), 48 deletions(-) create mode 100644 packages/common/src/lib/dom/dom.interfaces.ts create mode 100644 packages/common/src/lib/dom/dom.module.ts create mode 100644 packages/common/src/lib/dom/dom.service.ts create mode 100644 packages/common/src/lib/dom/index.ts diff --git a/packages/common/src/lib/dom/dom.interfaces.ts b/packages/common/src/lib/dom/dom.interfaces.ts new file mode 100644 index 0000000000..a2a3711e44 --- /dev/null +++ b/packages/common/src/lib/dom/dom.interfaces.ts @@ -0,0 +1,10 @@ +export interface DOMOptions { + name: string; + url?: string; + value?: DOMValue[]; +} + +export interface DOMValue { + id: number; + value: string; +} diff --git a/packages/common/src/lib/dom/dom.module.ts b/packages/common/src/lib/dom/dom.module.ts new file mode 100644 index 0000000000..458e3c018a --- /dev/null +++ b/packages/common/src/lib/dom/dom.module.ts @@ -0,0 +1,17 @@ +import { ModuleWithProviders, NgModule } from '@angular/core'; + +import { DOMService } from './dom.service'; + +@NgModule({ + providers: [DOMService] +}) +export class IgoDOMModule { + static forRoot(): ModuleWithProviders { + return { + ngModule: IgoDOMModule, + providers: [ + DOMService + ] + }; + } +} diff --git a/packages/common/src/lib/dom/dom.service.ts b/packages/common/src/lib/dom/dom.service.ts new file mode 100644 index 0000000000..0ff153347b --- /dev/null +++ b/packages/common/src/lib/dom/dom.service.ts @@ -0,0 +1,32 @@ +import { HttpClient, HttpErrorResponse } from '@angular/common/http'; +import { catchError, map } from 'rxjs/operators'; +import { throwError } from 'rxjs'; + +import { DOMOptions, DOMValue } from './dom.interfaces'; +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class DOMService { + + constructor(private http: HttpClient) {} + + async getDom(dom: DOMOptions): Promise { + const url = dom.url; + let result: DOMValue[]; + + await this.http.get(url).pipe( + map(response => { + result = response; + return response; + }), + catchError((err: HttpErrorResponse) => { + return throwError(err); + }) + ).toPromise(); + + return result; + } + +} diff --git a/packages/common/src/lib/dom/index.ts b/packages/common/src/lib/dom/index.ts new file mode 100644 index 0000000000..2387dbb5cb --- /dev/null +++ b/packages/common/src/lib/dom/index.ts @@ -0,0 +1,2 @@ +export * from './dom.service'; +export * from './dom.interfaces'; diff --git a/packages/common/src/public_api.ts b/packages/common/src/public_api.ts index 88856f2605..3fbc025511 100644 --- a/packages/common/src/public_api.ts +++ b/packages/common/src/public_api.ts @@ -12,6 +12,7 @@ export * from './lib/collapsible/collapsible.module'; export * from './lib/confirm-dialog/confirm-dialog.module'; export * from './lib/context-menu/context-menu.module'; export * from './lib/custom-html/custom-html.module'; +export * from './lib/dom/dom.module'; export * from './lib/drag-drop/drag-drop.module'; export * from './lib/dynamic-component/dynamic-component.module'; export * from './lib/dynamic-component/dynamic-outlet/dynamic-outlet.module'; @@ -53,6 +54,7 @@ export * from './lib/confirm-dialog'; export * from './lib/context-menu'; export * from './lib/custom-html'; export * from './lib/drag-drop'; +export * from './lib/dom'; export * from './lib/dynamic-component'; export * from './lib/form'; export * from './lib/home-button'; diff --git a/packages/geo/src/lib/datasource/shared/datasources/wfs-datasource.ts b/packages/geo/src/lib/datasource/shared/datasources/wfs-datasource.ts index 744c4f7bc9..dc25fa5437 100644 --- a/packages/geo/src/lib/datasource/shared/datasources/wfs-datasource.ts +++ b/packages/geo/src/lib/datasource/shared/datasources/wfs-datasource.ts @@ -64,6 +64,9 @@ export class WFSDataSource extends DataSource { if (ogcFilters?.select){ ogcFilters.select.selectorType = 'select'; } + if (ogcFilters?.autocomplete){ + ogcFilters.autocomplete.selectorType = 'autocomplete'; + } this.setOgcFilters((this.options as OgcFilterableDataSourceOptions).ogcFilters, true); } diff --git a/packages/geo/src/lib/datasource/shared/datasources/wms-datasource.ts b/packages/geo/src/lib/datasource/shared/datasources/wms-datasource.ts index 6234954b82..64c13d967c 100644 --- a/packages/geo/src/lib/datasource/shared/datasources/wms-datasource.ts +++ b/packages/geo/src/lib/datasource/shared/datasources/wms-datasource.ts @@ -114,7 +114,7 @@ export class WMSDataSource extends DataSource { ); } else { initOgcFilters.advancedOgcFilters = (initOgcFilters.pushButtons || initOgcFilters.checkboxes - || initOgcFilters.radioButtons || initOgcFilters.select) + || initOgcFilters.radioButtons || initOgcFilters.select || initOgcFilters.autocomplete) ? false : true; if (initOgcFilters.advancedOgcFilters && initOgcFilters.filters) { @@ -135,6 +135,9 @@ export class WMSDataSource extends DataSource { if (initOgcFilters.select){ initOgcFilters.select.selectorType = 'select'; } + if (initOgcFilters.autocomplete){ + initOgcFilters.autocomplete.selectorType = 'autocomplete'; + } } if ( diff --git a/packages/geo/src/lib/filter/filter.module.ts b/packages/geo/src/lib/filter/filter.module.ts index a25a6c5c36..1f4fc8b14e 100644 --- a/packages/geo/src/lib/filter/filter.module.ts +++ b/packages/geo/src/lib/filter/filter.module.ts @@ -32,7 +32,8 @@ import { IgoCollapsibleModule, IgoListModule, IgoKeyValueModule, - IgoEntityModule + IgoEntityModule, + IgoDOMModule } from '@igo2/common'; import { IgoGeometryModule } from './../geometry/geometry.module'; @@ -94,6 +95,7 @@ import { OgcFilterTimeSliderComponent } from './ogc-filter-time/ogc-filter-time- IgoCollapsibleModule, IgoListModule, IgoEntityModule, + IgoDOMModule, IgoKeyValueModule, IgoGeometryModule, MatBadgeModule diff --git a/packages/geo/src/lib/filter/ogc-filter-button/ogc-filter-button.component.html b/packages/geo/src/lib/filter/ogc-filter-button/ogc-filter-button.component.html index a979005920..348f4044a3 100644 --- a/packages/geo/src/lib/filter/ogc-filter-button/ogc-filter-button.component.html +++ b/packages/geo/src/lib/filter/ogc-filter-button/ogc-filter-button.component.html @@ -1,6 +1,7 @@