Skip to content

Commit dd3cedd

Browse files
committed
Vision
1 parent 69b8a44 commit dd3cedd

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

evap/grades/templates/grades_course_view.html

+27-22
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,33 @@ <h3 class="mb-3">{{ course.name }} ({{ semester.name }})</h3>
3030
<a href="{% url 'grades:download_grades' grade_document.id %}" class="btn btn-sm btn-light" data-bs-toggle="tooltip" data-bs-placement="top" title="{% trans 'Download' %}"><span class="fas fa-download"></span></a>
3131
{% if user.is_grade_publisher %}
3232
<a href="{% url 'grades:edit_grades' grade_document.id %}" class="btn btn-sm btn-light" data-bs-toggle="tooltip" data-bs-placement="top" title="{% trans 'Edit' %}"><span class="fas fa-pencil"></span></a>
33-
<button type="button" {{ disable_if_archived }} onclick="deleteGradedocumentModalShow({{ grade_document.id }}, '{{ grade_document.description|escapejs }}');" class="btn btn-sm btn-danger" data-bs-toggle="tooltip" data-bs-placement="top" title="{% trans 'Delete' %}">
34-
<span class="fas fa-trash"></span>
35-
</button>
33+
<confirmation-modal btn-type="danger">
34+
<span slot="title">{% trans 'Delete grade document' %}</span>
35+
<span slot="action-text">{% trans 'Delete grade document' %}</span>
36+
<span slot="question">
37+
{% blocktrans with document='<strong>{{ grade_document.description }}</strong>' %}
38+
Do you really want to delete the grade document {{ document }}?
39+
{% endblocktrans %}
40+
</span>
41+
<script slot="handler">
42+
const modal = ConfirmationModal.current();
43+
modal.confirmButton.addEventListener("click", async () => {
44+
const response = await fetch("{% url 'grades:delete_grades' %}", {
45+
body: new URLSearchParams({grade_document_id: "{{ grade_document.id }}"}),
46+
headers: CSRF_HEADERS,
47+
method: "POST",
48+
});
49+
50+
if (response.ok) {
51+
const row = modal.closest("tr");
52+
// TODO: animate
53+
row.remove();
54+
} else {
55+
window.alert("{% trans 'The server is not responding.' %}");
56+
}
57+
});
58+
</script>
59+
</confirmation-modal>
3660
{% endif %}
3761
</td>
3862
</tr>
@@ -49,22 +73,3 @@ <h3 class="mb-3">{{ course.name }} ({{ semester.name }})</h3>
4973
<a href="{% url 'grades:upload_grades' course.id %}?final=true" class="btn btn-dark {{ disable_if_archived }}">{% trans 'Upload new final grades' %}</a>
5074
{% endif %}
5175
{% endblock %}
52-
53-
{% block modals %}
54-
{{ block.super }}
55-
{% trans 'Delete grade document' as title %}
56-
{% trans 'Do you really want to delete the grade document <strong data-label=""></strong>?' as question %}
57-
{% trans 'Delete grade document' as action_text %}
58-
{% include 'confirmation_modal.html' with modal_id='deleteGradedocumentModal' title=title question=question action_text=action_text btn_type='danger' %}
59-
<script type="text/javascript">
60-
function deleteGradedocumentModalAction(dataId) {
61-
$.ajax({
62-
type: "POST",
63-
url: "{% url 'grades:delete_grades' %}",
64-
data: {"grade_document_id": dataId},
65-
success: function(){ $('#grade_document-row-'+dataId).hide('slow', function(){ $('#grade_document-row-'+dataId).remove(); }); },
66-
error: function(){ window.alert("{% trans 'The server is not responding.' %}"); }
67-
});
68-
};
69-
</script>
70-
{% endblock %}

0 commit comments

Comments
 (0)