Commit b68243af authored by Florent Chehab's avatar Florent Chehab

Restored University Dri and fixes accross the board

parent 65260c06
......@@ -5,18 +5,19 @@ import compose from "recompose/compose";
import { connect } from "react-redux";
import Editor from "../shared/Editor";
import Form from "../shared/Form";
import editorStyle from "../shared/editorStyle";
import getMapStateToPropsForEditor from "../shared/editorFunctions/getMapStateToPropsForEditor";
import getMapDispatchToPropsForEditor from "../shared/editorFunctions/getMapDispatchToPropsForEditor";
import { withSnackbar } from "notistack";
const styles = theme => ({
...editorStyle(theme)
});
class UniversityDriEditor extends Editor {
renderEditor() {
class UniversityDriForm extends Form {
render() {
return (
<div>
{this.renderTitleField()}
......@@ -29,12 +30,24 @@ class UniversityDriEditor extends Editor {
}
}
class UniversityDriEditor extends Editor {
renderForm() {
return <UniversityDriForm
modelData={this.props.modelData}
outsideData={this.props.outsideData}
ref={this.formRef}
/>;
}
}
UniversityDriEditor.propTypes = {
modelData: PropTypes.object.isRequired,
};
export default compose(
withSnackbar,
withStyles(styles, { withTheme: true }),
connect(
getMapStateToPropsForEditor("universityDri"),
......
......@@ -50,13 +50,12 @@ function parseRawModelData(rawModelData) {
class UniversityDri extends Module {
customRender() {
const univDriItems = this.getReadData("universityDri");
const { universities, classes } = this.props;
const { universities, classes } = this.props,
outsideData = { universities };
const outsideData = {
universities
};
const univDriItems = this.getReadData("universityDri");
return (
<GenericGroupModule
......@@ -72,9 +71,9 @@ class UniversityDri extends Module {
}}
>
{
univDriItems.map((rawModelData, idx) => (
univDriItems.map(rawModelData => (
<GenericModule
key={idx}
key={rawModelData.id} // use the id of the model to prevent useless unmount
buildTitle={(modelData) => modelData.title}
rawModelData={rawModelData}
parseRawModelData={parseRawModelData}
......
......@@ -160,6 +160,7 @@ Object.assign(Form.prototype, renderFieldsMixIn);
Form.propTypes = {
modelData: PropTypes.object.isRequired,
outsideData: PropTypes.object,
};
export default Form;
......@@ -56,7 +56,7 @@ class GenericGroupModule extends CustomComponentForAPI {
this.setState({ editorOpen: true });
}
handleCloseEditor = (somethingWasSaved = false) => {
handleEditorWasClosed = (somethingWasSaved = false) => {
this.setState({ editorOpen: false });
if (somethingWasSaved) {
this.props.invalidateGroup();
......@@ -64,16 +64,16 @@ class GenericGroupModule extends CustomComponentForAPI {
};
customRender() {
const { classes, groupTitle } = this.props;
const { endPoint } = this.props;
const userCanPostTo = this.getReadData("userData").owner_can_post_to;
const disabled = userCanPostTo.indexOf(endPoint) < 0;
const { classes, groupTitle, endPoint } = this.props,
userCanPostTo = this.getReadData("userData").owner_can_post_to,
disabled = userCanPostTo.indexOf(endPoint) < 0;
return (
<Paper className={classes.root}>
<this.props.editor
{...this.props.propsForEditor}
open={this.state.editorOpen}
handleCloseEditor={this.handleCloseEditor}
handleEditorWasClosed={this.handleEditorWasClosed}
userData={this.props.userData}
/>
<Grid container spacing={8} alignItems='center'>
......
......@@ -68,7 +68,7 @@ class GenericModule extends CustomComponentForAPI {
handleEditorWasClosed = (somethingWasSaved = false) => {
this.setState({ editorOpen: false, dataToSave: null });
if (somethingWasSaved && this.props.moduleInGroupInfos.isInGroup) {
// this.props.moduleInGroupInfos.invalidateGroup();
this.props.moduleInGroupInfos.invalidateGroup();
}
};
......
......@@ -7,8 +7,6 @@ import CustomComponentForAPI from "../../CustomComponentForAPI";
* @extends React.Component
*/
class Module extends CustomComponentForAPI {
// prevent hard reset of module when refetching
// ignoreInvalidation = true;
componentWillUnmount() {
this.props.invalidateData(true);
......
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