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

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