Skip to content

Commit

Permalink
Merge pull request #435 from spenceralger/fix/350
Browse files Browse the repository at this point in the history
Reset the aggParams on agg change
  • Loading branch information
w33ble committed Oct 2, 2014
2 parents 230e8a7 + b6da975 commit a20880c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/kibana/apps/visualize/editor/agg.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ define(function (require) {

var $aggParamEditors;
var $aggParamEditorsScope;
$scope.$watch('agg.type', function updateAggParamEditor() {
$scope.$watch('agg.type', function updateAggParamEditor(newType, oldType) {
if ($aggParamEditors) {
$aggParamEditors.remove();
$aggParamEditorsScope.$destroy();
Expand All @@ -59,7 +59,12 @@ define(function (require) {
var type = $scope.agg.type;

if (!agg) return;
agg.fillDefaults();

if (newType !== oldType) {
// don't reset on initial load, the
// saved params should persist
agg.resetParams();
}

if (!type) return;

Expand Down
9 changes: 9 additions & 0 deletions src/kibana/components/vis/_agg_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ define(function (require) {
});
};

/**
* Clear the parameters for this aggConfig
*
* @return {object} the new params object
*/
AggConfig.prototype.resetParams = function () {
return this.fillDefaults({});
};

AggConfig.prototype.write = function () {
return this.type.params.write(this);
};
Expand Down

0 comments on commit a20880c

Please sign in to comment.