Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Rex Dri
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
32
Issues
32
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Rex Dri
Rex Dri
Commits
5689754f
Commit
5689754f
authored
Sep 14, 2018
by
Florent Chehab
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better generalization
parent
6298e660
Pipeline
#27348
passed with stages
in 2 minutes and 38 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
51 deletions
+38
-51
frontend/src/components/university/editors/UniversityGeneralEditor.js
.../components/university/editors/UniversityGeneralEditor.js
+7
-24
frontend/src/components/university/editors/UniversitySemestersDatesEditor.js
...ents/university/editors/UniversitySemestersDatesEditor.js
+8
-26
frontend/src/components/university/shared/Editor.js
frontend/src/components/university/shared/Editor.js
+0
-1
frontend/src/components/university/shared/editorFunctions/getMapDispatchToPropsForEditor.js
.../shared/editorFunctions/getMapDispatchToPropsForEditor.js
+8
-0
frontend/src/components/university/shared/editorFunctions/getMapStateToPropsForEditor.js
...ity/shared/editorFunctions/getMapStateToPropsForEditor.js
+15
-0
No files found.
frontend/src/components/university/editors/UniversityGeneralEditor.js
View file @
5689754f
...
@@ -9,6 +9,9 @@ import editorStyle from '../shared/editorStyle';
...
@@ -9,6 +9,9 @@ import editorStyle from '../shared/editorStyle';
import
TextField
from
'
../shared/fields/TextField
'
;
import
TextField
from
'
../shared/fields/TextField
'
;
import
getMapStateToPropsForEditor
from
'
../shared/editorFunctions/getMapStateToPropsForEditor
'
;
import
getMapDispatchToPropsForEditor
from
'
../shared/editorFunctions/getMapDispatchToPropsForEditor
'
;
import
{
import
{
universitiesElSaveData
,
universitiesElSaveData
,
universitiesElSavingHasError
universitiesElSavingHasError
...
@@ -57,35 +60,15 @@ class UniversityGeneral extends Editor {
...
@@ -57,35 +60,15 @@ class UniversityGeneral extends Editor {
}
}
UniversityGeneral
.
propTypes
=
{
UniversityGeneral
.
propTypes
=
{
modelData
:
PropTypes
.
object
.
isRequired
,
modelData
:
PropTypes
.
object
.
isRequired
,
};
};
const
mapStateToProps
=
(
state
)
=>
{
let
lastUpdateTime
=
null
;
const
tmp
=
state
.
universitiesEl
.
fetched
;
if
(
tmp
.
fetchedAt
)
{
lastUpdateTime
=
tmp
.
data
.
updated_on
;
}
return
{
savingHasError
:
state
.
universitiesEl
.
savingHasError
,
lastSaveTime
:
state
.
universitiesEl
.
savedAt
,
lastUpdateTime
,
};
};
const
mapDispatchToProps
=
(
dispatch
)
=>
{
return
{
saveData
:
(
data
)
=>
dispatch
(
universitiesElSaveData
(
data
)),
clearSaveError
:
()
=>
dispatch
(
universitiesElSavingHasError
(
false
))
};
};
export
default
compose
(
export
default
compose
(
withStyles
(
styles
,
{
withTheme
:
true
}),
withStyles
(
styles
,
{
withTheme
:
true
}),
connect
(
mapStateToProps
,
mapDispatchToProps
)
connect
(
getMapStateToPropsForEditor
(
'
universitiesEl
'
),
getMapDispatchToPropsForEditor
(
universitiesElSaveData
,
universitiesElSavingHasError
)
)
)(
UniversityGeneral
);
)(
UniversityGeneral
);
\ No newline at end of file
frontend/src/components/university/editors/UniversitySemestersDatesEditor.js
View file @
5689754f
...
@@ -12,6 +12,9 @@ import MarkdownField from '../shared/fields/MarkdownField';
...
@@ -12,6 +12,9 @@ import MarkdownField from '../shared/fields/MarkdownField';
import
dateStrToDate
from
'
../../../utils/dateStrToDate
'
;
import
dateStrToDate
from
'
../../../utils/dateStrToDate
'
;
import
getMapStateToPropsForEditor
from
'
../shared/editorFunctions/getMapStateToPropsForEditor
'
;
import
getMapDispatchToPropsForEditor
from
'
../shared/editorFunctions/getMapDispatchToPropsForEditor
'
;
import
{
import
{
universitiesSemestersDatesElSaveData
,
universitiesSemestersDatesElSaveData
,
universitiesSemestersDatesElSavingHasError
universitiesSemestersDatesElSavingHasError
...
@@ -30,7 +33,7 @@ class UniversitySemestersDatesEditor extends Editor {
...
@@ -30,7 +33,7 @@ class UniversitySemestersDatesEditor extends Editor {
let
messages
=
Array
();
let
messages
=
Array
();
const
formData
=
this
.
getDataFromFields
();
const
formData
=
this
.
getDataFromFields
();
const
{
autumn_begin
,
autumn_end
,
spring_begin
,
spring_end
}
=
formData
;
const
{
autumn_begin
,
autumn_end
,
spring_begin
,
spring_end
}
=
formData
;
if
(
onlyOneIsNull
(
autumn_begin
,
autumn_end
))
{
if
(
onlyOneIsNull
(
autumn_begin
,
autumn_end
))
{
messages
.
push
(
"
Si une date est saisie pour le semestre d'automne, l'autre doit l'être aussi.
"
);
messages
.
push
(
"
Si une date est saisie pour le semestre d'automne, l'autre doit l'être aussi.
"
);
}
}
...
@@ -91,36 +94,15 @@ class UniversitySemestersDatesEditor extends Editor {
...
@@ -91,36 +94,15 @@ class UniversitySemestersDatesEditor extends Editor {
}
}
}
}
UniversitySemestersDatesEditor
.
propTypes
=
{
UniversitySemestersDatesEditor
.
propTypes
=
{
modelData
:
PropTypes
.
object
.
isRequired
,
modelData
:
PropTypes
.
object
.
isRequired
,
};
};
const
mapStateToProps
=
(
state
)
=>
{
let
lastUpdateTime
=
null
;
const
tmp
=
state
.
universitiesSemestersDatesEl
.
fetched
;
if
(
tmp
.
fetchedAt
)
{
lastUpdateTime
=
tmp
.
data
.
updated_on
;
}
return
{
savingHasError
:
state
.
universitiesSemestersDatesEl
.
savingHasError
,
lastSaveTime
:
state
.
universitiesSemestersDatesEl
.
savedAt
,
lastUpdateTime
,
};
};
const
mapDispatchToProps
=
(
dispatch
)
=>
{
return
{
saveData
:
(
data
)
=>
dispatch
(
universitiesSemestersDatesElSaveData
(
data
)),
clearSaveError
:
()
=>
dispatch
(
universitiesSemestersDatesElSavingHasError
(
false
))
};
};
export
default
compose
(
export
default
compose
(
withStyles
(
styles
,
{
withTheme
:
true
}),
withStyles
(
styles
,
{
withTheme
:
true
}),
connect
(
mapStateToProps
,
mapDispatchToProps
)
connect
(
getMapStateToPropsForEditor
(
'
universitiesSemestersDatesEl
'
),
getMapDispatchToPropsForEditor
(
universitiesSemestersDatesElSaveData
,
universitiesSemestersDatesElSavingHasError
)
)
)(
UniversitySemestersDatesEditor
);
)(
UniversitySemestersDatesEditor
);
\ No newline at end of file
frontend/src/components/university/shared/Editor.js
View file @
5689754f
...
@@ -163,7 +163,6 @@ class Editor extends MyComponent {
...
@@ -163,7 +163,6 @@ class Editor extends MyComponent {
if
(
this
.
state
.
lastSaveTime
<
this
.
props
.
lastSaveTime
)
{
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
;
...
...
frontend/src/components/university/shared/editorFunctions/getMapDispatchToPropsForEditor.js
0 → 100644
View file @
5689754f
export
default
function
getMapDispatchToPropsForEditor
(
saveDataAction
,
savingHasErrorAction
)
{
return
(
dispatch
)
=>
{
return
{
saveData
:
(
data
)
=>
dispatch
(
saveDataAction
(
data
)),
clearSaveError
:
()
=>
dispatch
(
savingHasErrorAction
(
false
))
};
}
}
\ No newline at end of file
frontend/src/components/university/shared/editorFunctions/getMapStateToPropsForEditor.js
0 → 100644
View file @
5689754f
export
default
function
getMapStateToPropsForEditor
(
elKey
)
{
return
(
state
)
=>
{
let
lastUpdateTime
=
null
;
const
tmp
=
state
[
elKey
].
fetched
;
if
(
tmp
.
fetchedAt
)
{
lastUpdateTime
=
tmp
.
data
.
updated_on
;
}
return
{
savingHasError
:
state
[
elKey
].
savingHasError
,
lastSaveTime
:
state
[
elKey
].
savedAt
,
lastUpdateTime
,
};
};
}
\ No newline at end of file
Write
Preview
Markdown
is supported
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