BasicInfoForm.tsx 3.37 KB
Newer Older
1
import * as React from 'react';
Valeriy Panov's avatar
Valeriy Panov committed
2
import {Field, reduxForm, FieldArray} from 'redux-form';
3

4
import {DATASET_BASIC_INFO_FORM} from 'constants/datasets';
Matija Obreza's avatar
Matija Obreza committed
5
import languages from 'data/Languages';
6

7
import {TextField} from 'ui/common/text-field';
8
import {MarkdownField} from 'ui/catalog/markdown';
9
import SelectPartner from 'ui/catalog/partner/SelectPartner';
10
import MaterialAutosuggest from 'ui/common/material-autosuggest';
Valeriy Panov's avatar
Valeriy Panov committed
11
import CropSelector from 'ui/catalog/crop/CropSelector';
12
13
14

import Validators from 'utilities/Validators';

15
import BasicInfoRadioGroup from './BasicInfoRadioGroup';
Maxym Borodenko's avatar
Maxym Borodenko committed
16
import remoteSubmit from './RemoteSubmit';
17
18
19
20
21
22
23
24
25
26
27

interface ILoginContainerProps extends React.ClassAttributes<any> {
    handleSubmit: () => void;
    initialValues: any;
    classes: any;
    uuid: string;
}

class BasicInfoStep extends React.Component<ILoginContainerProps, any> {

    public render() {
28

29
        const {initialValues, handleSubmit} = this.props;
30
31

        return (
Maxym Borodenko's avatar
Maxym Borodenko committed
32
            <form onSubmit={ handleSubmit } className="p-20 m-20 even-row">
33
                <Field required
34
                    name="owner"
35
                    component={ SelectPartner }
Matija Obreza's avatar
Matija Obreza committed
36
                    onlyMine
37
38
                    label="Select Partner"
                    placeholder="Partner"
Matija Obreza's avatar
Matija Obreza committed
39
                    editable={ ! (initialValues.uuid && initialValues.version) }
40
                    validate={ [ Validators.required ] }
41
                />
42
                <Field required
43
                    name="title"
44
45
46
                    basicMarkdown
                    component={ MarkdownField }
                    label="Title of the dataset"
47
                    placeholder="Title"
48
                    validate={ [ Validators.required ] }
49
                />
Matija Obreza's avatar
Matija Obreza committed
50
51
52
53
54
                <Field required
                    name="versionTag"
                    component={ TextField }
                    label="Dataset version"
                    placeholder="2018.1"
55
                    validate={ [ Validators.required ] }
Matija Obreza's avatar
Matija Obreza committed
56
                />
57
58
                <Field
                    name="description"
59
                    component={ MarkdownField }
60
                    label="Dataset description"
61
62
63
                    placeholder="An abstract, short or long description of the resource. Descriptive details improves discoverability of the resource."
                />
                <Field
64
65
66
                    name="created"
                    component={ TextField }
                    label="Date of creation of the document"
67
68
69
                />
                <Field
                    name="rights"
70
                    component={ BasicInfoRadioGroup }
71
72
73
74
75
76
77
78
79
80
81
82
83
84
                />
                <Field
                    name="language"
                    component={ MaterialAutosuggest }
                    label="Language"
                    placeholder="Select language*"
                    suggestions={ languages }
                    suggestionLabel="label"
                />
                <Field
                    name="source"
                    component={ TextField }
                    label="Source"
                />
Valeriy Panov's avatar
Valeriy Panov committed
85
86
87
88
89
                <FieldArray
                    name="crops"
                    component={ CropSelector }
                    label="Crops"
                />
90
91
92
93
94
95
96
            </form>
        );
    }
}

export default reduxForm({
    form: DATASET_BASIC_INFO_FORM,
Maxym Borodenko's avatar
Maxym Borodenko committed
97
    onSubmit: remoteSubmit,
98
    enableReinitialize: true,
Maxim Babichev's avatar
Maxim Babichev committed
99
})((BasicInfoStep));