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
Rex Dri
Rex Dri
Commits
42dbc13a
Commit
42dbc13a
authored
Sep 13, 2018
by
Florent Chehab
Browse files
Notif on form error and bug corrected
parent
10829504
Pipeline
#27286
passed with stages
in 2 minutes and 48 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
frontend/src/components/university/modules/editors/Editor.js
View file @
42dbc13a
...
@@ -68,7 +68,7 @@ class Editor extends MyComponent {
...
@@ -68,7 +68,7 @@ class Editor extends MyComponent {
hasChangesToSave
(
formData
,
modelData
)
{
hasChangesToSave
(
formData
,
modelData
)
{
for
(
let
fieldKey
in
formData
)
{
for
(
let
fieldKey
in
formData
)
{
if
(
formData
[
fieldKey
]
!=
modelData
[
fieldKey
])
{
if
(
formData
[
fieldKey
]
!=
modelData
[
fieldKey
])
{
console
.
log
(
fieldKey
,
formData
[
fieldKey
],
modelData
[
fieldKey
]);
//
console.log(fieldKey, formData[fieldKey], modelData[fieldKey]);
return
true
;
return
true
;
}
}
}
}
...
@@ -76,8 +76,7 @@ class Editor extends MyComponent {
...
@@ -76,8 +76,7 @@ class Editor extends MyComponent {
}
}
handleSaveEditor
()
{
handleSaveEditor
()
{
if
(
this
.
formIsValid
()
&&
!
this
.
formFieldsHaveError
())
{
if
(
this
.
formIsValid
())
{
const
formData
=
this
.
getDataFromFields
();
const
formData
=
this
.
getDataFromFields
();
const
{
modelData
}
=
this
.
props
;
const
{
modelData
}
=
this
.
props
;
if
(
this
.
hasChangesToSave
(
formData
,
modelData
))
{
if
(
this
.
hasChangesToSave
(
formData
,
modelData
))
{
...
@@ -104,7 +103,15 @@ class Editor extends MyComponent {
...
@@ -104,7 +103,15 @@ class Editor extends MyComponent {
}
}
}
else
{
}
else
{
console
.
log
(
"
ici
"
)
this
.
setState
({
notification
:
{
open
:
true
,
message
:
"
Le formulaire semble incohérent, merci de vérifier son contenu.
"
,
duration
:
5000
,
error
:
true
,
handleClose
:
this
.
handleCloseNotification
()
}
})
}
}
}
}
...
@@ -151,7 +158,8 @@ class Editor extends MyComponent {
...
@@ -151,7 +158,8 @@ class Editor extends MyComponent {
handleCloseNotification
()
{
handleCloseNotification
()
{
this
.
setState
({
this
.
setState
({
notification
:
{
open
:
false
}
// backup message to prevent graphic artefact
notification
:
{
open
:
false
,
message
:
this
.
state
.
notification
.
message
}
})
})
}
}
...
...
frontend/src/components/university/modules/editors/Notification.js
View file @
42dbc13a
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
PropTypes
,
{
array
}
from
'
prop-types
'
;
import
PropTypes
,
{
array
}
from
'
prop-types
'
;
import
{
withStyles
}
from
'
@material-ui/core/styles
'
;
import
{
withStyles
}
from
'
@material-ui/core/styles
'
;
import
Button
from
'
@material-ui/core/Button
'
;
import
Snackbar
from
'
@material-ui/core/Snackbar
'
;
import
Snackbar
from
'
@material-ui/core/Snackbar
'
;
import
DoneIcon
from
'
@material-ui/icons/Done
'
;
import
DoneIcon
from
'
@material-ui/icons/Done
'
;
import
Loading
from
'
../../../../components/other/Loading
'
import
Loading
from
'
../../../../components/other/Loading
'
import
IconButton
from
'
@material-ui/core/IconButton
'
;
import
CloseIcon
from
'
@material-ui/icons/Close
'
;
const
styles
=
theme
=>
({
const
styles
=
theme
=>
({
close
:
{
close
:
{
...
@@ -33,6 +34,18 @@ class Notification extends React.Component {
...
@@ -33,6 +34,18 @@ class Notification extends React.Component {
actions
.
push
(
actions
.
push
(
<
DoneIcon
color
=
'
primary
'
/>
<
DoneIcon
color
=
'
primary
'
/>
)
)
}
else
if
(
this
.
props
.
error
)
{
actions
.
push
(
<
IconButton
key
=
"
close
"
aria
-
label
=
"
Fermer
"
color
=
"
inherit
"
className
=
{
classes
.
close
}
onClick
=
{
this
.
props
.
handleClose
}
>
<
CloseIcon
/>
<
/IconButton
>
)
}
}
return
(
return
(
...
@@ -62,6 +75,7 @@ Notification.defaultProps = {
...
@@ -62,6 +75,7 @@ Notification.defaultProps = {
message
:
""
,
message
:
""
,
preventClickAway
:
true
,
preventClickAway
:
true
,
success
:
false
,
success
:
false
,
error
:
false
,
isLoading
:
false
,
isLoading
:
false
,
handleClose
:
()
=>
console
.
log
(
"
cloossee notif
"
)
handleClose
:
()
=>
console
.
log
(
"
cloossee notif
"
)
}
}
...
@@ -73,6 +87,7 @@ Notification.propTypes = {
...
@@ -73,6 +87,7 @@ Notification.propTypes = {
message
:
PropTypes
.
string
.
isRequired
,
message
:
PropTypes
.
string
.
isRequired
,
preventClickAway
:
PropTypes
.
bool
.
isRequired
,
preventClickAway
:
PropTypes
.
bool
.
isRequired
,
success
:
PropTypes
.
bool
.
isRequired
,
success
:
PropTypes
.
bool
.
isRequired
,
error
:
PropTypes
.
bool
.
isRequired
,
isLoading
:
PropTypes
.
bool
.
isRequired
,
isLoading
:
PropTypes
.
bool
.
isRequired
,
handleClose
:
PropTypes
.
func
.
isRequired
,
handleClose
:
PropTypes
.
func
.
isRequired
,
};
};
...
...
frontend/src/components/university/modules/editors/fields/SelectField.js
View file @
42dbc13a
...
@@ -18,7 +18,7 @@ const styles = theme => ({
...
@@ -18,7 +18,7 @@ const styles = theme => ({
class
SelectField
extends
Field
{
class
SelectField
extends
Field
{
hasError
(
value
)
{
hasError
(
value
)
{
return
this
.
props
.
required
&&
!
value
;
return
this
.
props
.
required
&&
(
value
==
null
)
;
}
}
handleChangeValue
=
(
value
)
=>
{
handleChangeValue
=
(
value
)
=>
{
...
...
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