From 8210d2af0e4728c7627dc9e26bea6e5a8942ea55 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Thu, 12 Oct 2017 15:50:31 +0200
Subject: [PATCH] when there is an error during saving daily planning there is
 popup with info

---
 smash/web/static/js/daily_planning.js |  2 ++
 smash/web/static/js/smash.js          | 23 ++++++++++++++++++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/smash/web/static/js/daily_planning.js b/smash/web/static/js/daily_planning.js
index 7462569b..5d201b60 100644
--- a/smash/web/static/js/daily_planning.js
+++ b/smash/web/static/js/daily_planning.js
@@ -217,6 +217,8 @@ $(document).ready(function () {
 
                         console.log(data);
                         saveButton.css('border-color', 'red');
+                        showErrorInfo("There was an unexpected problem with saving data. " +
+                            "Please contact administrators.");
                         setTimeout(function () {
                             saveButton.delay(200).css('border-color', currentBorder);
                         }, 200);
diff --git a/smash/web/static/js/smash.js b/smash/web/static/js/smash.js
index 6c08a856..3bfb6789 100644
--- a/smash/web/static/js/smash.js
+++ b/smash/web/static/js/smash.js
@@ -24,6 +24,7 @@ $(document).ready(function () {
             return true;
         }
     })
+
 });
 
 $.ajaxSetup({
@@ -49,4 +50,24 @@ $.ajaxSetup({
             xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
         }
     }
-});
\ No newline at end of file
+});
+
+function showErrorInfo(content) {
+    var errorDialogDiv = document.createElement("div");
+    document.body.appendChild(errorDialogDiv);
+    errorDialogDiv.innerHTML = '<div class="modal-dialog" role="document">' +
+        '<div class="modal-content">' +
+        '<div class="modal-header">ERROR' +
+        '<button type="button" class="close" data-dismiss="modal" aria-label="Close">' +
+        '<span aria-hidden="true">&times;</span></button>' +
+        '</div>' +
+        '<div name="error-content" class="modal-body">' + content + '</div>' +
+        '<div class="modal-footer">' +
+        '<button type="button" class="btn btn-outline pull-right" data-dismiss="modal">Close</button>' +
+        '</div>' +
+        '</div>' +
+        '</div>';
+    $(errorDialogDiv).attr("role", "dialog");
+    $(errorDialogDiv).addClass("modal modal-danger fade");
+    $(errorDialogDiv).modal("show");
+}
\ No newline at end of file
-- 
GitLab