diff --git a/src/os/filter/basefiltermanager.js b/src/os/filter/basefiltermanager.js index 6b8f3148f..16d2eafeb 100644 --- a/src/os/filter/basefiltermanager.js +++ b/src/os/filter/basefiltermanager.js @@ -312,6 +312,23 @@ os.filter.BaseFilterManager.prototype.hasEnabledFilters = function(opt_type) { }; +/** + * Determine the number of enabled filters + * @param {string=} opt_type + * @return {number} The number of enabled filters + */ +os.filter.BaseFilterManager.prototype.getNumEnabledFilters = function(opt_type) { + var numEnabledFilters = 0; + var filters = this.getFilters(opt_type) || []; + for (var i = 0; i < filters.length; i++) { + if (this.isEnabled(filters[i], opt_type)) { + numEnabledFilters += 1; + } + } + return numEnabledFilters; +}; + + /** * Checks whether the filter is active against the opt_type layer. * @param {os.filter.FilterEntry} filter @@ -319,7 +336,14 @@ os.filter.BaseFilterManager.prototype.hasEnabledFilters = function(opt_type) { * @return {boolean} */ os.filter.BaseFilterManager.prototype.isEnabled = function(filter, opt_type) { - return filter.isEnabled(); + var qm = os.ui.queryManager; + + if (filter) { + var results = qm.getEntries(opt_type, null, filter.getId()); + return !!results && !!results.length; + } + + return false; }; diff --git a/src/os/ui/query/areafilteradd.js b/src/os/ui/query/areafilteradd.js index e801c7a72..8f3f30f0f 100644 --- a/src/os/ui/query/areafilteradd.js +++ b/src/os/ui/query/areafilteradd.js @@ -25,7 +25,10 @@ os.ui.query.areaFilterAddDirective = function() { return { restrict: 'E', replace: true, - scope: {}, + scope: { + 'hideArea': '=?', + 'hideFilter': '=?' + }, templateUrl: os.ROOT + 'views/query/areafilteradd.html', controller: os.ui.query.AreaFilterAddCtrl, controllerAs: 'afa' @@ -547,3 +550,45 @@ os.ui.query.AreaFilterAddCtrl.prototype.onAreasSelected_ = function(features) { this.objectAreas_ = features; this.onAreasUpdate_(); }; + + +/** + * Launch the area/filter adder. + * @param {string} label + * @param {boolean=} opt_hideArea + * @param {boolean=} opt_hideFilter + */ +os.ui.query.AreaFilterAddCtrl.launch = function(label, opt_hideArea, opt_hideFilter) { + var id = 'areafilteradd'; + if (os.ui.window.exists(id)) { + os.ui.window.bringToFront(id); + return; + } + + var options = { + 'id': id, + 'x': 300, + 'y': 'center', + 'label': label, + 'show-close': true, + 'no-scroll': false, + 'width': 400, + 'min-width': 300, + 'max-width': 1000, + 'height': 600, + 'min-height': 300, + 'max-height': 1000 + }; + + var template = '