CRM-15578 - crmMailingAB2 - Implement joint composition screen (for "Subject" and...
[civicrm-core.git] / js / angular-crm-util.js
index 4e6decf8268723c93bf2d2b0289878d60b9592a9..e0b296fdd51b3228ee54badf2006f054e1273600 100644 (file)
@@ -2,6 +2,14 @@
 (function (angular, $, _) {
   angular.module('crmUtil', []);
 
+  // Adapter for CRM.status which supports Angular promises (instead of jQuery promises)
+  // example: crmStatus('Saving', crmApi(...)).then(function(result){...})
+  angular.module('crmUtil').factory('crmStatus', function($q){
+    return function(options, aPromise){
+      return CRM.toAPromise($q, CRM.status(options, CRM.toJqPromise(aPromise)));
+    };
+  });
+
   // crmWatcher allows one to setup event listeners and temporarily suspend
   // them en masse.
   //