Commit 72edc3c0 authored by Florent Chehab's avatar Florent Chehab

Fixed update data when changing univ

parent 4936f83f
Pipeline #27356 passed with stages
in 2 minutes and 30 seconds
......@@ -137,20 +137,28 @@ export function {{obj.name}}IsLoading(bool) {
};
}
export function {{obj.name}}Invalidated(bool) {
export function {{obj.name}}Invalidated(bool, resetObj=false) {
if (resetObj){
{{obj.name}}FetchDataSuccess({}, false);
}
return {
type: {{obj.NAME}}_INVALIDATED,
invalidated: bool
};
}
export function {{obj.name}}FetchDataSuccess({{obj.name}}) {
{{obj.name}}Invalidated(false)
export function {{obj.name}}FetchDataSuccess({{obj.name}}, setInvalidateFalse=true) {
let time = null;
if (setInvalidateFalse){
{{obj.name}}Invalidated(false)
time = Date.now();
}
return {
type: {{obj.NAME}}_FETCH_DATA_SUCCESS,
{{obj.name}},
{{obj.name}}FetchedAt: Date.now()
{{obj.name}}FetchedAt: time
};
}
......
......@@ -129,6 +129,7 @@ class MyComponent extends Component {
componentDidMount() {
this.loadPropsIfNeeded();
this.myComponentDidMount();
this.forceUpdate(); // bug otherwies
}
myComponentDidMount() { };
......@@ -145,8 +146,9 @@ class MyComponent extends Component {
// // render if nextprops should be visible
// return true;
// }
return true;
return this.myShouldComponentUpdate(nextProps, nextState);
}
myShouldComponentUpdate(nextProps, nextState){ return true; }
componentDidUpdate(prevProps, prevState, snapshot) {
// TODO ajouter expire date
......
......@@ -15,8 +15,6 @@ import GenericGroupModule from '../shared/GenericGroupModule';
import CountryDriEditor from '../editors/CountryDriEditor';
import {
citiesFetchData,
mainCampusesFetchData,
countriesFetchData,
countryDriFetchData,
countryDriInvalidated,
......@@ -54,7 +52,7 @@ class CountryDri extends MyComponent {
ignoreInvalidation = true;
componentWillUnmount() {
this.props.invalidateData();
this.props.invalidateData(true);
}
myComponentDidUpdate() {
......@@ -74,7 +72,7 @@ class CountryDri extends MyComponent {
return (
<GenericGroupModule
groupTitle={"Informations émanant de la DRI"}
groupTitle={"Informations émanant de la DRI liées au pays"}
endPoint={"countryDri"}
editor={CountryDriEditor}
invalidateGroup={this.props.invalidateData}
......@@ -119,8 +117,6 @@ const mapStateToProps = (state) => {
return {
countryDri: state.countryDri,
countries: state.countries,
cities: state.cities,
mainCampuses: state.mainCampuses
};
};
......@@ -129,10 +125,8 @@ const mapDispatchToProps = (dispatch) => {
fetchData: {
countryDri: (countryId) => dispatch(countryDriFetchData(countryId)),
countries: () => dispatch(countriesFetchData()),
cities: () => dispatch(citiesFetchData()),
mainCampuses: () => dispatch(mainCampusesFetchData()),
},
invalidateData: () => dispatch(countryDriInvalidated(true))
invalidateData: (resetObj=false) => dispatch(countryDriInvalidated(true, resetObj))
};
};
......
......@@ -55,7 +55,7 @@ class UniversityDri extends MyComponent {
ignoreInvalidation = true;
componentWillUnmount() {
this.props.invalidateData();
this.props.invalidateData(true);
}
myComponentDidUpdate() {
......@@ -75,7 +75,7 @@ class UniversityDri extends MyComponent {
return (
<GenericGroupModule
groupTitle={"Informations émanant de la DRI"}
groupTitle={"Informations émanant de la DRI liées à l'université"}
endPoint={"universityDri"}
editor={UniversityDriEditor}
invalidateGroup={this.props.invalidateData}
......@@ -129,7 +129,7 @@ const mapDispatchToProps = (dispatch) => {
universityDri: (univId) => dispatch(universityDriFetchData(univId)),
universities: () => dispatch(universitiesFetchData()),
},
invalidateData: () => dispatch(universityDriInvalidated(true))
invalidateData: (resetObj = false) => dispatch(universityDriInvalidated(true, resetObj))
};
};
......
......@@ -11,6 +11,7 @@ import Grid from '@material-ui/core/Grid';
import UniversityGeneral from '../modules/UniversityGeneral';
import UniversitySemestersDates from '../modules/UniversitySemestersDates';
import UniversityDri from '../modules/UniversityDri';
import CountryDri from '../modules/CountryDri';
import withWidth, { isWidthUp } from '@material-ui/core/withWidth';
import InfoProvider from '../shared/InfoProvider';
......@@ -50,6 +51,10 @@ class GeneralInfoTab extends MyComponent {
univId={this.props.univId}
renderAndAddPropsTo={UniversityDri}
/>
<InfoProvider
univId={this.props.univId}
renderAndAddPropsTo={CountryDri}
/>
</Grid>
</Grid>
</div>
......@@ -83,6 +88,10 @@ class GeneralInfoTab extends MyComponent {
univId={this.props.univId}
renderAndAddPropsTo={UniversityDri}
/>
<InfoProvider
univId={this.props.univId}
renderAndAddPropsTo={CountryDri}
/>
</Grid>
<Grid item xs={12}>
<UniversitySemestersDates visible={this.props.visible} univId={this.props.univId} />
......
......@@ -12,6 +12,8 @@ import {
universitiesInfoElReducers,
universityDriReducers,
universityDriElReducers,
countryDriReducers,
countryDriElReducers,
universitiesSemestersDatesElReducers,
serverModerationStatusReducers,
versionsReducers,
......@@ -43,6 +45,8 @@ const rootReducer = combineReducers({
universitiesSemestersDatesEl: universitiesSemestersDatesElReducers,
universityDri: universityDriReducers,
universityDriEl: universityDriElReducers,
countryDri: countryDriReducers,
countryDriEl: countryDriElReducers,
currencies: currenciesReducers,
mainCampuses: mainCampusesReducers,
userDataEl: userDataElReducers,
......
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