Skip to content

Commit

Permalink
Can disable search actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ger-benjamin committed Mar 22, 2016
1 parent 484afcd commit bdaf0c3
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions contribs/gmf/src/directives/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ gmf.SearchController = function($scope, $compile, $timeout, gettextCatalog,

if (groupValues.length === 0) {
filters.push({
'title': undefined,
'filter': undefined
'title': '',
'filter': this.filterLayername_(null)
});
} else {
groupValues.forEach(function(layerName) {
Expand All @@ -281,14 +281,15 @@ gmf.SearchController = function($scope, $compile, $timeout, gettextCatalog,
'filter': this.filterLayername_(layerName)
});
}, this);
groupActions.forEach(function(action) {
filters.push({
'title': action,
'filter': this.filterAction_(action)
});
}, this);
}

groupActions.forEach(function(action) {
filters.push({
'title': action,
'filter': this.filterAction_(action)
});
}, this);

filters.forEach(function(filter) {
this.datasets.push(this.createDataset_({
bloodhoundOptions: datasource.bloodhoundOptions,
Expand Down Expand Up @@ -383,8 +384,8 @@ gmf.SearchController.prototype.createDataset_ = function(config, opt_filter) {

var html = '<p class="search-label">' + feature.get(config.labelKey) +
'</p>';
html += '<p class="search-group">' + feature.get('layer_name') +
'</p>';
html += '<p class="search-group">' + (feature.get('layer_name') ||
config.datasetTitle) + '</p>';
html = '<div class="search-datum">' + html + '</div>';
return compile(html)(scope);
}
Expand Down Expand Up @@ -426,7 +427,8 @@ gmf.SearchController.prototype.filterAction_ = function(action) {


/**
* @param {string} layerName The layerName to keep.
* @param {?string} layerName The layerName to keep. If null, keep all layers
* (In all cases, except actions layers).
* @return {(function(GeoJSONFeature): boolean)} A filter function based on a
* GeoJSONFeaturesCollection's array.
* @private
Expand All @@ -438,8 +440,15 @@ gmf.SearchController.prototype.filterLayername_ = function(layerName) {
* @return {boolean}
*/
function(feature) {
var properties = feature['properties'];
return properties['layer_name'] === layerName;
var featureLayerName = feature['properties']['layer_name'];
// Keep only layers with layer_name (don't keep action layers).
if (featureLayerName === undefined) {
return false;
}
if (layerName === null) {
return true;
}
return featureLayerName === layerName;
}
);
};
Expand Down

0 comments on commit bdaf0c3

Please sign in to comment.