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
9e940bf1
Commit
9e940bf1
authored
Sep 13, 2018
by
Florent Chehab
Browse files
Alert when closing with unsave data
parent
22a5c7fe
Changes
1
Show whitespace changes
Inline
Side-by-side
frontend/src/components/university/modules/editors/Editor.js
View file @
9e940bf1
...
...
@@ -172,6 +172,33 @@ class Editor extends MyComponent {
})
}
handleCloseEditorRequest
()
{
console
.
log
(
"
close asked !
"
)
const
formData
=
this
.
getDataFromFields
();
const
{
modelData
}
=
this
.
props
;
if
(
this
.
hasChangesToSave
(
formData
,
modelData
))
{
this
.
setState
({
alert
:
{
open
:
true
,
info
:
false
,
title
:
"
Modifications non enregistrées !
"
,
description
:
"
Vous avez des modifications qui n'ont pas été sauvegardées. Voulez-vous les enregistrer ?
"
,
agreeText
:
"
Oui, je les enregistre
"
,
disagreeText
:
"
Non
"
,
handleResponse
:
(
agree
)
=>
{
if
(
agree
)
{
this
.
handleSaveEditor
();
}
else
{
this
.
props
.
handleCloseEditor
();
}
},
}
})
}
else
{
this
.
props
.
handleCloseEditor
();
}
}
renderEditor
()
{
return
(
<
div
>
No
editor
set
<
/div>
)
}
...
...
@@ -208,7 +235,6 @@ class Editor extends MyComponent {
<
Dialog
fullScreen
open
=
{
this
.
props
.
open
}
onClose
=
{
this
.
props
.
handleCloseEditor
}
TransitionComponent
=
{
Transition
}
>
<
Alert
...
...
@@ -217,7 +243,7 @@ class Editor extends MyComponent {
/
>
<
AppBar
className
=
{
classes
.
appBar
}
>
<
Toolbar
>
<
IconButton
color
=
"
inherit
"
onClick
=
{
this
.
prop
s
.
handleCloseEditor
}
aria
-
label
=
"
Close
"
>
<
IconButton
color
=
"
inherit
"
onClick
=
{
()
=>
thi
s
.
handleCloseEditor
Request
()
}
aria
-
label
=
"
Close
"
>
<
CloseIcon
/>
<
/IconButton
>
<
Typography
variant
=
"
title
"
color
=
"
inherit
"
className
=
{
classes
.
flex
}
>
...
...
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