X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/e79b7364ea28b6f0719c9adf409ba1217b9ccac8..eb94bef4d2aebe2bf16093f776e1703d7db106fc:/src/components/text-field/text-field.tsx?ds=sidebyside

diff --git a/src/components/text-field/text-field.tsx b/src/components/text-field/text-field.tsx
index 4d8c012f..78e2c7fb 100644
--- a/src/components/text-field/text-field.tsx
+++ b/src/components/text-field/text-field.tsx
@@ -2,31 +2,58 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as React from 'react';
+import React from 'react';
 import { WrappedFieldProps } from 'redux-form';
-import { ArvadosTheme } from '~/common/custom-theme';
-import { TextField as MaterialTextField, StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core';
+import { ArvadosTheme } from 'common/custom-theme';
+import {
+    TextField as MaterialTextField,
+    StyleRulesCallback,
+    WithStyles,
+    withStyles,
+    PropTypes
+} from '@material-ui/core';
 import RichTextEditor from 'react-rte';
 
-type CssRules = 'textField';
+type CssRules = 'textField' | 'rte';
 
 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     textField: {
-        marginBottom: theme.spacing.unit * 3
+        marginBottom: theme.spacing.unit
     },
+    rte: {
+        fontFamily: 'Arial',
+        '& a': {
+            textDecoration: 'none',
+            color: theme.palette.primary.main,
+            '&:hover': {
+                cursor: 'pointer',
+                textDecoration: 'underline'
+            }
+        }
+    }
 });
 
-export const TextField = withStyles(styles)((props: WrappedFieldProps & WithStyles<CssRules> & { label?: string, autoFocus?: boolean, required?: boolean }) =>
+type TextFieldProps = WrappedFieldProps & WithStyles<CssRules>;
+
+export const TextField = withStyles(styles)((props: TextFieldProps & {
+    label?: string, autoFocus?: boolean, required?: boolean, select?: boolean, disabled?: boolean, children: React.ReactNode, margin?: PropTypes.Margin, placeholder?: string,
+    helperText?: string, type?: string,
+}) =>
     <MaterialTextField
-        helperText={props.meta.touched && props.meta.error}
+        helperText={(props.meta.touched && props.meta.error) || props.helperText}
         className={props.classes.textField}
         label={props.label}
-        disabled={props.meta.submitting}
+        disabled={props.disabled || props.meta.submitting}
         error={props.meta.touched && !!props.meta.error}
         autoComplete='off'
         autoFocus={props.autoFocus}
         fullWidth={true}
         required={props.required}
+        select={props.select}
+        children={props.children}
+        margin={props.margin}
+        placeholder={props.placeholder}
+        type={props.type}
         {...props.input}
     />);
 
@@ -35,7 +62,7 @@ interface RichEditorTextFieldData {
     label?: string;
 }
 
-type RichEditorTextFieldProps = RichEditorTextFieldData & WrappedFieldProps & WithStyles<CssRules>;
+type RichEditorTextFieldProps = RichEditorTextFieldData & TextFieldProps;
 
 export const RichEditorTextField = withStyles(styles)(
     class RichEditorTextField extends React.Component<RichEditorTextFieldProps> {
@@ -49,10 +76,28 @@ export const RichEditorTextField = withStyles(styles)(
         }
 
         render() {
-            return <RichTextEditor 
+            return <RichTextEditor
+                className={this.props.classes.rte}
                 value={this.state.value}
                 onChange={this.onChange}
                 placeholder={this.props.label} />;
         }
     }
-);
\ No newline at end of file
+);
+
+export const DateTextField = withStyles(styles)
+    ((props: TextFieldProps) =>
+        <MaterialTextField
+            type="date"
+            disabled={props.meta.submitting}
+            helperText={props.meta.error}
+            error={!!props.meta.error}
+            fullWidth={true}
+            InputLabelProps={{
+                shrink: true
+            }}
+            name={props.input.name}
+            onChange={props.input.onChange}
+            value={props.input.value}
+        />
+    );
