Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Show a confirmation dialog when trying to delete an exercise.

Roland Geider90fe097d63ee
diff --git a/manager/templates/exercise/overview.html b/manager/templates/exercise/overview.html
index bfc8ce97b..c3856a5c6 100644
--- a/manager/templates/exercise/overview.html
+++ b/manager/templates/exercise/overview.html
@@ -12,25 +12,51 @@
{% block header %}
<script src="{% static "js/jquery-ui.js" %}"></script>
<script>
- $(document).ready(function() {
-
- // Init the tabs for the exercises
- $( "#tabs" ).tabs();
-
- // Init the autocompleter
- $("#exercise-search").autocomplete({
- source: "{% url manager.views.exercise_search %}",
- minLength: 2,
- select: function(event, ui) {
-
- // Redirect to exercise after clicking on a result
- // Path is hard coded here, because we can't use the url-tag
- window.location.href = '/exercise/view/' + ui.item.id
- }
- });
+$(document).ready(function() {
+
+ // Init the tabs for the exercises
+ $( "#tabs" ).tabs();
+
+ // Init the autocompleter
+ $("#exercise-search").autocomplete({
+ source: "{% url manager.views.exercise_search %}",
+ minLength: 2,
+ select: function(event, ui) {
+
+ // Redirect to exercise after clicking on a result
+ // Path is hard coded here, because we can't use the url-tag
+ window.location.href = '/exercise/view/' + ui.item.id
+ }
+ });
+ // Initialise a modal dialog
+ $("#dialog-confirm").dialog({
+ autoOpen: false,
+ width: 400,
+ modal: true,
+ });
+
+
+ // Show the dialog when a user wants to delete an exercise
+ $(".delete-exercise").click(function(e) {
+ e.preventDefault();
+ var targetUrl = $(this).attr("href");
+
+ $("#dialog-confirm").dialog({
+ buttons : {
+ {% trans "Confirm" %}: function() {
+ window.location.href = targetUrl;
+ },
+ {% trans "Cancel" %} : function() {
+ $(this).dialog("close");
+ }
+ }
});
+ $("#dialog-confirm").dialog("open");
+ });
+
+});
</script>
{% endblock %}
@@ -42,6 +68,14 @@
<h2> {% trans "Exercises" %} </h2>
+<div id="dialog-confirm" title="{% trans 'Really delete exercise?' %}">
+ <p>
+ <span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>
+ {% trans "Deleting the exercise will also delete it from all workouts." %}
+ {% trans "Are you sure?" %}
+ </p>
+</div>
+
<div id="tabs">
<ul>
{% for category in categories %}
@@ -63,10 +97,11 @@
<td style="text-align:right;">
<div class="editoptions">
<a href="{% url manager.views.exercise_edit exercise.id %}"
- title="{% trans "Edit" %}">[e]</a>
+ title="{% trans 'Edit' %}">[e]</a>
<a href="{% url manager.views.exercise_delete exercise.id %}"
- title="{% trans "Delete" %}">[x]</a>
+ title="{% trans 'Delete' %}"
+ class="delete-exercise">[x]</a>
</div>
</td>
</tr>