promise versions of record proxy fns
authorCornelius Weiß <c.weiss@metaways.de>
Mon, 17 Jul 2017 18:31:17 +0000 (20:31 +0200)
committerCornelius Weiss <c.weiss@metaways.de>
Mon, 17 Jul 2017 18:34:49 +0000 (20:34 +0200)
Change-Id: I0777044ec010df19c0502fdd7302192cdda84d8d
Reviewed-on: http://gerrit.tine20.com/customers/5225
Reviewed-by: Cornelius Weiss <c.weiss@metaways.de>
Tested-by: Cornelius Weiss <c.weiss@metaways.de>
tine20/Calendar/js/Model.js
tine20/Tinebase/js/data/RecordProxy.js

index d3523f3..57b86d0 100644 (file)
@@ -446,7 +446,27 @@ Tine.Calendar.Model.EventJsonBackend = Ext.extend(Tine.Tinebase.data.RecordProxy
         
         return this.doXHTTPRequest(options);
     },
-    
+
+    promiseCreateRecurException: function(event, deleteInstance, deleteAllFollowing, checkBusyConflicts, options) {
+        var me = this;
+        return new Promise(function (fulfill, reject) {
+            try {
+                me.createRecurException(event, deleteInstance, deleteAllFollowing, checkBusyConflicts, Ext.apply(options || {}, {
+                    success: function (r) {
+                        fulfill(r);
+                    },
+                    failure: function (error) {
+                        reject(new Error(error));
+                    }
+                }));
+            } catch (error) {
+                if (Ext.isFunction(reject)) {
+                    reject(new Error(options));
+                }
+            }
+        });
+    },
+
     /**
      * delete a recuring event series
      * 
index 1bb022a..a57c8fc 100644 (file)
@@ -153,7 +153,27 @@ Ext.extend(Tine.Tinebase.data.RecordProxy, Ext.data.DataProxy, {
         
         return this.doXHTTPRequest(options);
     },
-    
+
+    promiseLoadRecord: function(record, options) {
+        var me = this;
+        return new Promise(function (fulfill, reject) {
+            try {
+                me.loadRecord(record, Ext.apply(options || {}, {
+                    success: function (r) {
+                        fulfill(r);
+                    },
+                    failure: function (error) {
+                        reject(new Error(error));
+                    }
+                }));
+            } catch (error) {
+                if (Ext.isFunction(reject)) {
+                    reject(new Error(options));
+                }
+            }
+        });
+    },
+
     /**
      * searches all (lightweight) records matching filter
      * 
@@ -213,7 +233,27 @@ Ext.extend(Tine.Tinebase.data.RecordProxy, Ext.data.DataProxy, {
         
         return this.doXHTTPRequest(options);
     },
-    
+
+    promiseSaveRecord: function(record, options, additionalArguments) {
+        var me = this;
+        return new Promise(function (fulfill, reject) {
+            try {
+                me.saveRecord(record, Ext.apply(options || {}, {
+                    success: function (r) {
+                        fulfill(r);
+                    },
+                    failure: function (error) {
+                        reject(new Error(error));
+                    }
+                }), additionalArguments);
+            } catch (error) {
+                if (Ext.isFunction(reject)) {
+                    reject(new Error(options));
+                }
+            }
+        });
+    },
+
     /**
      * deletes multiple records identified by their ids
      *