// usage:
// crmApi('Entity', 'action', {...}).then(function(apiResult){...})
-
+ //
// Note: To mock API results in unit-tests, override crmApi.backend, e.g.
+ // var apiSpy = jasmine.createSpy('crmApi');
// crmApi.backend = apiSpy.and.returnValue(crmApi.val({
// is_error: 1
// }));
});
// Controller for the "Recipients: Edit Options" dialog
- // Note: Expects $scope.model to be a mailing object.
+ // Note: Expects $scope.model to be an object with properties:
+ // - "mailing" (APIv3 mailing object)
+ // - "fields" (list of fields)
angular.module('crmMailing').controller('EditRecipOptionsDialogCtrl', function EditRecipOptionsDialogCtrl($scope) {
$scope.ts = CRM.ts(null);
});
expect(fields.id.title).toBe('My entity ID');
expect(apiSpy.calls.count()).toBe(1);
- // call a second time, but now the data is cached cached
+ // call a second time, but now the data is cached
$q.when(crmMetadata.getFields('MyEntity')).then(
function(fields) {
expect(fields.id.title).toBe('My entity ID');
expect(apiSpy.calls.count()).toBe(1);
- // third call
+ // call a third time using a diff interface; data is still cached!
$q.when(crmMetadata.getField('MyEntity', 'id')).then(
function(field) {
expect(field.title).toBe('My entity ID');