Don't prevent filterable rows from being filterable (#11628)

* Don't prevent filterable rows just because they don't have a field

* Don't allow filtering on unfilterable fields

* Move isFilterable to aggConfig
This commit is contained in:
Lukas Olson 2017-05-09 10:09:34 -07:00 committed by GitHub
parent d5ee251dbd
commit 9509d9e89b
2 changed files with 8 additions and 4 deletions

View file

@ -40,10 +40,10 @@ module.directive('kbnRows', function ($compile, $rootScope, getAppState, Private
let $cellContent;
if (contents instanceof AggConfigResult) {
const field = contents.aggConfig.getField();
const isCellContentFilterable =
contents.type === 'bucket'
&& contents.aggConfig.getField()
&& contents.aggConfig.getField().filterable;
contents.aggConfig.isFilterable()
&& (!field || field.filterable);
if (isCellContentFilterable) {
$cell = createFilterableCell(contents);

View file

@ -163,8 +163,12 @@ export function VisAggConfigProvider(Private) {
return this.type.params.write(this);
};
AggConfig.prototype.isFilterable = function () {
return _.isFunction(this.type.createFilter);
};
AggConfig.prototype.createFilter = function (key) {
if (!_.isFunction(this.type.createFilter)) {
if (!this.isFilterable()) {
throw new TypeError('The "' + this.type.title + '" aggregation does not support filtering.');
}