Skip to content

Commit

Permalink
Move submit modal dialog error message from progress bar to alert box
Browse files Browse the repository at this point in the history
In the submit modal dialog in chapters, the error message
was displayed inside a progress bar. That was not a good idea
since it was hard to read and the latter half of the message
disappeared since it did not fit into the progress bar. The
error message is now moved to a separate alert box above
the progress bar.
  • Loading branch information
ihalaij1 authored and markkuriekkinen committed Jun 30, 2023
1 parent 91f9875 commit 339be66
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
10 changes: 7 additions & 3 deletions assets/js/aplus.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ $(function() {
var defaults = {
loader_selector: ".modal-progress",
loader_text_selector: ".progress-bar",
alert_text_selector: ".modal-submit-error",
title_selector: ".modal-title",
content_selector: ".modal-body",
error_message_attribute: "data-msg-error",
Expand All @@ -382,6 +383,7 @@ $(function() {
init: function() {
this.loader = this.element.find(this.settings.loader_selector);
this.loaderText = this.loader.find(this.settings.loader_text_selector);
this.alertText = this.loader.find(this.settings.alert_text_selector);
this.title = this.element.find(this.settings.title_selector);
this.content = this.element.find(this.settings.content_selector);
this.messages = {
Expand All @@ -407,6 +409,7 @@ $(function() {
open: function(data) {
this.title.hide();
this.content.hide();
this.alertText.hide();
this.loaderText
.removeClass('progress-bar-danger').addClass('active')
.text(data || this.messages.loading);
Expand All @@ -418,9 +421,10 @@ $(function() {
},

showError: function(data) {
this.loaderText
.removeClass('active').addClass('progress-bar-danger')
.text(data || this.messages.error);
if (data) {
this.alertText.text(data).show();
}
this.loaderText.removeClass('active').addClass('progress-bar-danger').text(this.messages.error);
},

showContent: function(data) {
Expand Down
15 changes: 9 additions & 6 deletions edit_course/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ def test_course_clone(self):
'key_month': 'Test',
}, follow=True)
self.assertEqual(response.status_code, 200)
self.assertNotContains(response, "alert alert-danger")
self.assertContains(response, "alert alert-success")
stripped_content = response.content.decode("utf-8").replace("modal-submit-error alert alert-danger", "")
self.assertNotIn("alert alert-danger", stripped_content)
self.assertIn("alert alert-success", stripped_content)

# Partial clone
response = self.client.post(url, {
Expand All @@ -48,8 +49,9 @@ def test_course_clone(self):
'key_month': 'Test',
}, follow=True)
self.assertEqual(response.status_code, 200)
self.assertNotContains(response, "alert alert-danger")
self.assertContains(response, "alert alert-success")
stripped_content = response.content.decode("utf-8").replace("modal-submit-error alert alert-danger", "")
self.assertNotIn("alert alert-danger", stripped_content)
self.assertIn("alert alert-success", stripped_content)

instance = CourseInstance.objects.get(id=1)
self.assertEqual(instance.url, instance_url)
Expand Down Expand Up @@ -104,8 +106,9 @@ def test_clone_from_sis(self):
'sis': '123',
}, follow=True)
self.assertEqual(response.status_code, 200)
self.assertNotContains(response, "alert alert-danger")
self.assertContains(response, "alert alert-success")
stripped_content = response.content.decode("utf-8").replace("modal-submit-error alert alert-danger", "")
self.assertNotIn("alert alert-danger", stripped_content)
self.assertIn("alert alert-success", stripped_content)

# The asserted values are coming from in sis_test.py
sis_instance = CourseInstance.objects.get(course=instance.course, url="sis-test")
Expand Down
2 changes: 1 addition & 1 deletion locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -3842,7 +3842,7 @@ msgid "TOTAL_NUMBER_OF_SUBMITTERS"
msgstr "Total number of submitters"

#: exercise/templates/exercise/_exercise_wait.html
#: exercise/templates/exercise/exercise.html
#: exercise/templates/exercise/exercise.html templates/base.html
msgid "EXERCISE_ERROR_COMMUNICATION"
msgstr ""
"There was a problem loading the assignment. Try loading the page again "
Expand Down
2 changes: 1 addition & 1 deletion locale/fi/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -3849,7 +3849,7 @@ msgid "TOTAL_NUMBER_OF_SUBMITTERS"
msgstr "Palauttaneita opiskelijoita yhteensä"

#: exercise/templates/exercise/_exercise_wait.html
#: exercise/templates/exercise/exercise.html
#: exercise/templates/exercise/exercise.html templates/base.html
msgid "EXERCISE_ERROR_COMMUNICATION"
msgstr ""
"Tehtävän lataaminen epäonnistui. Yritä uudelleen myöhemmin. "
Expand Down
3 changes: 3 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ <h4>{% translate "SITE" %}</h4>
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-progress">
<div class="modal-submit-error alert alert-danger" style="display:none">
{% translate "EXERCISE_ERROR_COMMUNICATION" %}
</div>
<div class="progress">
<div class="progress-bar progress-bar-striped active" role="progressbar" style="width:100%"
data-msg-error="{% translate 'LOADING_FAILED' %}">
Expand Down

0 comments on commit 339be66

Please sign in to comment.