1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- (function()
- {
- angular.module('appSdk')
- .factory('GroupsBusiness', ['GroupsDataAccess', '$q', 'DataShareBusiness', function (GroupsDataAccess, $q, DataShareBusiness) {
-
- var Business = {};
-
- Business.makeParents = function(group)
- {
- if (group.Groups != null) {
- group.Groups.forEach(function (g) {
- g.Parent = group;
- Business.makeParents(g);
- });
- }
- };
-
- Business.getAll = function(promise)
- {
- var defer = $q.defer();
-
- GroupsDataAccess.getAll(promise).then(function(data)
- {
- data.forEach(function(group)
- {
- Business.makeParents(group);
- group.parent = null;
- });
- defer.resolve(data);
- }, defer.reject);
-
- return defer.promise;
- };
-
- Business.loadAll = function(promise)
- {
- var defer = $q.defer();
-
- Business.getAll(promise).then(function(data)
- {
- DataShareBusiness.Groups = data;
- defer.resolve(data);
- }, defer.reject);
-
- return defer.promise;
- };
-
- return Business;
- }]);
- })();
|