From cc245661db617bb785899cd97dcf29af15a90e10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-=C3=89tienne=20Lord?= Date: Thu, 29 Apr 2021 13:58:20 -0400 Subject: [PATCH 1/7] feat(ogcfilter): automatic assignation of selectorType --- .../datasource/shared/datasources/wfs-datasource.ts | 10 ++++++++++ .../datasource/shared/datasources/wms-datasource.ts | 9 +++++++++ 2 files changed, 19 insertions(+) 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 9e9fa41315..2e7b269b4c 100644 --- a/packages/geo/src/lib/datasource/shared/datasources/wfs-datasource.ts +++ b/packages/geo/src/lib/datasource/shared/datasources/wfs-datasource.ts @@ -51,6 +51,16 @@ export class WFSDataSource extends DataSource { this.wfsService.getSourceFieldsFromWFS(this.options); } + if (ogcFilters.pushButtons){ + ogcFilters.pushButtons.selectorType = 'pushButton'; + } + if (ogcFilters.checkboxes){ + ogcFilters.checkboxes.selectorType = 'checkbox'; + } + if (ogcFilters.radioButtons){ + ogcFilters.radioButtons.selectorType = 'radioButton'; + } + 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 da901d1ec6..aeb2fa95e0 100644 --- a/packages/geo/src/lib/datasource/shared/datasources/wms-datasource.ts +++ b/packages/geo/src/lib/datasource/shared/datasources/wms-datasource.ts @@ -116,6 +116,15 @@ export class WMSDataSource extends DataSource { initOgcFilters.advancedOgcFilters = (initOgcFilters.pushButtons || initOgcFilters.checkboxes || initOgcFilters.radioButtons) ? false : true; + if (initOgcFilters.pushButtons){ + initOgcFilters.pushButtons.selectorType = 'pushButton'; + } + if (initOgcFilters.checkboxes){ + initOgcFilters.checkboxes.selectorType = 'checkbox'; + } + if (initOgcFilters.radioButtons){ + initOgcFilters.radioButtons.selectorType = 'radioButton'; + } } if ( From 92ffd32826d55276cf248dfed324ca2a2607ee32 Mon Sep 17 00:00:00 2001 From: Philippe Lafreniere Date: Fri, 30 Apr 2021 08:38:34 -0400 Subject: [PATCH 2/7] fix(ogcFilters): various fix --- .../ogc-filter-selection.component.html | 6 +-- .../ogc-filter-selection.component.ts | 35 ++------------- .../geo/src/lib/filter/shared/ogc-filter.ts | 43 ++++++++++++------- 3 files changed, 33 insertions(+), 51 deletions(-) diff --git a/packages/geo/src/lib/filter/ogc-filter-selection/ogc-filter-selection.component.html b/packages/geo/src/lib/filter/ogc-filter-selection/ogc-filter-selection.component.html index b5aa394419..f898d2842e 100644 --- a/packages/geo/src/lib/filter/ogc-filter-selection/ogc-filter-selection.component.html +++ b/packages/geo/src/lib/filter/ogc-filter-selection/ogc-filter-selection.component.html @@ -35,10 +35,10 @@

{{bundle.title}}

{{bundle.title}}

- {{ogcCheckbox.title}} + *ngFor="let ogcCheckbox of bundle.selectors; let i = index" [value]="ogcCheckbox">{{ogcCheckbox.title}}

@@ -68,7 +68,7 @@

{{bundle.title}}

{{ogcRadioButton.title}} + *ngFor="let ogcRadioButton of bundle.selectors" [value]="ogcRadioButton">{{ogcRadioButton.title}}

diff --git a/packages/geo/src/lib/filter/ogc-filter-selection/ogc-filter-selection.component.ts b/packages/geo/src/lib/filter/ogc-filter-selection/ogc-filter-selection.component.ts index daadb18836..aa2114ccd5 100644 --- a/packages/geo/src/lib/filter/ogc-filter-selection/ogc-filter-selection.component.ts +++ b/packages/geo/src/lib/filter/ogc-filter-selection/ogc-filter-selection.component.ts @@ -99,30 +99,6 @@ export class OgcFilterSelectionComponent implements OnInit { this.form.patchValue({ radioButtonsGroup: value }); } - getCurrentCheckboxesSelectors(bundle) { - const current = []; - if (bundle?.selectors.length) { - for (let i = 0; i < this.checkboxesIndex; i++) { - if (bundle.selectors[i]) { - current.push(bundle.selectors[i]); - } - } - } - return current; - } - - getCurrentRadioButtonsSelectors(bundle) { - const current = []; - if (bundle?.selectors.length) { - for (let i = 0; i < this.radioButtonsIndex; i++) { - if (bundle.selectors[i]) { - current.push(bundle.selectors[i]); - } - } - } - return current; - } - constructor( private ogcFilterService: OGCFilterService, private formBuilder: FormBuilder @@ -134,7 +110,6 @@ export class OgcFilterSelectionComponent implements OnInit { private buildForm() { this.form = this.formBuilder.group({ pushButtons: ['', [Validators.required]], - checkboxes: ['', [Validators.required]], radioButtons: ['', [Validators.required]], pushButtonsGroup: ['', [Validators.required]], checkboxesGroup: ['', [Validators.required]], @@ -213,13 +188,6 @@ export class OgcFilterSelectionComponent implements OnInit { .subscribe(() => { this.applyFilters(); }); - this.form - .get('checkboxes') - .valueChanges - .pipe(debounceTime(750)) - .subscribe(() => { - this.applyFilters(); - }); this.form .get('radioButtons') .valueChanges @@ -290,6 +258,9 @@ export class OgcFilterSelectionComponent implements OnInit { if (currentOgcSelection) { currentOgcSelection.enabled = !currentOgcSelection.enabled; } + setTimeout(() => { + this.applyFilters(); + }, 750); } private applyFilters() { diff --git a/packages/geo/src/lib/filter/shared/ogc-filter.ts b/packages/geo/src/lib/filter/shared/ogc-filter.ts index 7494c0556e..29d4f00172 100644 --- a/packages/geo/src/lib/filter/shared/ogc-filter.ts +++ b/packages/geo/src/lib/filter/shared/ogc-filter.ts @@ -714,24 +714,44 @@ export class OgcFilterWriter { if (!ogcFilters) { return; } - const filterQueryStringSelector = ''; + let conditions = []; + let filterQueryStringSelector = ''; let filterQueryStringAdvancedFilters = ''; if (ogcFilters.enabled && (ogcFilters.pushButtons || ogcFilters.checkboxes || ogcFilters.radioButtons)) { let selectors; if (ogcFilters.pushButtons) { selectors = ogcFilters.pushButtons; - this.formatGroupAndFilter(ogcFilters, selectors, filterQueryStringSelector, extent, proj); + const pushConditions = this.formatGroupAndFilter(ogcFilters, selectors); + for (const condition of pushConditions) { + conditions.push(condition); + } } if (ogcFilters.checkboxes) { selectors = ogcFilters.checkboxes; - this.formatGroupAndFilter(ogcFilters, selectors, filterQueryStringSelector, extent, proj); + const checkboxConditions = this.formatGroupAndFilter(ogcFilters, selectors); + for (const condition of checkboxConditions) { + conditions.push(condition); + } } if (ogcFilters.radioButtons) { selectors = ogcFilters.radioButtons; - this.formatGroupAndFilter(ogcFilters, selectors, filterQueryStringSelector, extent, proj); + const radioConditions = this.formatGroupAndFilter(ogcFilters, selectors); + for (const condition of radioConditions) { + conditions.push(condition); + } } - } + if (conditions.length >= 1) { + filterQueryStringSelector = this.buildFilter( + conditions.length === 1 + ? conditions[0] + : { logical: 'And', filters: conditions }, + extent, + proj, + ogcFilters.geometryName + ); + } + } if (ogcFilters.enabled && ogcFilters.filters) { ogcFilters.geometryName = ogcFilters.geometryName || fieldNameGeometry; const igoFilters = ogcFilters.filters; @@ -763,7 +783,7 @@ export class OgcFilterWriter { return filterQueryString; } - public formatGroupAndFilter(ogcFilters: OgcFiltersOptions, selectors, filterQueryStringSelector = '', extent, proj) { + public formatGroupAndFilter(ogcFilters: OgcFiltersOptions, selectors) { selectors = this.computeIgoSelector( selectors ); @@ -789,16 +809,6 @@ export class OgcFilterWriter { }); } }); - if (conditions.length >= 1) { - filterQueryStringSelector = this.buildFilter( - conditions.length === 1 - ? conditions[0] - : { logical: 'And', filters: conditions }, - extent, - proj, - ogcFilters.geometryName - ); - } if (selectors.selectorType === 'pushButton') { ogcFilters.pushButtons = selectors; @@ -807,6 +817,7 @@ export class OgcFilterWriter { } else if (selectors.selectorType === 'radioButton') { ogcFilters.radioButtons = selectors; } + return conditions; } public formatProcessedOgcFilter( From 86fd9e7177b38fd2d40c7ec79feddbb6f159d631 Mon Sep 17 00:00:00 2001 From: Philippe Lafreniere Date: Fri, 30 Apr 2021 09:04:54 -0400 Subject: [PATCH 3/7] lint --- packages/geo/src/lib/filter/shared/ogc-filter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/geo/src/lib/filter/shared/ogc-filter.ts b/packages/geo/src/lib/filter/shared/ogc-filter.ts index 29d4f00172..8c87c64bc1 100644 --- a/packages/geo/src/lib/filter/shared/ogc-filter.ts +++ b/packages/geo/src/lib/filter/shared/ogc-filter.ts @@ -714,7 +714,7 @@ export class OgcFilterWriter { if (!ogcFilters) { return; } - let conditions = []; + const conditions = []; let filterQueryStringSelector = ''; let filterQueryStringAdvancedFilters = ''; if (ogcFilters.enabled && (ogcFilters.pushButtons || ogcFilters.checkboxes || ogcFilters.radioButtons)) { From e6f491474d3829e45b17045f146edfd4b7e7d025 Mon Sep 17 00:00:00 2001 From: Philippe Lafreniere Date: Fri, 30 Apr 2021 15:13:20 -0400 Subject: [PATCH 4/7] refactor(ogc-filter-selection): clear timeout for checkboxes apply filters --- .../ogc-filter-selection/ogc-filter-selection.component.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/geo/src/lib/filter/ogc-filter-selection/ogc-filter-selection.component.ts b/packages/geo/src/lib/filter/ogc-filter-selection/ogc-filter-selection.component.ts index aa2114ccd5..c6b22191ff 100644 --- a/packages/geo/src/lib/filter/ogc-filter-selection/ogc-filter-selection.component.ts +++ b/packages/geo/src/lib/filter/ogc-filter-selection/ogc-filter-selection.component.ts @@ -55,6 +55,8 @@ export class OgcFilterSelectionComponent implements OnInit { private ogcFilterWriter: OgcFilterWriter; public color = 'primary'; + public applyFiltersTimeout; + get ogcFiltersSelectors() { const ogcSelector = []; if (this.datasource?.options?.ogcFilters?.pushButtons) { @@ -255,10 +257,11 @@ export class OgcFilterSelectionComponent implements OnInit { } onSelectionChange(currentOgcSelection?) { + clearTimeout(this.applyFiltersTimeout); if (currentOgcSelection) { currentOgcSelection.enabled = !currentOgcSelection.enabled; } - setTimeout(() => { + this.applyFiltersTimeout = setTimeout(() => { this.applyFilters(); }, 750); } From 656280efa3780939f3aaa31fc6a724349af2e86d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-=C3=89tienne=20Lord?= Date: Fri, 30 Apr 2021 15:43:32 -0400 Subject: [PATCH 5/7] fix(ogc): linked layers filter sync. --- .../src/lib/datasource/shared/datasources/wfs-datasource.ts | 6 +++--- .../ogc-filter-selection/ogc-filter-selection.component.ts | 1 + .../ogc-filterable-form/ogc-filterable-form.component.ts | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) 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 2e7b269b4c..260fa37187 100644 --- a/packages/geo/src/lib/datasource/shared/datasources/wfs-datasource.ts +++ b/packages/geo/src/lib/datasource/shared/datasources/wfs-datasource.ts @@ -51,13 +51,13 @@ export class WFSDataSource extends DataSource { this.wfsService.getSourceFieldsFromWFS(this.options); } - if (ogcFilters.pushButtons){ + if (ogcFilters?.pushButtons){ ogcFilters.pushButtons.selectorType = 'pushButton'; } - if (ogcFilters.checkboxes){ + if (ogcFilters?.checkboxes){ ogcFilters.checkboxes.selectorType = 'checkbox'; } - if (ogcFilters.radioButtons){ + if (ogcFilters?.radioButtons){ ogcFilters.radioButtons.selectorType = 'radioButton'; } diff --git a/packages/geo/src/lib/filter/ogc-filter-selection/ogc-filter-selection.component.ts b/packages/geo/src/lib/filter/ogc-filter-selection/ogc-filter-selection.component.ts index c6b22191ff..1868af7702 100644 --- a/packages/geo/src/lib/filter/ogc-filter-selection/ogc-filter-selection.component.ts +++ b/packages/geo/src/lib/filter/ogc-filter-selection/ogc-filter-selection.component.ts @@ -302,6 +302,7 @@ export class OgcFilterSelectionComponent implements OnInit { // TODO: Check how to prevent wfs to refresh when filter icon is pushed... this.datasource.ol.refresh(); } + this.datasource.setOgcFilters(this.datasource.options.ogcFilters,true); } isMoreResults(bundle, type) { diff --git a/packages/geo/src/lib/filter/ogc-filterable-form/ogc-filterable-form.component.ts b/packages/geo/src/lib/filter/ogc-filterable-form/ogc-filterable-form.component.ts index bd767985db..d284e79de8 100644 --- a/packages/geo/src/lib/filter/ogc-filterable-form/ogc-filterable-form.component.ts +++ b/packages/geo/src/lib/filter/ogc-filterable-form/ogc-filterable-form.component.ts @@ -26,7 +26,8 @@ export class OgcFilterableFormComponent { } get currentFilter(): any { - return this.datasource.options.ogcFilters.interfaceOgcFilters[0]; + return this.datasource.options.ogcFilters.interfaceOgcFilters ? + this.datasource.options.ogcFilters.interfaceOgcFilters[0]: undefined } public color = 'primary'; From c332bcfd81da54fea3ef2a4df8bbc12c70e820d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-=C3=89tienne=20Lord?= Date: Fri, 30 Apr 2021 15:52:58 -0400 Subject: [PATCH 6/7] lint --- package.json | 1 + .../ogc-filter-selection/ogc-filter-selection.component.ts | 2 +- .../filter/ogc-filterable-form/ogc-filterable-form.component.ts | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7ff6dcbce5..dd32839fac 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "build.integration": "ng build integration --prod && gulp integration", "build.demo": "ng build demo --configuration=production", "build.doc": "compodoc -p tsconfig.json --disablePrivate --disableProtected --disableInternal --disableLifeCycleHooks --theme material", + "copy": "copy-newer --cwd dist ** \"..\\igo2\\node_modules\\@igo2\"", "doc": "npm run build.doc && compodoc -s --port 4220", "pretest": "ng lint", "test": "ng test --watch=false --browsers=ChromeHeadless", diff --git a/packages/geo/src/lib/filter/ogc-filter-selection/ogc-filter-selection.component.ts b/packages/geo/src/lib/filter/ogc-filter-selection/ogc-filter-selection.component.ts index 1868af7702..0a3167a0c5 100644 --- a/packages/geo/src/lib/filter/ogc-filter-selection/ogc-filter-selection.component.ts +++ b/packages/geo/src/lib/filter/ogc-filter-selection/ogc-filter-selection.component.ts @@ -302,7 +302,7 @@ export class OgcFilterSelectionComponent implements OnInit { // TODO: Check how to prevent wfs to refresh when filter icon is pushed... this.datasource.ol.refresh(); } - this.datasource.setOgcFilters(this.datasource.options.ogcFilters,true); + this.datasource.setOgcFilters(this.datasource.options.ogcFilters, true); } isMoreResults(bundle, type) { diff --git a/packages/geo/src/lib/filter/ogc-filterable-form/ogc-filterable-form.component.ts b/packages/geo/src/lib/filter/ogc-filterable-form/ogc-filterable-form.component.ts index d284e79de8..ca4d2d9fa7 100644 --- a/packages/geo/src/lib/filter/ogc-filterable-form/ogc-filterable-form.component.ts +++ b/packages/geo/src/lib/filter/ogc-filterable-form/ogc-filterable-form.component.ts @@ -27,7 +27,7 @@ export class OgcFilterableFormComponent { get currentFilter(): any { return this.datasource.options.ogcFilters.interfaceOgcFilters ? - this.datasource.options.ogcFilters.interfaceOgcFilters[0]: undefined + this.datasource.options.ogcFilters.interfaceOgcFilters[0] : undefined; } public color = 'primary'; From 26bd8a387545f9de108a4f4808773c0b1b0c85eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-=C3=89tienne=20Lord?= Date: Mon, 3 May 2021 10:04:16 -0400 Subject: [PATCH 7/7] wip --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index dd32839fac..7ff6dcbce5 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,6 @@ "build.integration": "ng build integration --prod && gulp integration", "build.demo": "ng build demo --configuration=production", "build.doc": "compodoc -p tsconfig.json --disablePrivate --disableProtected --disableInternal --disableLifeCycleHooks --theme material", - "copy": "copy-newer --cwd dist ** \"..\\igo2\\node_modules\\@igo2\"", "doc": "npm run build.doc && compodoc -s --port 4220", "pretest": "ng lint", "test": "ng test --watch=false --browsers=ChromeHeadless",