From c4c6ea1565274b5a0e616077b1084c456974e4e6 Mon Sep 17 00:00:00 2001 From: Lukas Olson Date: Wed, 16 Aug 2017 06:02:42 -0700 Subject: [PATCH] Handle booleans in filter editor (#13406) * Handle booleans in filter editor * Use select instead of checkbox --- src/ui/public/directives/focus_on.js | 6 +++++- src/ui/public/filter_editor/lib/filter_operators.js | 2 ++ .../params_editor/filter_params_input_type.html | 9 +++++++++ .../params_editor/filter_params_input_type.js | 11 +++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/ui/public/directives/focus_on.js b/src/ui/public/directives/focus_on.js index 024644a3e5977..4a7bc67bd272e 100644 --- a/src/ui/public/directives/focus_on.js +++ b/src/ui/public/directives/focus_on.js @@ -5,7 +5,11 @@ module.directive('focusOn', ($timeout) => ({ restrict: 'A', link: function (scope, elem, attrs) { scope.$on(attrs.focusOn, () => { - $timeout(() => elem.find('input').addBack('input').focus()); + $timeout(() => { + return elem.find('input,select') + .addBack('input,select') + .focus(); + }); }); } })); diff --git a/src/ui/public/filter_editor/lib/filter_operators.js b/src/ui/public/filter_editor/lib/filter_operators.js index fe14bbe9c4e3f..967571fb93093 100644 --- a/src/ui/public/filter_editor/lib/filter_operators.js +++ b/src/ui/public/filter_editor/lib/filter_operators.js @@ -15,11 +15,13 @@ export const FILTER_OPERATORS = [ name: 'is one of', type: 'phrases', negate: false, + fieldTypes: ['string', 'number', 'date', 'ip', 'geo_point', 'geo_shape'] }, { name: 'is not one of', type: 'phrases', negate: true, + fieldTypes: ['string', 'number', 'date', 'ip', 'geo_point', 'geo_shape'] }, { name: 'is between', diff --git a/src/ui/public/filter_editor/params_editor/filter_params_input_type.html b/src/ui/public/filter_editor/params_editor/filter_params_input_type.html index 56ffa8068d0d0..ea2d3cde615ce 100644 --- a/src/ui/public/filter_editor/params_editor/filter_params_input_type.html +++ b/src/ui/public/filter_editor/params_editor/filter_params_input_type.html @@ -37,4 +37,13 @@ ng-model="value" ng-change="onChange({ value: value })" /> +
+ +
diff --git a/src/ui/public/filter_editor/params_editor/filter_params_input_type.js b/src/ui/public/filter_editor/params_editor/filter_params_input_type.js index 5e55b76d7c8d8..dec02ac08af9e 100644 --- a/src/ui/public/filter_editor/params_editor/filter_params_input_type.js +++ b/src/ui/public/filter_editor/params_editor/filter_params_input_type.js @@ -13,6 +13,17 @@ module.directive('filterParamsInputType', function () { placeholder: '@', value: '=', onChange: '&' + }, + link: function (scope) { + scope.boolOptions = [true, false]; + scope.setDefaultBool = () => { + if (scope.value == null) { + scope.value = scope.boolOptions[0]; + scope.onChange({ + value: scope.value + }); + } + }; } }; });