1 (function(angular
, CRM
) {
2 var crmApp
= angular
.module('crmApp', CRM
.angular
.modules
);
3 crmApp
.config(['$routeProvider',
4 function($routeProvider
) {
5 $routeProvider
.otherwise({
6 template
: ts('Unknown path')
10 crmApp
.factory('crmApi', function($q
) {
11 return function(entity
, action
, params
, message
) {
12 // JSON serialization in CRM.api3 is not aware of Angular metadata like $$hash, so use angular.toJson()
13 var deferred
= $q
.defer();
15 if (_
.isObject(entity
)) {
16 p
= CRM
.api3(eval('('+angular
.toJson(entity
)+')'), message
);
18 p
= CRM
.api3(entity
, action
, eval('('+angular
.toJson(params
)+')'), message
);
20 // CRM.api3 returns a promise, but the promise doesn't really represent errors as errors, so we
24 if (result
.is_error
) {
25 deferred
.reject(result
);
27 deferred
.resolve(result
);
31 deferred
.reject(error
);
34 return deferred
.promise
;
37 crmApp
.factory('crmLegacy', function() {
40 crmApp
.factory('crmNavigator', ['$window', function($window
) {
42 redirect: function(path
) {
43 $window
.location
.href
= path
;