Add confirmation popup on delete care or behavior.

This commit is contained in:
Geoffrey POUZET 2020-10-24 14:39:14 +02:00
parent ec570dddb2
commit 1def73b90a
5 changed files with 66 additions and 13 deletions

View File

@ -31,5 +31,7 @@ authentication.label.password=Password:
authentication.placeholder.password=Password
authentication.button.submit=Login
animal_list.delete.modal_body=Do you want to delete this animal?
animal_list.delete.modal_button_yes=Yes
animal_list.delete.modal_button_no=No
modal_button.delete=Delete
modal_button.cancel=Cancel
animal_cares_and_behaviors.delete.modal_body.behavior=Do you want to delete this behavior?
animal_cares_and_behaviors.delete.modal_body.care=Do you want to delete this care?

View File

@ -31,5 +31,7 @@ authentication.label.password=Password:
authentication.placeholder.password=Password
authentication.button.submit=Login
animal_list.delete.modal_body=Do you want to delete this animal?
animal_list.delete.modal_button_yes=Yes
animal_list.delete.modal_button_no=No
modal_button.delete=Delete
modal_button.cancel=Cancel
animal_cares_and_behaviors.delete.modal_body.behavior=Do you want to delete this behavior?
animal_cares_and_behaviors.delete.modal_body.care=Do you want to delete this care?

View File

@ -31,5 +31,7 @@ authentication.label.password=Mot de passe :
authentication.placeholder.password=Mot de passe
authentication.button.submit=Connexion
animal_list.delete.modal_body=Voulez-vous vraiment supprimer cet animal ?
animal_list.delete.modal_button_yes=Oui
animal_list.delete.modal_button_no=Non
modal_button.delete=Supprimer
modal_button.cancel=Annuler
animal_cares_and_behaviors.delete.modal_body.behavior=Voulez-vous vraiment supprimer ce comportement ?
animal_cares_and_behaviors.delete.modal_body.care=Voulez-vous vraiment supprimer ce soin ?

View File

@ -49,6 +49,7 @@
<div class="col-lg-12">
${care.getName()}
<form class="pull-right" action="${animalDeleteCareURL}/${care.getId()}" method="POST">
<input value="${care.getName()}" hidden />
<button class="btn btn-danger" type="submit" data-toggle="tooltip" data-placement="bottom" title="Suppression"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></button>
</form>
</div>
@ -81,6 +82,7 @@
<div class="col-lg-12">
${consentBehavior.getName()}
<form class="pull-right" action="${animalDeleteConsentBehaviorURL}/${consentBehavior.getId()}" method="POST">
<input value="${consentBehavior.getName()}" hidden />
<button class="btn btn-danger" type="submit" data-toggle="tooltip" data-placement="bottom" title="Suppression"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></button>
</form>
</div>
@ -104,11 +106,56 @@
<%@ include file="base/footer.jsp" %>
</div>
</body>
<script type="text/javascript">
$(document).ready(function () {
$('[data-toggle="tooltip"]').tooltip();
});
<div id="modal_delete_animal_care_or_behavior" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 id="modal_delete_animal_care_or_behavior_title" class="modal-title"></h4>
</div>
<div class="modal-body">
<p id="modal_delete_animal_care_or_behavior_body"></p>
</div>
<div class="modal-footer">
<form id="modal_delete_animal_care_or_behavior_validate_delete" class="pull-right" action="" method="POST">
<button type="button" class="btn btn-default" data-dismiss="modal"><fmt:message key="modal_button.cancel"></fmt:message></button>
<button type="submit" class="btn btn-danger"><fmt:message key="modal_button.delete"></fmt:message></button>
</form>
</div>
</div>
</div>
</div>
</body>
<script type="text/javascript">
$(document).ready(function () {
$('[data-toggle="tooltip"]').tooltip();
$("form").submit(function (event) {
if ($(this).attr('id') !== 'modal_delete_animal_care_or_behavior_validate_delete') {
var formUrl = $(this).attr('action');
if (formUrl.startsWith('${animalDeleteCareURL}') || formUrl.startsWith('${animalDeleteConsentBehaviorURL}')) {
// Only for deleting care or behavior forms
var careOrBehaviorName = $(this).find('input')[0].value;
$('#modal_delete_animal_care_or_behavior_title').text(careOrBehaviorName);
$('#modal_delete_animal_care_or_behavior_validate_delete').attr('action', formUrl);
if (formUrl.startsWith('${animalDeleteCareURL}')) {
$('#modal_delete_animal_care_or_behavior_body').text('<fmt:message key="animal_cares_and_behaviors.delete.modal_body.care"></fmt:message>');
} else if (formUrl.startsWith('${animalDeleteConsentBehaviorURL}')) {
$('#modal_delete_animal_care_or_behavior_body').text('<fmt:message key="animal_cares_and_behaviors.delete.modal_body.behavior"></fmt:message>');
}
$('#modal_delete_animal_care_or_behavior').modal({
show: true
});
event.preventDefault();
}
}
});
});
</script>
</html>

View File

@ -111,9 +111,9 @@
</div>
<div class="modal-footer">
<form id="modal_delete_animal_validate_delete" class="pull-right" action="" method="POST">
<button type="submit" class="btn btn-danger"><fmt:message key="animal_list.delete.modal_button_yes"></fmt:message></button>
<button type="button" class="btn btn-default" data-dismiss="modal"><fmt:message key="modal_button.cancel"></fmt:message></button>
<button type="submit" class="btn btn-danger"><fmt:message key="modal_button.delete"></fmt:message></button>
</form>
<button type="button" class="btn btn-default" data-dismiss="modal"><fmt:message key="animal_list.delete.modal_button_no"></fmt:message></button>
</div>
</div>