0010190: Add exceptionhandler to calendar
authorAlexander Stintzing <a.stintzing@metaways.de>
Fri, 29 Aug 2014 11:52:01 +0000 (13:52 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 3 Sep 2014 11:12:04 +0000 (13:12 +0200)
Add exceptionhandler to calendar in JS

https://forge.tine20.org/mantisbt/view.php?id=10190

Change-Id: I806ebb0b7e043bac6255c4f133de513113770ac8
Reviewed-on: http://gerrit.tine20.com/customers/1070
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Calendar/Calendar.jsb2
tine20/Calendar/Exception.php [new file with mode: 0644]
tine20/Calendar/js/Calendar.js
tine20/Calendar/js/ExceptionHandler.js [new file with mode: 0644]

index bf39041..837c81b 100644 (file)
           "path": "js/"
         },
         {
+          "text": "ExceptionHandler.js",
+          "path": "js/"
+        },
+        {
           "text": "PagingToolbar.js",
           "path": "js/"
         },
       ]
     }
   ]
-}
\ No newline at end of file
+}
diff --git a/tine20/Calendar/Exception.php b/tine20/Calendar/Exception.php
new file mode 100644 (file)
index 0000000..a076740
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+/**
+ * Tine 2.0
+ *
+ * @package     Calendar
+ * @subpackage  Exception
+ * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
+ * @copyright   Copyright (c) 2014 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @author      Alexander Stintzing <a.stintzing@metaways.de>
+ *
+ */
+
+/**
+ * General Calendar Exception
+ *
+ * @package     Calendar
+ * @subpackage  Exception
+ */
+class Calendar_Exception extends Tinebase_Exception
+{
+}
\ No newline at end of file
index e4e43b2..b7ec3e1 100644 (file)
@@ -114,5 +114,3 @@ Ext.extend(Tine.Calendar.MainScreen, Tine.widgets.MainScreen, {
         Tine.Tinebase.MainScreen.setActiveToolbar(this.actionToolbar, true);
     }
 });
-
-Tine.Calendar.handleRequestException = Tine.Tinebase.ExceptionHandler.handleRequestException;
diff --git a/tine20/Calendar/js/ExceptionHandler.js b/tine20/Calendar/js/ExceptionHandler.js
new file mode 100644 (file)
index 0000000..b5595ea
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Tine 2.0
+ * 
+ * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
+ * @author      Alexander Stintzing <a.stintzing@metaways.de>
+ * @copyright   Copyright (c) 2014 Metaways Infosystems GmbH (http://www.metaways.de)
+ */
+Ext.ns('Tine.Calendar');
+
+/**
+ * @namespace   Tine.Calendar
+ * @class       Tine.Calendar.ExceptionHandler
+ * 
+ * <p>Exception Handler for Calendar</p>
+ * 
+ * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
+ * @author      Alexander Stintzing <a.stintzing@metaways.de>
+ */
+
+Tine.Calendar.handleRequestException = function(exception, callback, callbackScope) {
+    if (! exception.code && exception.responseText) {
+        // we need to decode the exception first
+        var response = Ext.util.JSON.decode(exception.responseText);
+        exception = response.data;
+    }
+    
+    var app = Tine.Tinebase.appMgr.get('Calendar');
+    
+    var defaults = {
+        buttons: Ext.Msg.OK,
+        icon: Ext.MessageBox.ERROR,
+        fn: callback,
+        scope: callbackScope,
+        title: app.i18n._(exception.title),
+        msg: app.i18n._(exception.message)
+    };
+    
+    Tine.log.warn('Request exception :');
+    Tine.log.warn(exception);
+
+    switch(exception.code) {
+        case 911: // Calendar_Exception_InvalidUrl
+            Ext.MessageBox.show(defaults);
+            break;
+        // return false will the generic exceptionhandler handle the caught exception
+        default:
+            return false;
+    }
+    
+    return true;
+}
+
+Tine.Tinebase.ExceptionHandlerRegistry.register('Calendar', Tine.Calendar.handleRequestException);
\ No newline at end of file