You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GroupsBusiness.js 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. (function()
  2. {
  3. angular.module('appSdk')
  4. .factory('GroupsBusiness', ['GroupsDataAccess', '$q', 'DataShareBusiness', function (GroupsDataAccess, $q, DataShareBusiness) {
  5. var Business = {};
  6. Business.makeParents = function(group)
  7. {
  8. if (group.Groups != null) {
  9. group.Groups.forEach(function (g) {
  10. g.Parent = group;
  11. Business.makeParents(g);
  12. });
  13. }
  14. };
  15. Business.getAll = function(promise)
  16. {
  17. var defer = $q.defer();
  18. GroupsDataAccess.getAll(promise).then(function(data)
  19. {
  20. data.forEach(function(group)
  21. {
  22. Business.makeParents(group);
  23. group.parent = null;
  24. });
  25. defer.resolve(data);
  26. }, defer.reject);
  27. return defer.promise;
  28. };
  29. Business.loadAll = function(promise)
  30. {
  31. var defer = $q.defer();
  32. Business.getAll(promise).then(function(data)
  33. {
  34. DataShareBusiness.Groups = data;
  35. defer.resolve(data);
  36. }, defer.reject);
  37. return defer.promise;
  38. };
  39. return Business;
  40. }]);
  41. })();