Skip to content

Commit ae36e95

Browse files
committed
more modals and fix blocktrans
1 parent 65f7505 commit ae36e95

File tree

3 files changed

+63
-48
lines changed

3 files changed

+63
-48
lines changed

evap/grades/templates/grades_course_view.html

+3-4
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ <h3 class="mb-3">{{ course.name }} ({{ semester.name }})</h3>
3535
<span slot="title">{% trans 'Delete grade document' %}</span>
3636
<span slot="action-text">{% trans 'Delete grade document' %}</span>
3737
<span slot="question">
38-
{% blocktrans with document='<strong>{{ grade_document.description|escape }}</strong>' %}
39-
Do you really want to delete the grade document {{ document|safe }}?
38+
{% blocktrans with description=grade_document.description %}
39+
Do you really want to delete the grade document <strong>{{ description }}</strong>?
4040
{% endblocktrans %}
4141
</span>
4242

@@ -49,9 +49,8 @@ <h3 class="mb-3">{{ course.name }} ({{ semester.name }})</h3>
4949
</tr>
5050
{% endfor %}
5151

52-
<script async type="module">
52+
<script type="module">
5353
import { CSRF_HEADERS } from "{% static 'js/csrf-utils.js' %}";
54-
await customElements.whenDefined("confirmation-modal");
5554

