Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Julien Jerphanion
Rex Dri
Commits
8658d749
Commit
8658d749
authored
Sep 16, 2018
by
Florent Chehab
Browse files
Better POO in modules
parent
ff58b6fd
Changes
6
Hide whitespace changes
Inline
Side-by-side
frontend/src/components/university/modules/CountryDri.js
View file @
8658d749
...
...
@@ -7,7 +7,7 @@ import __pick from 'lodash/pick';
import
Markdown
from
'
../../shared/Markdown
'
;
import
M
yComponent
from
'
../
../MyComponent
'
;
import
M
odule
from
'
../
shared/Module
'
;
import
GenericModule
from
'
../shared/GenericModule
'
;
import
GenericGroupModule
from
'
../shared/GenericGroupModule
'
;
...
...
@@ -47,19 +47,7 @@ function parseRawModelData(rawModelData) {
}
class
CountryDri
extends
MyComponent
{
ignoreInvalidation
=
true
;
componentWillUnmount
()
{
this
.
props
.
invalidateData
(
true
);
}
myComponentDidUpdate
()
{
if
(
this
.
props
.
countryDri
.
invalidated
&&
!
this
.
props
.
countryDri
.
isLoading
)
{
this
.
props
.
fetchData
.
countryDri
(
this
.
props
.
countryId
);
}
}
class
CountryDri
extends
Module
{
myRender
()
{
const
countryDriItems
=
this
.
getFetchedData
(
'
countryDri
'
);
const
{
countries
,
classes
}
=
this
.
props
;
...
...
frontend/src/components/university/modules/UniversityDri.js
View file @
8658d749
...
...
@@ -7,7 +7,7 @@ import __pick from 'lodash/pick';
import
Markdown
from
'
../../shared/Markdown
'
;
import
M
yComponent
from
'
../
../MyComponent
'
;
import
M
odule
from
'
../
shared/Module
'
;
import
GenericModule
from
'
../shared/GenericModule
'
;
import
GenericGroupModule
from
'
../shared/GenericGroupModule
'
;
...
...
@@ -50,19 +50,7 @@ function parseRawModelData(rawModelData) {
}
class
UniversityDri
extends
MyComponent
{
ignoreInvalidation
=
true
;
componentWillUnmount
()
{
this
.
props
.
invalidateData
(
true
);
}
myComponentDidUpdate
()
{
if
(
this
.
props
.
universityDri
.
invalidated
&&
!
this
.
props
.
universityDri
.
isLoading
)
{
this
.
props
.
fetchData
.
universityDri
(
this
.
props
.
univId
);
}
}
class
UniversityDri
extends
Module
{
myRender
()
{
const
univDriItems
=
this
.
getFetchedData
(
'
universityDri
'
);
const
{
universities
,
classes
}
=
this
.
props
;
...
...
frontend/src/components/university/modules/UniversityGeneral.js
View file @
8658d749
...
...
@@ -8,7 +8,7 @@ import __pick from 'lodash/pick';
import
Markdown
from
'
../../shared/Markdown
'
;
import
Typography
from
'
@material-ui/core/Typography
'
;
import
M
yComponent
from
'
../
../MyComponent
'
;
import
M
odule
from
'
../
shared/Module
'
;
import
TextLink
from
'
../../other/TextLink
'
;
import
Grid
from
'
@material-ui/core/Grid
'
;
import
Divider
from
'
@material-ui/core/Divider
'
;
...
...
@@ -84,11 +84,7 @@ function parseRawModelData(rawModelData) {
}
class
UniversityGeneral
extends
MyComponent
{
componentWillUnmount
()
{
this
.
props
.
invalidateData
();
}
class
UniversityGeneral
extends
Module
{
myRender
()
{
const
univInfos
=
this
.
getFetchedData
(
'
universitiesEl
'
);
const
{
classes
}
=
this
.
props
;
...
...
frontend/src/components/university/modules/UniversityScholarships.js
View file @
8658d749
...
...
@@ -5,7 +5,7 @@ import compose from 'recompose/compose';
import
{
connect
}
from
"
react-redux
"
;
import
__pick
from
'
lodash/pick
'
;
import
M
yComponent
from
'
../../MyComponent
'
;
import
M
odule
from
'
../shared/Module
'
;
import
GenericModule
from
'
../shared/GenericModule
'
;
import
GenericGroupModule
from
'
../shared/GenericGroupModule
'
;
...
...
@@ -65,19 +65,7 @@ function parseRawModelData(rawModelData) {
}
class
UniversityScholarships
extends
MyComponent
{
ignoreInvalidation
=
true
;
componentWillUnmount
()
{
this
.
props
.
invalidateData
(
true
);
}
myComponentDidUpdate
()
{
if
(
this
.
props
.
universityScholarships
.
invalidated
&&
!
this
.
props
.
universityScholarships
.
isLoading
)
{
this
.
props
.
fetchData
.
universityScholarships
(
this
.
props
.
univId
);
}
}
class
UniversityScholarships
extends
Module
{
myRender
()
{
const
univScholarshipsItems
=
this
.
getFetchedData
(
'
universityScholarships
'
);
const
{
universities
,
currencies
,
classes
}
=
this
.
props
;
...
...
frontend/src/components/university/modules/UniversitySemestersDates.js
View file @
8658d749
...
...
@@ -17,7 +17,7 @@ import LocalFloristIcon from '@material-ui/icons/LocalFlorist';
import
GenericModule
from
'
../shared/GenericModule
'
;
import
M
yComponent
from
'
../
../MyComponent
'
;
import
M
odule
from
'
../
shared/Module
'
;
import
dateStrToStr
from
'
../../../utils/dateStrToStr
'
;
...
...
@@ -126,12 +126,8 @@ function parseRawModelData(rawModelData) {
}
class
UniversitySemestersDates
extends
MyComponent
{
componentWillUnmount
()
{
this
.
props
.
invalidateData
();
}
class
UniversitySemestersDates
extends
Module
{
myRender
()
{
const
semestersDates
=
this
.
getFetchedData
(
'
universitiesSemestersDatesEl
'
);
const
{
classes
}
=
this
.
props
;
...
...
frontend/src/components/university/shared/Module.js
0 → 100644
View file @
8658d749
import
React
from
'
react
'
;
import
MyComponent
from
'
../../MyComponent
'
;
class
Module
extends
MyComponent
{
// prevent hard reset of module when refetching
ignoreInvalidation
=
true
;
componentWillUnmount
()
{
this
.
props
.
invalidateData
(
true
);
}
myComponentDidUpdate
()
{
this
.
fetchAbleProps
.
map
((
propKey
)
=>
{
if
(
this
.
props
[
propKey
].
invalidated
&&
!
this
.
props
[
propKey
].
isLoading
)
{
this
.
props
.
fetchData
[
propKey
](
this
.
props
.
univId
);
}
})
}
}
export
default
Module
;
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment