Skip to content

Commit

Permalink
Check if default agg type is part of filtered list and if not, change…
Browse files Browse the repository at this point in the history
… to first agg type in list
  • Loading branch information
jen-huang committed Jul 5, 2018
1 parent 09d0b4c commit 360d2a2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ui/public/vis/editors/default/agg.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</span>

<!-- error -->
<span ng-if="!editorOpen && aggForm.$invalid" class="vis-editor-agg-header-description danger" title="{{aggForm.describeErrors()}}">
<span ng-if="!editorOpen && aggForm.$invalid && aggForm.softErrorCount()" class="vis-editor-agg-header-description danger" title="{{aggForm.describeErrors()}}">
{{ aggForm.describeErrors() }}
</span>

Expand Down
7 changes: 6 additions & 1 deletion src/ui/public/vis/editors/default/agg_params.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ uiModules

const aggTypeSubscription = aggTypeFilters
.filter$(aggTypes.byType[$scope.groupName], $scope.indexPattern, $scope.agg)
.subscribe(aggTypes => $scope.aggTypeOptions = aggTypes);
.subscribe(aggTypes => {
if(!aggTypes.includes($scope.agg.type) && aggTypes && aggTypes.length) {
$scope.agg.type = aggTypes[0];
}
$scope.aggTypeOptions = aggTypes;
});

$scope.$on('$destroy', () => {
aggTypeSubscription.unsubscribe();
Expand Down

0 comments on commit 360d2a2

Please sign in to comment.