Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(layer-list)Allow search with layer keyword (capabilitie or context) #250

Merged
merged 2 commits into from
Dec 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions projects/geo/src/lib/layer/layer-list/layer-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,19 @@ export class LayerListComponent implements AfterViewInit {
});

localLayers.forEach(layer => {
if (this.layerListService.getKeyword()) {
const localKeyword = this.layerListService.getKeyword().normalize('NFD').replace(/[\u0300-\u036f]/g, '');
const localLayerKeywords = [];
if (layer.options && layer.options['metadata'] && layer.options['metadata'].keywordList ) {
layer.options['metadata'].keywordList.forEach(kw => {
localLayerKeywords.push(kw.normalize('NFD').replace(/[\u0300-\u036f]/g, ''));
});
}
if (this.keyword) {
const localKeyword = this.keyword.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
const localLayerTitle = layer.title.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
if (
!new RegExp(localKeyword, 'gi').test(localLayerTitle) &&
!(this.layerListService.getKeyword().toLowerCase() ===
layer.dataSource.options.type.toString().toLowerCase()) ) {
!(this.keyword.toLowerCase() === layer.dataSource.options.type.toString().toLowerCase()) &&
localLayerKeywords.filter(kw => new RegExp(localKeyword, 'gi').test(kw)).length === 0) {
const index = layerIDToKeep.indexOf(layer.id);
if (index > -1) {
layerIDToKeep.splice(index, 1);
Expand Down