15067: Tag key/value suggestions show all available labels.
[arvados.git] / src / views-components / resource-properties-form / property-field-common.tsx
index 395be19670a5c7d51e5dcf5e89f85319ff536d00..a90ce923265b779758b64987c68dd3070009ff06 100644 (file)
@@ -3,10 +3,10 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import { connect } from 'react-redux';
-import { Vocabulary } from '~/models/vocabulary';
+import { WrappedFieldMetaProps, WrappedFieldInputProps, WrappedFieldProps } from 'redux-form';
+import { Vocabulary, PropFieldSuggestion } from '~/models/vocabulary';
 import { RootState } from '~/store/store';
-import { getVocabulary } from '~/store/vocabulary/vocabulary-selctors';
-import { WrappedFieldMetaProps, WrappedFieldInputProps } from 'redux-form';
+import { getVocabulary } from '~/store/vocabulary/vocabulary-selectors';
 
 export interface VocabularyProp {
     vocabulary: Vocabulary;
@@ -31,3 +31,15 @@ export const getErrorMsg = (meta: WrappedFieldMetaProps) =>
 export const handleBlur = ({ onBlur, value }: WrappedFieldInputProps) =>
     () =>
         onBlur(value);
+
+export const buildProps = ({ input, meta }: WrappedFieldProps) => {
+    return {
+        value: input.value,
+        onChange: input.onChange,
+        onBlur: handleBlur(input),
+        items: ITEMS_PLACEHOLDER,
+        renderSuggestion: (item:PropFieldSuggestion) => item.label,
+        error: hasError(meta),
+        helperText: getErrorMsg(meta),
+    };
+};