5655
document.querySelectorAll("confirmation-modal[data-delete-document]").forEach(modal => {
5756
modal.addEventListener("confirmed", async () => {

evap/grades/templates/grades_semester_view.html

+41-34
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,38 @@ <h3 class="col-9 mb-0">
5959
{% if num_final_grades > 0 %}
6060
<span class="fas fa-file"></span> {{ num_final_grades }}
6161
{% elif course.gets_no_grade_documents %}
62-
<a href="#" onclick="confirmLateruploadModalShow({{ course.id }}, '{{ course.name|escapejs }}');">
63-
<span class="fas fa-xmark light-link" data-bs-toggle="tooltip" data-bs-placement="top" title="{% trans 'Grade documents for this course will not be uploaded. Click to change.' %}"></span>
64-
</a>
62+
<confirmation-modal confirm-button-class="btn-primary" data-toggle-grades-course="{{ course.id }}">
63+
<span slot="title">{% trans 'Will final grades be uploaded?' %}</span>
64+
<span slot="action-text">{% trans 'Confirm' %}</span>
65+
<span slot="question">
66+
{% blocktrans with course_name=course.name %}
67+
Please confirm that a grade document for the course <strong>{{ course_name }}</strong> will be uploaded later on.
68+
{% endblocktrans %}
69+
</span>
70+
71+
<a slot="show-button" href="#">
72+
<span class="fas fa-xmark light-link" data-bs-toggle="tooltip" data-bs-placement="top" title="{% trans 'Grade documents for this course will not be uploaded. Click to change.' %}"></span>
73+
</a>
74+
</confirmation-modal>
6575
{% endif %}
6676
</td>
6777
<td class="text-end" style="min-width:72px">
6878
{% if not course.gets_no_grade_documents %}
6979
{% if num_final_grades == 0 %}
70-
<button type="button" {{ disable_if_archived }} onclick="confirmNouploadModalShow({{ course.id }}, '{{ course.name|escapejs }}');" class="btn btn-sm btn-secondary" data-bs-toggle="tooltip" data-bs-placement="top" title="{% trans 'Confirm that final grades have been submitted but will not be uploaded.' %}">
71-
<span class="fas fa-xmark"></span>
72-
</button>
80+
<confirmation-modal confirm-button-class="btn-primary" data-toggle-grades-course="{{ course.id }}">
81+
<span slot="title">{% trans 'Have final grades been submitted?' %}</span>
82+
<span slot="action-text">{% trans 'Confirm' %}</span>
83+
<span slot="question">
84+
{% blocktrans with course_name=course.name %}
85+
Please confirm that the final grades for the course <strong>{{ course_name }}</strong> have been submitted but will not be uploaded.
86+
{% endblocktrans %}
87+
</span>
88+
89+
<button slot="show-button" type="button" {{ disable_if_archived }} class="btn btn-sm btn-secondary" data-bs-toggle="tooltip" data-bs-placement="top" title="{% trans 'Confirm that final grades have been submitted but will not be uploaded.' %}">
90+
<span class="fas fa-xmark"></span>
91+
</button>
92+
</confirmation-modal>
93+
7394
<div class="btn-group" role="group" data-bs-toggle="tooltip" data-bs-placement="top" title="{% trans 'Upload grade document' %}">
7495
<button type="button" id="btnUpload{{ course.id }}" class="btn btn-sm btn-dark dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
7596
<span class="fas fa-upload"></span>
@@ -88,41 +109,27 @@ <h3 class="col-9 mb-0">
88109
{% endfor %}
89110
</tbody>
90111
</table>
112+
113+
<script type="module">
114+
import { CSRF_HEADERS } from "{% static 'js/csrf-utils.js' %}";
115+
116+
document.querySelectorAll("confirmation-modal[data-toggle-grades-course]").forEach(modal => {
117+
modal.addEventListener("confirmed", () => {
118+
fetch("{% url 'grades:toggle_no_grades' %}", {
119+
method: "POST",
120+
headers: CSRF_HEADERS,
121+
body: new URLSearchParams({"course_id": modal.dataset.toggleGradesCourse}),
122+
}).then(() => location.reload());
123+
});
124+
});
125+
</script>
91126
{% else %}
92127
<span class="fst-italic">{% trans 'No courses have been created yet' %}</span>
93128
{% endif %}
94129
</div>
95130
</div>
96131
{% endblock %}
97132

98-
{% block modals %}
99-
{{ block.super }}
100-
{% trans 'Have final grades been submitted?' as title %}
101-
{% trans 'Please confirm that the final grades for the course <strong data-label=""></strong> have been submitted but will not be uploaded.' as question %}
102-
{% trans 'Confirm' as action_text %}
103-
{% include 'confirmation_modal.html' with modal_id='confirmNouploadModal' title=title question=question action_text=action_text btn_type='primary' %}
104-
<script type="text/javascript">
105-
function confirmNouploadModalAction(dataId) {
106-
$.ajax({
107-
type: "POST",
108-
url: "{% url 'grades:toggle_no_grades' %}",
109-
data: {"course_id": dataId},
110-
success: function(){ location.reload(); },
111-
error: function(){}
112-
});
113-
};
114-
</script>
115-
{% trans 'Will final grades be uploaded?' as title %}
116-
{% trans 'Please confirm that a grade document for the course <strong data-label=""></strong> will be uploaded later on.' as question %}
117-
{% trans 'Confirm' as action_text %}
118-
{% include 'confirmation_modal.html' with modal_id='confirmLateruploadModal' title=title question=question action_text=action_text btn_type='primary' %}
119-
<script type="text/javascript">
120-
function confirmLateruploadModalAction(dataId) {
121-
confirmNouploadModalAction(dataId);
122-
};
123-
</script>
124-
{% endblock %}
125-
126133
{% block additional_javascript %}
127134
<script type="module">
128135
import {TableGrid} from "{% static 'js/datagrid.js' %}";

evap/staff/templates/staff_semester_view.html

+19-10
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,25 @@ <h3>
7272
<div class="btn-switch ms-2">
7373
<div class="btn-switch-label">{% trans 'Reward points active' %}</div>
7474
<div class="btn-switch btn-group icon-buttons">
75-
<button type="button" onclick="activateRewardPointsModalShow({{ semester.id }}, '{{ semester.name|escapejs }}');" class="btn btn-sm btn-light{% if rewards_active %} active{% endif %}"><span class="fas fa-check" aria-hidden="true"></span></button>
75+
<confirmation-modal confirm-button-class="btn-primary" data-delete-document="{{ grade_document.id }}">
76+
<span slot="title">{% trans 'Activate reward points' %}</span>
77+
<span slot="action-text">{% trans 'Activate reward points' %}</span>
78+
<span slot="question">
79+
{% blocktrans with semester_name=semester.name %}
80+
Do you want to activate the reward points for the semester <strong>{{ semester_name }}</strong>?
81+
The activation will allow participants to receive reward points when voting and will also grant all eligible points for participants who have already voted so far.
82+
The process will take a while.
83+
{% endblocktrans %}
84+
</span>
85+
86+
<button slot="show-button" type="button" class="btn btn-sm btn-light{% if rewards_active %} active{% endif %}"><span class="fas fa-check" aria-hidden="true"></span></button>
87+
</confirmation-modal>
88+
89+
<script defer type="text/javascript">
90+
const modal = document.currentScript.previousElementSibling;
91+
modal.addEventListener("confirmed", () => document.getElementById("form_activation_status").requestSubmit());
92+
</script>
93+
7694
<button type="submit" name="activation_status" value="off" form="form_activation_status" class="btn btn-sm btn-light{% if not rewards_active %} active{% endif %}"><span class="fas fa-xmark" aria-hidden="true"></span></button>
7795
</div>
7896
</div>
@@ -554,15 +572,6 @@ <h3>
554572
});
555573
};
556574
</script>
557-
{% trans 'Activate reward points' as title %}
558-
{% blocktrans asvar question %}Do you want to activate the reward points for the semester <strong data-label=""></strong>? The activation will allow participants to receive reward points when voting and will also grant all eligible points for participants who have already voted so far. The process will take a while.{% endblocktrans %}
559-
{% trans 'Activate reward points' as action_text %}
560-
{% include 'confirmation_modal.html' with modal_id='activateRewardPointsModal' title=title question=question action_text=action_text btn_type='primary' %}
561-
<script type="text/javascript">
562-
function activateRewardPointsModalAction() {
563-
document.getElementById("form_activation_status").requestSubmit();
564-
}
565-
</script>
566575
{% endblock %}
567576

568577
{% block additional_javascript %}

0 commit comments

Comments
 (0)