Skip to content

Commit

Permalink
refactor(filters): Move type to types folder
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipLeitner authored and jmacura committed Oct 3, 2024
1 parent d1d4d1b commit 9c86ba2
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
ComparisonOperatorType,
FilterType,
LogicalOperatorType,
} from '../filter.type';
} from 'hslayers-ng/types';
import {HsFiltersService} from '../filters.service';
import {NgbDropdownModule} from '@ng-bootstrap/ng-bootstrap';
import {TranslateCustomPipe} from 'hslayers-ng/services/language';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
import {Vector as VectorSource} from 'ol/source';
import {WfsFeatureAttribute} from 'hslayers-ng/types';

import {Filter} from '../filter.type';
import {Filter} from 'hslayers-ng/types';
import {FilterRangeInputComponent} from '../filter-range-input/filter-range-input.component';
import {HsFiltersService} from '../filters.service';
import {HsLayerUtilsService} from 'hslayers-ng/services/utils';
Expand Down
2 changes: 1 addition & 1 deletion projects/hslayers/common/filters/filter.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {CommonModule} from '@angular/common';
import {Component, Input, inject} from '@angular/core';
import {Filter} from './filter.type';
import {Filter} from 'hslayers-ng/types';
import {HsAddFilterButtonComponent} from './add-filter-button/add-filter-button.component';
import {HsComparisonFilterComponent} from './comparison-filter/comparison-filter.component';
import {HsFiltersService} from './filters.service';
Expand Down
2 changes: 1 addition & 1 deletion projects/hslayers/common/filters/filters.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Component, Input, inject, viewChild} from '@angular/core';

import {FilterType} from './filter.type';
import {FilterType} from 'hslayers-ng/types';
import {HsAddFilterButtonComponent} from './add-filter-button/add-filter-button.component';
import {HsComparisonFilterComponent} from './comparison-filter/comparison-filter.component';
import {HsFilterComponent} from './filter.component';
Expand Down
2 changes: 1 addition & 1 deletion projects/hslayers/common/filters/filters.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {HsToastService} from 'hslayers-ng/common/toast';
import {HsUtilsService} from 'hslayers-ng/services/utils';
import {getName, getWfsUrl} from 'hslayers-ng/common/extensions';

import {Filter, FilterType, LogicalOperatorType} from './filter.type';
import {Filter, FilterType, LogicalOperatorType} from 'hslayers-ng/types';

@Injectable({
providedIn: 'root',
Expand Down
13 changes: 12 additions & 1 deletion projects/hslayers/test/common/filters/comparison-filter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import VectorLayer from 'ol/layer/Vector';
import VectorSource from 'ol/source/Vector';
import {Feature} from 'ol';
import {Filter} from 'hslayers-ng/types';
import {
HsComparisonFilterComponent,
HsFiltersService,
Expand Down Expand Up @@ -64,6 +65,12 @@ class MockHsFiltersService {
return a - b;
});
}

removeFilter(parent: Filter, filter: Filter): boolean {
const index = parent.findIndex((item) => item === filter);
parent.splice(index, 1);
return true;
}
}

class MockHsLayerUtilsService {
Expand Down Expand Up @@ -154,7 +161,11 @@ describe('HsComparisonFilterComponent', () => {
}));

it('should remove filter when remove() is called', () => {
const parentMock = ['&&', component.filter, ['==', 'attr2', 'value2']];
const parentMock = [
'&&',
component.filter,
['==', 'attr2', 'value2'],
] as Filter;
component.parent = parentMock;
spyOn(component, 'emitChange');
component.remove();
Expand Down
2 changes: 2 additions & 0 deletions projects/hslayers/types/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,5 @@ export * from './query/widget-item.type';

export * from './extensions/layer-extensions.type';
export * from './wfs-filter/wfs-attributes.type';

export * from './filters/filter-types';

0 comments on commit 9c86ba2

Please sign in to comment.