mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
add negate to the fieldFilter
This commit is contained in:
parent
380dcd7f77
commit
40ab504cbd
3 changed files with 28 additions and 14 deletions
8
TODOS.md
8
TODOS.md
|
@ -4,10 +4,10 @@
|
|||
- **src/kibana/apps/dashboard/directives/grid.js**
|
||||
- change this from event based to calling a method on dashboardApp – [L68](https://github.com/elasticsearch/kibana4/blob/master/src/kibana/apps/dashboard/directives/grid.js#L68)
|
||||
- **src/kibana/apps/discover/controllers/discover.js**
|
||||
- Switch this to watching time.string when we implement it – [L150](https://github.com/elasticsearch/kibana4/blob/master/src/kibana/apps/discover/controllers/discover.js#L150)
|
||||
- On array fields, negating does not negate the combination, rather all terms – [L477](https://github.com/elasticsearch/kibana4/blob/master/src/kibana/apps/discover/controllers/discover.js#L477)
|
||||
- Move to utility class – [L548](https://github.com/elasticsearch/kibana4/blob/master/src/kibana/apps/discover/controllers/discover.js#L548)
|
||||
- Move to utility class – [L558](https://github.com/elasticsearch/kibana4/blob/master/src/kibana/apps/discover/controllers/discover.js#L558)
|
||||
- Switch this to watching time.string when we implement it – [L151](https://github.com/elasticsearch/kibana4/blob/master/src/kibana/apps/discover/controllers/discover.js#L151)
|
||||
- On array fields, negating does not negate the combination, rather all terms – [L480](https://github.com/elasticsearch/kibana4/blob/master/src/kibana/apps/discover/controllers/discover.js#L480)
|
||||
- Move to utility class – [L551](https://github.com/elasticsearch/kibana4/blob/master/src/kibana/apps/discover/controllers/discover.js#L551)
|
||||
- Move to utility class – [L561](https://github.com/elasticsearch/kibana4/blob/master/src/kibana/apps/discover/controllers/discover.js#L561)
|
||||
- **src/kibana/apps/settings/sections/indices/_create.js**
|
||||
- we should probably display a message of some kind – [L111](https://github.com/elasticsearch/kibana4/blob/master/src/kibana/apps/settings/sections/indices/_create.js#L111)
|
||||
- **src/kibana/apps/visualize/controllers/editor.js**
|
||||
|
|
|
@ -7,18 +7,28 @@ define(function (require) {
|
|||
require('modules')
|
||||
.get('kibana')
|
||||
.filter('fieldType', function () {
|
||||
return function (arr, type) {
|
||||
if (type === '*') return arr;
|
||||
return function (fields, types) {
|
||||
if (!_.isArray(types)) types = [types];
|
||||
if (_.contains(types, '*')) return fields;
|
||||
|
||||
if (_.isArray(type)) {
|
||||
if (_.contains(type, '*')) return arr;
|
||||
return _.filter(arr, function (field) {
|
||||
return _.contains(type, field.type);
|
||||
});
|
||||
}
|
||||
var filters = types.map(function (type) {
|
||||
var filter = {
|
||||
match: true,
|
||||
type: type
|
||||
};
|
||||
|
||||
return arr && arr.filter(function (field) {
|
||||
return (field.type === type);
|
||||
if (type.charAt(0) === '!') {
|
||||
filter.match = false;
|
||||
filter.type = type.substr(1);
|
||||
}
|
||||
return filter;
|
||||
});
|
||||
|
||||
return fields.filter(function (field) {
|
||||
for (var i = 0; i < filters.length; i++) {
|
||||
var filter = filters[i];
|
||||
if ((field.type === filter.type) === filter.match) return true;
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
@ -61,6 +61,10 @@ define(function (require) {
|
|||
expect(filter(types, '*').length).to.be(7);
|
||||
});
|
||||
|
||||
it('should allow negation', function () {
|
||||
var resultNames = _.pluck(filter(types, '!string'), 'name');
|
||||
expect(resultNames).to.eql(['n1', 'n2', 'i1', 'd1']);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue