Commit f9be8300 authored by Florent Chehab's avatar Florent Chehab

Updated Editors and take advantage of new infos provided

parent 1e64a50c
......@@ -25,24 +25,11 @@ const styles = theme => ({
class CountryDriEditor extends Editor {
renderEditor() {
const { modelData } = this.props;
const { outsideData } = this.props;
const countries = __map(outsideData.countries,
(country) => { return { label: country.name, value: country.id, disabled: false } }
)
return (
<div>
{this.renderTitleField()}
{this.renderImportanceLevelField()}
<MultiSelectField label={"Pays concernés"}
required={true}
value={modelData.countries}
options={countries}
formManager={this}
fieldMapping={'countries'}
/>
{this.renderCountriesField()}
{this.renderCommentField()}
{this.renderUsefulLinksField()}
</div>
......
......@@ -6,7 +6,6 @@ import { connect } from "react-redux";
import Editor from '../shared/Editor';
import editorStyle from '../shared/editorStyle';
import MultiSelectField from '../shared/fields/MultiSelectField';
import __map from 'lodash/map';
......@@ -36,13 +35,7 @@ class UniversityDriEditor extends Editor {
<div>
{this.renderTitleField()}
{this.renderImportanceLevelField()}
<MultiSelectField label={"Universités concernées"}
required={true}
value={modelData.universities}
options={universities}
formManager={this}
fieldMapping={'universities'}
/>
{this.renderUniversitiesField()}
{this.renderCommentField()}
{this.renderUsefulLinksField()}
</div>
......
......@@ -108,7 +108,8 @@ class CountryDri extends MyComponent {
CountryDri.propTypes = {
classes: PropTypes.object.isRequired,
theme: PropTypes.object.isRequired,
countryId: PropTypes.string.isRequired
countryId: PropTypes.string.isRequired,
countries: PropTypes.object.isRequired,
};
const mapStateToProps = (state) => {
......
......@@ -111,7 +111,8 @@ class UniversityDri extends MyComponent {
UniversityDri.propTypes = {
classes: PropTypes.object.isRequired,
theme: PropTypes.object.isRequired,
univId: PropTypes.string.isRequired
univId: PropTypes.string.isRequired,
universities: PropTypes.object.isRequired,
};
const mapStateToProps = (state) => {
......
......@@ -18,6 +18,9 @@ import SelectField from './fields/SelectField';
import UsefulLinksField from './fields/UsefulLinksField';
import MarkdownField from './fields/MarkdownField';
import TextField from './fields/TextField';
import MultiSelectField from './fields/MultiSelectField';
import __map from 'lodash/map';
function Transition(props) {
return <Slide direction="up" {...props} />;
......@@ -319,6 +322,42 @@ class Editor extends MyComponent {
)
}
renderUniversitiesField() {
const { modelData } = this.props;
const { outsideData } = this.props;
const universities = __map(outsideData.universities,
(univ) => { return { label: univ.name, value: univ.id, disabled: false } }
)
return (
<MultiSelectField label={"Universités concernées"}
required={true}
value={modelData.universities}
options={universities}
formManager={this}
fieldMapping={'universities'}
/>
)
}
renderCountriesField() {
const { modelData } = this.props;
const { outsideData } = this.props;
const countries = __map(outsideData.countries,
(country) => { return { label: country.name, value: country.id, disabled: false } }
)
return (
<MultiSelectField label={"Pays concernés"}
required={true}
value={modelData.countries}
options={countries}
formManager={this}
fieldMapping={'countries'}
/>
)
}
myRender() {
const { classes } = this.props;
return (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment