(function (angular, $, _) {
angular.module('crmUtil', []);
+ angular.module('crmUtil').factory('crmApi', function($q) {
+ return function(entity, action, params, message) {
+ // JSON serialization in CRM.api3 is not aware of Angular metadata like $$hash, so use angular.toJson()
+ var deferred = $q.defer();
+ var p;
+ if (_.isObject(entity)) {
+ p = CRM.api3(eval('('+angular.toJson(entity)+')'), message);
+ } else {
+ p = CRM.api3(entity, action, eval('('+angular.toJson(params)+')'), message);
+ }
+ // CRM.api3 returns a promise, but the promise doesn't really represent errors as errors, so we
+ // convert them
+ p.then(
+ function(result) {
+ if (result.is_error) {
+ deferred.reject(result);
+ } else {
+ deferred.resolve(result);
+ }
+ },
+ function(error) {
+ deferred.reject(error);
+ }
+ );
+ return deferred.promise;
+ };
+ });
+
+ angular.module('crmUtil').factory('crmLegacy', function() {
+ return CRM;
+ });
+
// example: scope.$watch('foo', crmLog.wrap(function(newValue, oldValue){ ... }));
angular.module('crmUtil').factory('crmLog', function(){
var level = 0;
return crmLog;
});
+ angular.module('crmUtil').factory('crmNavigator', ['$window', function($window) {
+ return {
+ redirect: function(path) {
+ $window.location.href = path;
+ }
+ };
+ }]);
+
angular.module('crmUtil').factory('crmNow', function($q){
// FIXME: surely there's already some helper which can do this in one line?
// @return string "YYYY-MM-DD hh:mm:ss"
(function(angular, CRM) {
+ // crmApp is the default application which aggregates all known modules.
+ // crmApp should not provide any significant services, and no other
+ // modules should depend on it.
var crmApp = angular.module('crmApp', CRM.angular.modules);
crmApp.config(['$routeProvider',
function($routeProvider) {
});
}
]);
- crmApp.factory('crmApi', function($q) {
- return function(entity, action, params, message) {
- // JSON serialization in CRM.api3 is not aware of Angular metadata like $$hash, so use angular.toJson()
- var deferred = $q.defer();
- var p;
- if (_.isObject(entity)) {
- p = CRM.api3(eval('('+angular.toJson(entity)+')'), message);
- } else {
- p = CRM.api3(entity, action, eval('('+angular.toJson(params)+')'), message);
- }
- // CRM.api3 returns a promise, but the promise doesn't really represent errors as errors, so we
- // convert them
- p.then(
- function(result) {
- if (result.is_error) {
- deferred.reject(result);
- } else {
- deferred.resolve(result);
- }
- },
- function(error) {
- deferred.reject(error);
- }
- );
- return deferred.promise;
- };
- });
- crmApp.factory('crmLegacy', function() {
- return CRM;
- });
- crmApp.factory('crmNavigator', ['$window', function($window) {
- return {
- redirect: function(path) {
- $window.location.href = path;
- }
- };
- }]);
})(angular, CRM);
return CRM.resourceUrls['civicrm'] + '/partials/crmCaseType/' + relPath;
};
- var crmCaseType = angular.module('crmCaseType', ['ngRoute', 'ui.utils', 'crmUi', 'unsavedChanges', 'crmApp']);
+ var crmCaseType = angular.module('crmCaseType', ['ngRoute', 'ui.utils', 'crmUi', 'unsavedChanges', 'crmUtil']);
// Note: This template will be passed to cloneDeep(), so don't put any funny stuff in here!
var newCaseTypeTemplate = {
};
angular.module('crmMailing', [
- 'crmUtil', 'crmAttachment', 'ngRoute', 'ui.utils', 'crmUi', 'dialogService', 'crmApp'
+ 'crmUtil', 'crmAttachment', 'ngRoute', 'ui.utils', 'crmUi', 'dialogService'
]); // TODO ngSanitize, unsavedChanges
// Time to wait before triggering AJAX update to recipients list
'unsavedChanges',
'angularFileUpload',
'dialogService',
- 'crmApp',
'crmAttachment',
'crmUi',
'crmUtil',
describe('crmMailing', function() {
beforeEach(function() {
- module('crmApp');
+ module('crmUtil');
module('crmMailing');
});