Skip to content

Commit

Permalink
fix(ogcFilters): fix wfs datasource ogcFilters / clearTimeout for che…
Browse files Browse the repository at this point in the history
…ckbox filters (#849)

* feat(ogcfilter):  automatic assignation of selectorType

* fix(ogcFilters): various fix

* lint

* refactor(ogc-filter-selection): clear timeout for checkboxes apply filters

* fix(ogc): linked layers filter sync.

* lint

* wip

Co-authored-by: Pierre-Étienne Lord <pe_lord@yahoo.ca>
  • Loading branch information
PhilippeLafreniere18 and Pierre-Étienne Lord committed May 3, 2021
1 parent 166a895 commit 99f9d75
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -299,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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 99f9d75

Please sign in to comment.