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