BasicInfoForm.tsx 3.46 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 {Partner} from 'model/partner.model';

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

import Validators from 'utilities/Validators';

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

interface ILoginContainerProps extends React.ClassAttributes<any> {
    handleSubmit: () => void;
    initialValues: any;
    classes: any;
    uuid: string;
24
    partners: Partner[];
25
26
27
28
29
}

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

    public render() {
30

Maxym Borodenko's avatar
Maxym Borodenko committed
31
        const {partners, initialValues, handleSubmit} = this.props;
32
33

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

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