[Vis: Default Editor] Fix issue for string control (#34151) (#34250)

* Display fied if it's enabled

* Reset model value

* Fix type

* Get rid of lodash dependancy
This commit is contained in:
Maryia Lapata 2019-04-01 12:45:15 +03:00 committed by GitHub
parent 48c1781af0
commit 52da31e55a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 2 deletions

View file

@ -17,10 +17,13 @@
* under the License.
*/
import { AggConfig } from '../vis/agg_config';
interface AggParam {
type: string;
name: string;
displayName?: string;
disabled?(agg: AggConfig): boolean;
}
export { AggParam };

View file

@ -23,6 +23,12 @@ import { EuiFieldText, EuiFormRow } from '@elastic/eui';
import { AggParamEditorProps } from '../../vis/editors/default';
function StringParamEditor({ agg, aggParam, value, setValue }: AggParamEditorProps<string>) {
if (aggParam.disabled && aggParam.disabled(agg)) {
// reset model value
setValue();
return null;
}
return (
<EuiFormRow
label={aggParam.displayName || aggParam.name}

View file

@ -31,7 +31,8 @@ uiModules
['onChange', { watchDepth: 'reference' }],
['setValidity', { watchDepth: 'reference' }],
'value',
'isInvalid'
'isInvalid',
'field'
]))
.directive('visAggParamEditor', function (config) {
return {
@ -58,6 +59,7 @@ uiModules
value="paramValue"
is-invalid="isInvalid"
set-validity="setValidity"
field="agg.params.field"
></vis-agg-param-react-wrapper>`;
}

View file

@ -29,6 +29,6 @@ export interface AggParamEditorProps<T> {
aggParam: AggParam;
value: T;
isInvalid: boolean;
setValue(value: T): void;
setValue(value?: T): void;
setValidity(isValid: boolean): void;
}