Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
compendium-v2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
geant-swd
compendium-v2
Commits
81c61e70
Commit
81c61e70
authored
1 year ago
by
Remco Tukker
Browse files
Options
Downloads
Patches
Plain Diff
add listeners for closing page without stopping edit
parent
2abf719f
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!57
Feature/survey locking system
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
survey-frontend/src/SurveyContainerComponent.tsx
+13
-0
13 additions, 0 deletions
survey-frontend/src/SurveyContainerComponent.tsx
survey-frontend/src/SurveyManagementComponent.tsx
+1
-1
1 addition, 1 deletion
survey-frontend/src/SurveyManagementComponent.tsx
with
14 additions
and
1 deletion
survey-frontend/src/SurveyContainerComponent.tsx
+
13
−
0
View file @
81c61e70
...
...
@@ -126,6 +126,15 @@ function SurveyContainerComponent({ loadFrom, saveTo = '' }) {
}
}
const
beforeUnloadListener
=
(
event
)
=>
{
event
.
preventDefault
();
return
(
event
.
returnValue
=
""
);
};
const
pageHideListener
=
(
event
)
=>
{
window
.
navigator
.
sendBeacon
(
'
/api/survey/unlock/
'
+
year
+
'
/
'
+
nren
,
JSON
.
stringify
({
some
:
"
data
"
}))
}
const
doSurveyAction
=
(
action
)
=>
{
switch
(
action
)
{
case
'
save
'
:
...
...
@@ -137,9 +146,13 @@ function SurveyContainerComponent({ loadFrom, saveTo = '' }) {
case
'
saveAndStopEdit
'
:
saveSurveyData
(
surveyModel
);
// TODO include stop editing
surveyModel
.
mode
=
'
display
'
;
removeEventListener
(
"
beforeunload
"
,
beforeUnloadListener
,
{
capture
:
true
});
removeEventListener
(
"
pagehide
"
,
pageHideListener
);
break
;
case
'
startEdit
'
:
// TODO lock http request
addEventListener
(
"
pagehide
"
,
pageHideListener
);
addEventListener
(
"
beforeunload
"
,
beforeUnloadListener
,
{
capture
:
true
});
surveyModel
.
mode
=
'
edit
'
;
break
;
}
...
...
This diff is collapsed.
Click to expand it.
survey-frontend/src/SurveyManagementComponent.tsx
+
1
−
1
View file @
81c61e70
...
...
@@ -100,7 +100,7 @@ function SurveyManagementComponent() {
<
td
>
<
Button
onClick
=
{
()
=>
navigate
(
`/survey/respond/
${
survey
.
year
}
/
${
response
.
nren
}
`
)
}
style
=
{
{
pointerEvents
:
'
auto
'
}
}
title
=
"Open the responses of the NREN."
>
edit
open
</
Button
>
remove lock (only available when locked)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment