Fix model name and set parameter watcher only for react component (#33399)
This commit is contained in:
parent
76eff0afab
commit
364325b1be
2 changed files with 12 additions and 6 deletions
|
@ -76,11 +76,13 @@ uiModules
|
|||
return true;
|
||||
};
|
||||
|
||||
$scope.$watch('agg.params[aggParam.name]', (value) => {
|
||||
// Whenever the value of the parameter changed (e.g. by a reset or actually by calling)
|
||||
// we store the new value in $scope.paramValue, which will be passed as a new value to the react component.
|
||||
$scope.paramValue = value;
|
||||
}, true);
|
||||
if (attr.editorComponent) {
|
||||
$scope.$watch('agg.params[aggParam.name]', (value) => {
|
||||
// Whenever the value of the parameter changed (e.g. by a reset or actually by calling)
|
||||
// we store the new value in $scope.paramValue, which will be passed as a new value to the react component.
|
||||
$scope.paramValue = value;
|
||||
}, true);
|
||||
}
|
||||
|
||||
$scope.onChange = (value) => {
|
||||
// This is obviously not a good code quality, but without using scope binding (which we can't see above)
|
||||
|
|
|
@ -209,7 +209,7 @@ uiModules
|
|||
// The form should interact with reactified components as well.
|
||||
// So we set the ng-model (using a random ng-model variable) to have the method to set dirty
|
||||
// inside the agg_param.js directive, which can get access to the ngModelController to manipulate it.
|
||||
attrs['ng-model'] = `_internalNgModelState${$scope.agg.id}${param.name}`;
|
||||
attrs['ng-model'] = normalizeModelName(`_internalNgModelState${$scope.agg.id}${param.name}`);
|
||||
}
|
||||
|
||||
return $('<vis-agg-param-editor>')
|
||||
|
@ -217,6 +217,10 @@ uiModules
|
|||
.append(param.editor)
|
||||
.get(0);
|
||||
}
|
||||
|
||||
function normalizeModelName(modelName = '') {
|
||||
return modelName.replace('-', '_');
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue