//
// SPDX-License-Identifier: AGPL-3.0
-import { ChangeEvent } from 'react';
import { connect } from 'react-redux';
-import { change, WrappedFieldMetaProps, WrappedFieldInputProps, WrappedFieldProps, reset } from 'redux-form';
-import { Vocabulary, PropFieldSuggestion } from '~/models/vocabulary';
-import { RootState } from '~/store/store';
-import { getVocabulary } from '~/store/vocabulary/vocabulary-selectors';
-import { PROPERTY_KEY_FIELD_ID } from './property-key-field';
+import { change, WrappedFieldMetaProps, WrappedFieldInputProps, WrappedFieldProps } from 'redux-form';
+import { Vocabulary, PropFieldSuggestion } from 'models/vocabulary';
+import { RootState } from 'store/store';
+import { getVocabulary } from 'store/vocabulary/vocabulary-selectors';
export interface VocabularyProp {
vocabulary: Vocabulary;
export interface ValidationProp {
skipValidation?: boolean;
+ clearPropertyKeyOnSelect?: boolean;
}
export const mapStateToProps = (state: RootState, ownProps: ValidationProp): VocabularyProp & ValidationProp => ({
dispatch(change(formName, fieldName, item.id));
}
};
-
-export const handleChange = (
- fieldName: string,
- formName: string,
- { onChange }: WrappedFieldInputProps,
- { dispatch }: WrappedFieldMetaProps) =>
- (value: ChangeEvent<HTMLInputElement>) => {
- if (fieldName === PROPERTY_KEY_FIELD_ID) {
- // Properties' values are dependant on the keys, if any value is
- // pre-existant, a change on the property key should mean that the
- // previous value is invalid.
- dispatch(reset(formName));
- }
- onChange(value);
- dispatch(change(formName, fieldName, value));
- };
\ No newline at end of file