Преглед изворни кода

[desktop] Display document api errors

Erick Tryzelaar пре 10 година
родитељ
комит
69933a5

+ 8 - 3
desktop/core/src/desktop/static/desktop/js/share.vm.js

@@ -32,9 +32,10 @@ function ShareViewModel(updateDocF) {
 
   self.setDocId = function(docId) {
     if (docId == -1) { return false; }
-    $.get('/desktop/api/doc/get', { id : docId },
-      function (data) {
-        shareViewModel.selectedDoc(data)
+    $.get('/desktop/api/doc/get', { id : docId }, function (data) {
+      shareViewModel.selectedDoc(data)
+    }).fail(function (response) {
+      $(document).trigger("error", "There was an error processing your action: " + response.responseText);
     });
   }
 }
@@ -146,6 +147,8 @@ function setupSharing(id, updateFunc) {
       if (typeof id == "function"){
         id();
       }
+    }).fail(function (response) {
+      $(document).trigger("error", "There was an error processing your action: " + response.responseText);
     });
 
     $("#documentShareAddBtn").on("click", function () {
@@ -248,5 +251,7 @@ function shareDocFinal() {
         shareViewModel.updateDoc(response.doc);
       }
     }
+  }).fail(function (response) {
+    $(document).trigger("error", "There was an error processing your action: " + response.responseText);
   });
 }

+ 7 - 3
desktop/core/src/desktop/templates/home.mako

@@ -387,7 +387,7 @@ ${ commonshare() | n,unicode }
         $(document).trigger("info", "${_('Project created')}");
         $("#addTagModal").modal("hide");
       }).fail(function (xhr, textStatus, errorThrown) {
-        $(document).trigger("error", xhr.responseText); // reserved name, duplicate etc
+        $(document).trigger("error", "${_("There was an error processing your action: ")}" + xhr.responseText); // reserved name, duplicate etc
       });
     });
 
@@ -424,6 +424,8 @@ ${ commonshare() | n,unicode }
           $(document).trigger("error", "${_("There was an error processing your action: ")}" + response.message);
         }
       }
+    }).fail(function (response) {
+      $(document).trigger("error", "${_("There was an error processing your action: ")}" + response.responseText);
     });
   }
 
@@ -444,7 +446,7 @@ ${ commonshare() | n,unicode }
         tag_ids: [tag.id()]
       })
     }, function (response) {
-      if (response != null){
+      if (response != null) {
         if (response.status != 0) {
           $(document).trigger("error", "${_("There was an error processing your action: ")}" + response.message);
         }
@@ -454,7 +456,9 @@ ${ commonshare() | n,unicode }
         }
       }
       $("#documentMoveModal").modal("hide");
-    })
+    }).fail(function (response) {
+      $(document).trigger("error", "${_("There was an error processing your action: ")}" + response.responseText);
+    });
   }
 
 </script>