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
65260c06
Commit
65260c06
authored
Mar 01, 2019
by
Florent Chehab
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed nasty save detection and make use of requestCallabck on save in editor
parent
302743c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
34 deletions
+41
-34
frontend/src/components/university/shared/Editor.js
frontend/src/components/university/shared/Editor.js
+41
-34
No files found.
frontend/src/components/university/shared/Editor.js
View file @
65260c06
...
...
@@ -72,20 +72,6 @@ class Editor extends Component {
////////////////////////
/**
* Function to save the `data` to the server.
*
* @param {Object} data
* @memberof Editor
*/
performSave
(
data
)
{
this
.
notifyIsSaving
();
this
.
props
.
saveData
(
Object
.
assign
({
__apiAttr
:
this
.
props
.
__apiAttr
},
data
)
);
}
/**
* Function to handle save editor events, eg when clicking on the save button
* This function is not trivial and checks are performed.
...
...
@@ -112,6 +98,46 @@ class Editor extends Component {
}
/**
* Function to save the `data` to the server.
*
* @param {Object} data
* @memberof Editor
*/
performSave
(
data
)
{
this
.
notifyIsSaving
();
this
.
props
.
saveData
(
Object
.
assign
({
__apiAttr
:
this
.
props
.
__apiAttr
},
data
),
(
newData
)
=>
this
.
handleSaveRequestWasSuccessful
(
newData
)
);
}
/**
* Function that is called as soon as we now that the save request to the server was successful
*
* This enables not to use weird save detection method.
*
* @param {object} newData object returned by the server
* @memberof Editor
*/
handleSaveRequestWasSuccessful
(
newData
)
{
// We check if data was moderated
let
message
,
lastUpdateTimeInModel
=
this
.
props
.
lastUpdateTimeInModel
;
// at this point it will be still the previously stored data
const
newUpdateTimeInModel
=
newData
.
updated_on
;
if
(
lastUpdateTimeInModel
==
newUpdateTimeInModel
)
{
message
=
"
Les données ont été enregistrées et sont en attentes de modération.
"
;
}
else
{
lastUpdateTimeInModel
=
newUpdateTimeInModel
;
message
=
"
Les données ont été enregistrées avec succès !
"
;
}
this
.
notifySaveSuccessful
(
message
);
this
.
closeEditor
(
true
);
}
/**
* Function to handle close editor request from the user.
* It checks if there is data to save or not.
...
...
@@ -147,7 +173,7 @@ class Editor extends Component {
*
* @memberof Editor
*/
componentDidUpdate
(
prevProps
)
{
componentDidUpdate
()
{
// Open the editor if needed
// don't check the if prevProps was false before, we need to rerender it anyway so that we can
...
...
@@ -172,25 +198,6 @@ class Editor extends Component {
if
(
savingHasError
.
failed
&&
!
this
.
state
.
alert
.
open
)
{
this
.
alertSaveFailed
(
savingHasError
.
error
.
content
.
toString
());
}
//saving data was successful
if
(
prevProps
.
lastSaveTime
<
this
.
props
.
lastSaveTime
)
{
// We check if data was moderated
let
message
,
lastUpdateTimeInModel
=
prevProps
.
lastUpdateTimeInModel
;
const
newUpdateTimeInModel
=
this
.
props
.
lastUpdateTimeInModel
;
if
(
lastUpdateTimeInModel
==
newUpdateTimeInModel
)
{
message
=
"
Les données ont été enregistrées et sont en attentes de modération.
"
;
}
else
{
lastUpdateTimeInModel
=
newUpdateTimeInModel
;
message
=
"
Les données ont été enregistrées avec succès !
"
;
}
this
.
setState
({
lastSaveTime
:
this
.
props
.
lastSaveTime
,
lastUpdateTimeInModel
});
this
.
notifySaveSuccessful
(
message
);
this
.
closeEditor
(
true
);
}
}
...
...
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