blob: 4dccc9e1c42e2e151137e12ac7aebbd55ad15f44 [file] [log] [blame]
Michael Landoefa037d2017-02-19 12:57:33 +02001import React from 'react';
2import i18n from 'nfvo-utils/i18n/i18n.js';
3import ValidationInput from 'nfvo-components/input/validation/ValidationInput.jsx';
4import ValidationForm from 'nfvo-components/input/validation/ValidationForm.jsx';
5
6const LicenseModelPropType = React.PropTypes.shape({
7 id: React.PropTypes.string,
8 vendorName: React.PropTypes.string,
9 description: React.PropTypes.string
10});
11
12class LicenseModelCreationView extends React.Component {
13
14 static propTypes = {
15 data: LicenseModelPropType,
16 onDataChanged: React.PropTypes.func.isRequired,
17 onSubmit: React.PropTypes.func.isRequired,
18 onCancel: React.PropTypes.func.isRequired
19 };
20
21 render() {
22 let {data = {}, onDataChanged} = this.props;
23 let {vendorName, description} = data;
24 return (
25 <div>
26 <ValidationForm
27 ref='validationForm'
28 hasButtons={true}
29 onSubmit={ () => this.submit() }
30 onReset={ () => this.props.onCancel() }
31 labledButtons={true}>
32 <ValidationInput
33 value={vendorName}
34 label={i18n('Vendor Name')}
35 ref='vendor-name'
36 onChange={vendorName => onDataChanged({vendorName})}
37 validations={{maxLength: 25, required: true}}
38 type='text'
39 className='field-section'/>
40 <ValidationInput
41 value={description}
42 label={i18n('Description')}
43 ref='description'
44 onChange={description => onDataChanged({description})}
45 validations={{maxLength: 1000, required: true}}
46 type='textarea'
47 className='field-section'/>
48 </ValidationForm>
49 </div>
50 );
51 }
52
53
54 submit() {
55 const {data:licenseModel} = this.props;
56 this.props.onSubmit(licenseModel);
57 }
58}
59
60export default LicenseModelCreationView;