Commit 775e0e56 authored by Florent Chehab's avatar Florent Chehab
Browse files

Clean saving time and reset data

parent 24444ce9
Pipeline #27347 passed with stages
in 2 minutes and 47 seconds
...@@ -72,7 +72,7 @@ const mapStateToProps = (state) => { ...@@ -72,7 +72,7 @@ const mapStateToProps = (state) => {
return { return {
savingHasError: state.universitiesEl.savingHasError, savingHasError: state.universitiesEl.savingHasError,
lastSave: state.universitiesEl.fetched.fetchedAt, lastSaveTime: state.universitiesEl.savedAt,
lastUpdateTime, lastUpdateTime,
}; };
}; };
......
...@@ -107,7 +107,7 @@ const mapStateToProps = (state) => { ...@@ -107,7 +107,7 @@ const mapStateToProps = (state) => {
return { return {
savingHasError: state.universitiesSemestersDatesEl.savingHasError, savingHasError: state.universitiesSemestersDatesEl.savingHasError,
lastSave: state.universitiesSemestersDatesEl.fetched.fetchedAt, lastSaveTime: state.universitiesSemestersDatesEl.savedAt,
lastUpdateTime, lastUpdateTime,
}; };
}; };
......
...@@ -19,6 +19,7 @@ import UniversityGeneralEditor from '../editors/UniversityGeneralEditor'; ...@@ -19,6 +19,7 @@ import UniversityGeneralEditor from '../editors/UniversityGeneralEditor';
import { import {
universitiesElFetchData, universitiesElFetchData,
universitiesElInvalidated,
citiesFetchData, citiesFetchData,
countriesFetchData, countriesFetchData,
mainCampusesFetchData, mainCampusesFetchData,
...@@ -75,6 +76,10 @@ function parseRawModelData(rawModelData) { ...@@ -75,6 +76,10 @@ function parseRawModelData(rawModelData) {
class UniversityGeneral extends MyComponent { class UniversityGeneral extends MyComponent {
idToUse = "univId"; idToUse = "univId";
componentWillUnmount() {
this.props.invalidateData();
}
myRender() { myRender() {
const univInfos = this.getFetchedData('universitiesEl'); const univInfos = this.getFetchedData('universitiesEl');
const { classes } = this.props; const { classes } = this.props;
...@@ -90,6 +95,7 @@ class UniversityGeneral extends MyComponent { ...@@ -90,6 +95,7 @@ class UniversityGeneral extends MyComponent {
return ( return (
<GenericModule <GenericModule
visible={this.props.visible}
buildTitle={() => "Présentation"} buildTitle={() => "Présentation"}
rawModelData={univInfos} rawModelData={univInfos}
parseRawModelData={parseRawModelData} parseRawModelData={parseRawModelData}
...@@ -125,6 +131,7 @@ const mapDispatchToProps = (dispatch) => { ...@@ -125,6 +131,7 @@ const mapDispatchToProps = (dispatch) => {
cities: () => dispatch(citiesFetchData()), cities: () => dispatch(citiesFetchData()),
mainCampuses: () => dispatch(mainCampusesFetchData()), mainCampuses: () => dispatch(mainCampusesFetchData()),
}, },
invalidateData: () => dispatch(universitiesElInvalidated(true, true))
}; };
}; };
......
...@@ -25,6 +25,7 @@ import UniversitySemestersDatesEditor from '../editors/UniversitySemestersDatesE ...@@ -25,6 +25,7 @@ import UniversitySemestersDatesEditor from '../editors/UniversitySemestersDatesE
import { import {
universitiesSemestersDatesElFetchData, universitiesSemestersDatesElFetchData,
universitiesSemestersDatesElInvalidated,
} from '../../../generated/actions'; } from '../../../generated/actions';
const styles = theme => ({ const styles = theme => ({
...@@ -128,6 +129,10 @@ function parseRawModelData(rawModelData) { ...@@ -128,6 +129,10 @@ function parseRawModelData(rawModelData) {
class UniversitySemestersDates extends MyComponent { class UniversitySemestersDates extends MyComponent {
idToUse = "univId"; idToUse = "univId";
componentWillUnmount() {
this.props.invalidateData();
}
myRender() { myRender() {
const semestersDates = this.getFetchedData('universitiesSemestersDatesEl'); const semestersDates = this.getFetchedData('universitiesSemestersDatesEl');
const { classes } = this.props; const { classes } = this.props;
...@@ -163,6 +168,7 @@ const mapDispatchToProps = (dispatch) => { ...@@ -163,6 +168,7 @@ const mapDispatchToProps = (dispatch) => {
fetchData: { fetchData: {
universitiesSemestersDatesEl: (univId) => dispatch(universitiesSemestersDatesElFetchData(univId)), universitiesSemestersDatesEl: (univId) => dispatch(universitiesSemestersDatesElFetchData(univId)),
}, },
invalidateData: () => dispatch(universitiesSemestersDatesElInvalidated(true, true)),
}; };
}; };
......
...@@ -38,7 +38,7 @@ class Editor extends MyComponent { ...@@ -38,7 +38,7 @@ class Editor extends MyComponent {
notification: { notification: {
open: false, open: false,
}, },
lastSave: this.props.lastSave, lastSaveTime: this.props.lastSaveTime,
lastUpdateTime: this.props.lastUpdateTime, lastUpdateTime: this.props.lastUpdateTime,
} }
...@@ -161,9 +161,9 @@ class Editor extends MyComponent { ...@@ -161,9 +161,9 @@ class Editor extends MyComponent {
} }
} }
if (this.state.lastSave < this.props.lastSave) { if (this.state.lastSaveTime < this.props.lastSaveTime) {
//saving data was successfull //saving data was successfull
console.log("state", this.state.lastSaveTime, "props", this.props.lastSaveTime)
// We check if data was moderated // We check if data was moderated
let message = "Les données ont été enregistrées avec succès !"; let message = "Les données ont été enregistrées avec succès !";
let lastUpdateTime = this.state.lastUpdateTime; let lastUpdateTime = this.state.lastUpdateTime;
...@@ -173,7 +173,7 @@ class Editor extends MyComponent { ...@@ -173,7 +173,7 @@ class Editor extends MyComponent {
} else { } else {
lastUpdateTime = newUpdateTime; lastUpdateTime = newUpdateTime;
} }
this.setState({ lastSave: this.props.lastSave, lastUpdateTime }); this.setState({ lastSaveTime: this.props.lastSaveTime, lastUpdateTime });
this.setState({ this.setState({
notification: { notification: {
......
...@@ -39,20 +39,20 @@ class GeneralInfoTab extends MyComponent { ...@@ -39,20 +39,20 @@ class GeneralInfoTab extends MyComponent {
<div style={{ flexGrow: 8, paddingRight: 2 * theme.spacing.unit }}> <div style={{ flexGrow: 8, paddingRight: 2 * theme.spacing.unit }}>
<Grid container direction='column' > <Grid container direction='column' >
<Grid item xs style={{ paddingBottom: 2 * theme.spacing.unit }} > <Grid item xs style={{ paddingBottom: 2 * theme.spacing.unit }} >
<UniversityGeneral univId={this.props.univId} /> <UniversityGeneral visible={this.props.visible} univId={this.props.univId} />
</Grid> </Grid>
<Grid item xs> <Grid item xs>
{/* <UniversityDri univId={this.props.univId} /> */} {/* <UniversityDri visible={this.props.visible} univId={this.props.univId} /> */}
</Grid> </Grid>
</Grid> </Grid>
</div> </div>
<div style={{ flexGrow: 6 }} > <div style={{ flexGrow: 6 }} >
<Grid container direction='column' > <Grid container direction='column' >
<Grid item xs style={{ paddingBottom: 2 * theme.spacing.unit }}> <Grid item xs style={{ paddingBottom: 2 * theme.spacing.unit }}>
<UniversitySemestersDates univId={this.props.univId} /> <UniversitySemestersDates visible={this.props.visible} univId={this.props.univId} />
</Grid> </Grid>
<Grid item xs> <Grid item xs>
{/* <GenericModule title={"Offres de départs"} automaticData={true} /> */} {/* <GenericModule visible={this.props.visible} title={"Offres de départs"} automaticData={true} /> */}
</Grid> </Grid>
</Grid> </Grid>
</div> </div>
...@@ -66,16 +66,16 @@ class GeneralInfoTab extends MyComponent { ...@@ -66,16 +66,16 @@ class GeneralInfoTab extends MyComponent {
<Grid container spacing={16} > <Grid container spacing={16} >
<Grid item xs={12}> <Grid item xs={12}>
<UniversityGeneral univId={this.props.univId} /> <UniversityGeneral visible={this.props.visible} univId={this.props.univId} />
</Grid> </Grid>
<Grid item xs={12}> <Grid item xs={12}>
{/* <UniversityDri univId={this.props.univId} /> */} {/* <UniversityDri visible={this.props.visible} univId={this.props.univId} /> */}
</Grid> </Grid>
<Grid item xs={12}> <Grid item xs={12}>
<UniversitySemestersDates univId={this.props.univId} /> <UniversitySemestersDates visible={this.props.visible} univId={this.props.univId} />
</Grid> </Grid>
<Grid item xs={12}> <Grid item xs={12}>
{/* <GenericModule title={"Offres de départs"} automaticData={true} /> */} {/* <GenericModule visible={this.props.visible} title={"Offres de départs"} automaticData={true} /> */}
</Grid> </Grid>
</Grid> </Grid>
......
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