Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Philipp Wolfer
funkwhale
Commits
df8b9867
Verified
Commit
df8b9867
authored
Mar 18, 2019
by
Ciarán Ainsworth
Committed by
Eliot Berriot
Mar 20, 2019
Browse files
Resolve #630: "Do not allow tab closure during upload"
parent
53d1a5c9
Changes
3
Hide whitespace changes
Inline
Side-by-side
changes/changelog.d/630.enhancement
0 → 100644
View file @
df8b9867
Ask for confirmation before leaving upload page if there is a an upload in process (#630)
\ No newline at end of file
front/src/components/library/FileUpload.vue
View file @
df8b9867
...
...
@@ -166,14 +166,24 @@ export default {
id
:
"
fileUpload
"
,
handler
:
this
.
handleImportEvent
});
window
.
onbeforeunload
=
e
=>
this
.
onBeforeUnload
(
e
);
},
destroyed
()
{
this
.
$store
.
commit
(
"
ui/removeWebsocketEventHandler
"
,
{
eventName
:
"
import.status_updated
"
,
id
:
"
fileUpload
"
});
window
.
onbeforeunload
=
null
;
},
methods
:
{
onBeforeUnload
(
e
=
{})
{
const
returnValue
=
(
'
This page is asking you to confirm that you want to leave - data you have entered may not be saved.
'
);
if
(
!
this
.
hasActiveUploads
)
return
null
;
Object
.
assign
(
e
,
{
returnValue
,
});
return
returnValue
;
},
inputFile
(
newFile
,
oldFile
)
{
this
.
$refs
.
upload
.
active
=
true
;
},
...
...
@@ -291,6 +301,9 @@ export default {
f
.
statusIndex
=
statusIndex
return
f
}),
[
'
statusIndex
'
,
'
name
'
])
},
hasActiveUploads
()
{
return
this
.
sortedFiles
.
filter
((
f
)
=>
{
return
f
.
active
}).
length
>
0
}
},
watch
:
{
...
...
front/src/views/content/libraries/Upload.vue
View file @
df8b9867
...
...
@@ -4,7 +4,7 @@
<div
class=
"ui text loader"
><translate>
Loading library data…
</translate></div>
</div>
<detail-area
v-else
:library=
"library"
>
<file-upload
:default-import-reference=
"defaultImportReference"
:library=
"library"
/>
<file-upload
ref=
"fileupload"
:default-import-reference=
"defaultImportReference"
:library=
"library"
/>
</detail-area>
</div>
</
template
>
...
...
@@ -20,6 +20,19 @@ export default {
components
:
{
DetailArea
,
FileUpload
},
beforeRouteLeave
(
to
,
from
,
next
){
if
(
this
.
$refs
.
fileupload
.
hasActiveUploads
){
const
answer
=
window
.
confirm
(
'
This page is asking you to confirm that you want to leave - data you have entered may not be saved.
'
)
if
(
answer
)
{
next
()
}
else
{
next
(
false
)
}
}
else
{
next
()
}
}
}
</
script
>
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment