Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ARC-Support
public projects
lou-server
Commits
2c24a61a
Commit
2c24a61a
authored
Feb 05, 2021
by
Maik Messerschmidt
Browse files
Ask for confirmation before removing results.
parent
cdb0a551
Changes
3
Hide whitespace changes
Inline
Side-by-side
resources/js/app.js
View file @
2c24a61a
require
(
'
./bootstrap
'
);
require
(
'
./bootstrap
'
);
require
(
'
./confirm-delete
'
)
resources/js/confirm-delete.js
0 → 100644
View file @
2c24a61a
/**
* Adds a click-listener to each "confirm-delete" class element.
*
* When clicked, the form referenced by the elements "data-form-id" value
* will be submitted, after asking for confirmation.
*
* Take a look at resources/views/results/index.blade.php for better understanding.
*/
document
.
addEventListener
(
"
DOMContentLoaded
"
,
()
=>
{
for
(
const
elem
of
document
.
getElementsByClassName
(
"
confirm-delete
"
))
{
const
form
=
document
.
getElementById
(
elem
.
dataset
.
formId
)
const
message
=
elem
.
dataset
.
message
elem
.
addEventListener
(
"
click
"
,
event
=>
{
event
.
preventDefault
()
const
confirmed
=
confirm
(
elem
.
dataset
.
message
||
"
Delete?
"
)
if
(
confirmed
)
form
.
submit
()
})
}
})
resources/views/results/index.blade.php
View file @
2c24a61a
...
@@ -37,8 +37,9 @@
...
@@ -37,8 +37,9 @@
<
i
class
=
"fa fa-eye"
></
i
><
small
>
json
</
small
>
<
i
class
=
"fa fa-eye"
></
i
><
small
>
json
</
small
>
</
a
>
</
a
>
<
a
href
=
"_blank"
title
=
"Remove these results"
<
a
href
=
"_blank"
class
=
"confirm-delete"
title
=
"Remove these results"
onclick
=
"event.preventDefault(); document.getElementById('remove-form-
{
{$result->id}
}
').submit();"
>
data
-
form
-
id
=
"remove-form-
{
{$result->id}
}
"
data
-
message
=
"Do you really want to delete this result?"
>
<
i
class
=
"fa fa-remove"
></
i
>
<
i
class
=
"fa fa-remove"
></
i
>
</
a
>
</
a
>
...
...
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