Commit f9be8300 authored by Florent Chehab's avatar Florent Chehab
Browse files

Updated Editors and take advantage of new infos provided

parent 1e64a50c
...@@ -25,24 +25,11 @@ const styles = theme => ({ ...@@ -25,24 +25,11 @@ const styles = theme => ({
class CountryDriEditor extends Editor { class CountryDriEditor extends Editor {
renderEditor() { 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 ( return (
<div> <div>
{this.renderTitleField()} {this.renderTitleField()}
{this.renderImportanceLevelField()} {this.renderImportanceLevelField()}
<MultiSelectField label={"Pays concernés"} {this.renderCountriesField()}
required={true}
value={modelData.countries}
options={countries}
formManager={this}
fieldMapping={'countries'}
/>
{this.renderCommentField()} {this.renderCommentField()}
{this.renderUsefulLinksField()} {this.renderUsefulLinksField()}
</div> </div>
......
...@@ -6,7 +6,6 @@ import { connect } from "react-redux"; ...@@ -6,7 +6,6 @@ import { connect } from "react-redux";
import Editor from '../shared/Editor'; import Editor from '../shared/Editor';
import editorStyle from '../shared/editorStyle'; import editorStyle from '../shared/editorStyle';
import MultiSelectField from '../shared/fields/MultiSelectField';
import __map from 'lodash/map'; import __map from 'lodash/map';
...@@ -36,13 +35,7 @@ class UniversityDriEditor extends Editor { ...@@ -36,13 +35,7 @@ class UniversityDriEditor extends Editor {
<div> <div>
{this.renderTitleField()} {this.renderTitleField()}
{this.renderImportanceLevelField()} {this.renderImportanceLevelField()}
<MultiSelectField label={"Universités concernées"} {this.renderUniversitiesField()}
required={true}
value={modelData.universities}
options={universities}
formManager={this}
fieldMapping={'universities'}
/>
{this.renderCommentField()} {this.renderCommentField()}
{this.renderUsefulLinksField()} {this.renderUsefulLinksField()}
</div> </div>
......
...@@ -108,7 +108,8 @@ class CountryDri extends MyComponent { ...@@ -108,7 +108,8 @@ class CountryDri extends MyComponent {
CountryDri.propTypes = { CountryDri.propTypes = {
classes: PropTypes.object.isRequired, classes: PropTypes.object.isRequired,
theme: PropTypes.object.isRequired, theme: PropTypes.object.isRequired,
countryId: PropTypes.string.isRequired countryId: PropTypes.string.isRequired,
countries: PropTypes.object.isRequired,
}; };
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
......
...@@ -111,7 +111,8 @@ class UniversityDri extends MyComponent { ...@@ -111,7 +111,8 @@ class UniversityDri extends MyComponent {
UniversityDri.propTypes = { UniversityDri.propTypes = {
classes: PropTypes.object.isRequired, classes: PropTypes.object.isRequired,
theme: PropTypes.object.isRequired, theme: PropTypes.object.isRequired,
univId: PropTypes.string.isRequired univId: PropTypes.string.isRequired,
universities: PropTypes.object.isRequired,
}; };
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
......
...@@ -18,6 +18,9 @@ import SelectField from './fields/SelectField'; ...@@ -18,6 +18,9 @@ import SelectField from './fields/SelectField';
import UsefulLinksField from './fields/UsefulLinksField'; import UsefulLinksField from './fields/UsefulLinksField';
import MarkdownField from './fields/MarkdownField'; import MarkdownField from './fields/MarkdownField';
import TextField from './fields/TextField'; import TextField from './fields/TextField';
import MultiSelectField from './fields/MultiSelectField';
import __map from 'lodash/map';
function Transition(props) { function Transition(props) {
return <Slide direction="up" {...props} />; return <Slide direction="up" {...props} />;
...@@ -319,6 +322,42 @@ class Editor extends MyComponent { ...@@ -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() { myRender() {
const { classes } = this.props; const { classes } = this.props;
return ( 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