Fix issue with adding negating scripted filter
This commit is contained in:
parent
77078ec818
commit
bfc03ddd13
|
@ -111,6 +111,22 @@ describe('Filter Manager', function () {
|
|||
filterManager.add('_exists_', 'myField', '-', 'myIndex');
|
||||
checkAddFilters(0, null, 3);
|
||||
expect(appState.filters).to.have.length(2);
|
||||
|
||||
var scriptedField = {name: 'scriptedField', scripted: true, script: 1};
|
||||
filterManager.add(scriptedField, 1, '+', 'myIndex');
|
||||
checkAddFilters(1, [{
|
||||
meta: {index: 'myIndex', negate: false, field: 'scriptedField'},
|
||||
script: {
|
||||
script: '(' + scriptedField.script + ') == value',
|
||||
lang: scriptedField.lang,
|
||||
params: {value: 1}
|
||||
}
|
||||
}], 4);
|
||||
expect(appState.filters).to.have.length(3);
|
||||
|
||||
filterManager.add(scriptedField, 1, '-', 'myIndex');
|
||||
checkAddFilters(0, null, 5);
|
||||
expect(appState.filters).to.have.length(3);
|
||||
});
|
||||
|
||||
it('should enable matching filters being changed', function () {
|
||||
|
|
|
@ -26,6 +26,10 @@ define(function (require) {
|
|||
if (filter.query) {
|
||||
return filter.query.match[fieldName] && filter.query.match[fieldName].query === value;
|
||||
}
|
||||
|
||||
if (filter.script) {
|
||||
return filter.meta.field === fieldName && filter.script.params.value === value;
|
||||
}
|
||||
});
|
||||
|
||||
if (existing) {
|
||||
|
|
Loading…
Reference in a new issue