Skip to content

Commit

Permalink
Handle booleans in filter editor (elastic#13406)
Browse files Browse the repository at this point in the history
* Handle booleans in filter editor

* Use select instead of checkbox
  • Loading branch information
lukasolson committed Aug 16, 2017
1 parent b677bea commit 0e5b457
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ui/public/directives/focus_on.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
}
}));
2 changes: 2 additions & 0 deletions src/ui/public/filter_editor/lib/filter_operators.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,13 @@
ng-model="value"
ng-change="onChange({ value: value })"
/>
<div ng-switch-when="boolean">
<select
class="kuiSelect"
ng-model="value"
ng-options="option for option in boolOptions"
ng-change="onChange({ value: value })"
ng-init="setDefaultBool()"
></select>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}
};
}
};
});

0 comments on commit 0e5b457

Please sign in to comment.