Ver código fonte

new lu busy business

tags/v0.1.1
Robin Thoni 8 anos atrás
pai
commit
66c1a074e2

+ 1
- 1
dist/luticate-utils.min.js Ver arquivo

@@ -1 +1 @@
1
-!function(){angular.module("luticate2Utils",[])}(),function(){"use strict";angular.module("luticate2Utils").factory("luBusiness",[function(){var a={};return a.create=function(){var a={};return a},a}])}(),function(){"use strict";angular.module("luticate2Utils").factory("luBusyBusiness",[function(){var a={};return a.promises={},a.loaders=[],a.errors=[],a.STATUS_RUNNING=0,a.STATUS_RESOLVED=1,a.STATUS_REJECTED=2,a.build=function(b){a[b]={};for(var c in a.promises)if(a.promises.hasOwnProperty(c)){var d=a.promises[c];d[b].forEach(function(c){null==a[b][c]&&(a[b][c]=[]),a[b][c].push(d)})}},a.newPromise=function(a,b,c,d){return{id:a,groups:b,loaderGroups:c,errorGroups:d}},a.initLuBusy=function(b){var c={loaders:[],errors:[],status:a.STATUS_RUNNING,id:b.id};b.groups instanceof Array?b.groups.forEach(function(a){c.loaders.push(a),c.errors.push(a)}):"string"==typeof b.groups&&(c.loaders.push(b.groups),c.errors.push(b.groups)),b.loaderGroups instanceof Array?b.loaderGroups.forEach(function(a){c.loaders.push(a)}):"string"==typeof b.loaderGroups&&c.loaders.push(b.loaderGroups),b.errorGroups instanceof Array?b.errorGroups.forEach(function(a){c.errors.push(a)}):"string"==typeof b.errorGroups&&c.errors.push(b.errorGroups),a.promises[b.id]=c,a.build("loaders"),a.build("errors")},a.getLoadersGroup=function(b){return null==a.loaders[b]?null:a.loaders[b]},a.getErrorsGroup=function(b){return null==a.errors[b]?null:a.errors[b]},a.reject=function(b,c){a.promises[b.id].status=a.STATUS_REJECTED,a.promises[b.id].value=c},a.resolve=function(b){a.promises[b.id].status=a.STATUS_RESOLVED,a.promises[b.id].value=null},a}])}(),function(){"use strict";angular.module("luticate2Utils").factory("luWebApiCrudBusiness",["luBusiness","luWebApiDataAccess",function(a,b){var c={};return c.create=function(b){var c=a.create();return c.dataAccess=b,c.getSingleById=function(a,b){return c.dataAccess.getSingleById(a,b)},c.getMultiple=function(a,b,d,e,f){return c.dataAccess.getMultiple(a,b,d,e,f)},c.addDbo=function(a,b){return c.dataAccess.addDbo(a,b)},c.editSingleByIdDbo=function(a,b,d){return c.dataAccess.editSingleByIdDbo(a,b,d)},c.deleteDbo=function(a,b){return c.dataAccess.deleteDbo(a,b)},c},c}])}(),function(){"use strict";angular.module("luticate2Utils").factory("luDataAccess",[function(){var a={};return a.create=function(){var a={};return a},a}])}(),function(){"use strict";angular.module("luticate2Utils").factory("luRequest",["$q","$http","luBusyBusiness",function(a,b,c){function d(a,b,d,e){var f={data:b,status:d};a.reject(f),null!=e&&c.reject(e,f)}function e(a,b,d){a.resolve(b),null!=d&&c.resolve(d)}var f={};return f.get=function(a,b,c){return f.request(a,"GET",b,null,c)},f.post=function(a,b,c,d){return f.request(a,"POST",b,c,d)},f.put=function(a,b,c,d){return f.request(a,"PUT",b,c,d)},f["delete"]=function(a,b,c,d){return f.request(a,"DELETE",b,c,d)},f.request=function(f,g,h,i,j){null!=j&&c.initLuBusy(j);var k=a.defer();f=f.replace(/\/+$/,"");var l={url:f,method:g,params:h,data:JSON.stringify(i),headers:{"Content-Type":"application/json"}};return b(l).then(function(a){var b=a.data,c=a.status;null==b||"object"!=typeof b?d(k,{message:"Failed to parse response",code:c},c,j):null!=b.message?d(k,b,c,j):e(k,b.data,j)},function(a){var b=a.data,c=a.status;null==b||"object"!=typeof b?d(k,{message:"Failed to parse response",code:c},c,j):d(k,b,c,j)}),k.promise},f}])}(),function(){"use strict";angular.module("luticate2Utils").factory("luWebApiCrudDataAccess",["luWebApiDataAccess",function(a){var b={};return b.create=function(b){var c=a.create(b);return c.getSingleById=function(a,b){return c.get(a,null,b)},c.getMultiple=function(a,b,d,e,f){return c.get("",{orderBy:a,filter:b,page:d,perPage:e},f)},c.addDbo=function(a,b){return c.post("",null,a,b)},c.editSingleByIdDbo=function(a,b,d){return c.post(a,null,b,d)},c.deleteDbo=function(a,b){return c["delete"](a,null,null,b)},c},b}])}(),function(){"use strict";angular.module("luticate2Utils").factory("luWebApiDataAccess",["luDataAccess","luRequest",function(a,b){var c={};return c.create=function(c){var d=a.create();return d.entry_point=c,"/"!==d.entry_point.substr(-1)&&(d.entry_point+="/"),d.get=function(a,c,e){return b.get(d.entry_point+a,c,e)},d.post=function(a,c,e,f){return b.post(d.entry_point+a,c,e,f)},d.put=function(a,c,e,f){return b.put(d.entry_point+a,c,e,f)},d["delete"]=function(a,c,e,f){return b["delete"](d.entry_point+a,c,e,f)},d},c}])}();
1
+!function(){angular.module("luticate2Utils",[])}(),function(){"use strict";angular.module("luticate2Utils").factory("luBusiness",[function(){var a={};return a.create=function(){var a={};return a},a}])}(),function(){"use strict";angular.module("luticate2Utils").factory("luBusyBusiness",["$q",function(a){var b={};return b.groups=null,b.initGroups=function(c){"string"==typeof c&&(c=[c]);for(var d=0;d<c.length;++d){var e=b.groups[c[d]];null==e&&(e={count:0,deferred:null,errors:[]},b.groups[c[d]]=e),0==e.count&&(e.deferred=a.defer(),e.errors=[]),++e.count}},b.isRunning=function(a){var c=b.groups[a];return null!=c?c.count>0:!1},b.promise=function(a){var c=b.groups[a];return null!=c&&null!=c.deferred?c.deferred.promise:null},b.hasError=function(a){var c=b.groups[a];return null!=c?0!=c.errors.length:null},b.errors=function(a){var c=b.groups[a];return null!=c?c.errors:null},b.resolve=function(a){"string"==typeof a&&(a=[a]);for(var c=0;c<a.length;++c){var d=b.groups[a[c]];--d.count,0==d.count&&(b.hasError(d)?d.deferred.resolve(null):d.deferred.resolve(null),d.deferred=null)}},b.reject=function(a,c){"string"==typeof a&&(a=[a]);for(var d=0;d<a.length;++d){var e=b.groups[a[d]];--e.count,e.errors.push(c),0==e.count&&(e.deferred.resolve(null),e.deferred=null)}},b.reset=function(){return b.groups={},b},b}])}(),function(){"use strict";angular.module("luticate2Utils").factory("luWebApiCrudBusiness",["luBusiness","luWebApiDataAccess",function(a,b){var c={};return c.create=function(b){var c=a.create();return c.dataAccess=b,c.getSingleById=function(a,b){return c.dataAccess.getSingleById(a,b)},c.getMultiple=function(a,b,d,e,f){return c.dataAccess.getMultiple(a,b,d,e,f)},c.addDbo=function(a,b){return c.dataAccess.addDbo(a,b)},c.editSingleByIdDbo=function(a,b,d){return c.dataAccess.editSingleByIdDbo(a,b,d)},c.deleteDbo=function(a,b){return c.dataAccess.deleteDbo(a,b)},c},c}])}(),function(){"use strict";angular.module("luticate2Utils").factory("luDataAccess",[function(){var a={};return a.create=function(){var a={};return a},a}])}(),function(){"use strict";angular.module("luticate2Utils").factory("luRequest",["$q","$http","luBusyBusiness",function(a,b,c){function d(a,b,d,e){var f={data:b,status:d};a.reject(f),null!=e&&c.reject(e,f)}function e(a,b,d){a.resolve(b),null!=d&&c.resolve(d)}var f={};return f.get=function(a,b,c){return f.request(a,"GET",b,null,c)},f.post=function(a,b,c,d){return f.request(a,"POST",b,c,d)},f.put=function(a,b,c,d){return f.request(a,"PUT",b,c,d)},f["delete"]=function(a,b,c,d){return f.request(a,"DELETE",b,c,d)},f.request=function(f,g,h,i,j){null!=j&&c.initGroups(j);var k=a.defer();f=f.replace(/\/+$/,"");var l={url:f,method:g,params:h,data:JSON.stringify(i),headers:{"Content-Type":"application/json"}};return b(l).then(function(a){var b=a.data,c=a.status;null==b||"object"!=typeof b?d(k,{message:"Failed to parse response",code:c},c,j):null!=b.message?d(k,b,c,j):e(k,b.data,j)},function(a){var b=a.data,c=a.status;null==b||"object"!=typeof b?d(k,{message:"Failed to parse response",code:c},c,j):d(k,b,c,j)}),k.promise},f}])}(),function(){"use strict";angular.module("luticate2Utils").factory("luWebApiCrudDataAccess",["luWebApiDataAccess",function(a){var b={};return b.create=function(b){var c=a.create(b);return c.getSingleById=function(a,b){return c.get(a,null,b)},c.getMultiple=function(a,b,d,e,f){return c.get("",{orderBy:a,filter:b,page:d,perPage:e},f)},c.addDbo=function(a,b){return c.post("",null,a,b)},c.editSingleByIdDbo=function(a,b,d){return c.post(a,null,b,d)},c.deleteDbo=function(a,b){return c["delete"](a,null,null,b)},c},b}])}(),function(){"use strict";angular.module("luticate2Utils").factory("luWebApiDataAccess",["luDataAccess","luRequest",function(a,b){var c={};return c.create=function(c){var d=a.create();return d.entry_point=c,"/"!==d.entry_point.substr(-1)&&(d.entry_point+="/"),d.get=function(a,c,e){return b.get(d.entry_point+a,c,e)},d.post=function(a,c,e,f){return b.post(d.entry_point+a,c,e,f)},d.put=function(a,c,e,f){return b.put(d.entry_point+a,c,e,f)},d["delete"]=function(a,c,e,f){return b["delete"](d.entry_point+a,c,e,f)},d},c}])}();

+ 83
- 77
src/Business/lu-busy-business.js Ver arquivo

@@ -5,107 +5,113 @@
5 5
 (function () {
6 6
     'use strict';
7 7
     angular.module('luticate2Utils')
8
-        .factory('luBusyBusiness', [function() {
8
+        .factory('luBusyBusiness', ['$q', function($q) {
9 9
 
10 10
             var luBusyBusiness = {};
11
-            luBusyBusiness.promises = {};
12
-            luBusyBusiness.loaders = [];
13
-            luBusyBusiness.errors = [];
14 11
 
15
-            luBusyBusiness.STATUS_RUNNING = 0;
16
-            luBusyBusiness.STATUS_RESOLVED = 1;
17
-            luBusyBusiness.STATUS_REJECTED = 2;
12
+            luBusyBusiness.groups = null;
18 13
 
19
-            luBusyBusiness.build = function(array)
14
+            luBusyBusiness.initGroups = function(groups)
20 15
             {
21
-                luBusyBusiness[array] = {};
22
-                for (var id in luBusyBusiness.promises) {
23
-                    if (luBusyBusiness.promises.hasOwnProperty(id)) {
24
-                        var promise = luBusyBusiness.promises[id];
25
-                        promise[array].forEach(function (group) {
26
-                            if (luBusyBusiness[array][group] == null) {
27
-                                luBusyBusiness[array][group] = [];
28
-                            }
29
-                            luBusyBusiness[array][group].push(promise);
30
-                        });
31
-                    }
16
+                if (typeof groups === 'string') {
17
+                    groups = [groups];
32 18
                 }
33
-            };
34
-
35
-            luBusyBusiness.newPromise = function(id, groups, loaderGroups, errorGroups) {
36
-                return {
37
-                    id: id,
38
-                    groups: groups,
39
-                    loaderGroups: loaderGroups,
40
-                    errorGroups: errorGroups
41
-                };
42
-            };
43 19
 
44
-            luBusyBusiness.initLuBusy = function(data) {
45
-                var p = {
46
-                    loaders : [],
47
-                    errors: [],
48
-                    status: luBusyBusiness.STATUS_RUNNING,
49
-                    id: data.id
50
-                };
20
+                for (var i = 0; i < groups.length; ++i) {
21
+                    var group = luBusyBusiness.groups[groups[i]];
22
+                    if (group == null ) {
23
+                        group = {
24
+                            count: 0,
25
+                            deferred: null,
26
+                            errors: []
27
+                        };
28
+                        luBusyBusiness.groups[groups[i]] = group;
29
+                    }
51 30
 
52
-                if (data.groups instanceof Array) {
53
-                    data.groups.forEach(function (group) {
54
-                        p.loaders.push(group);
55
-                        p.errors.push(group);
56
-                    });
57
-                }
58
-                else if (typeof data.groups === 'string') {
59
-                    p.loaders.push(data.groups);
60
-                    p.errors.push(data.groups);
31
+                    if (group.count == 0) {
32
+                        group.deferred = $q.defer();
33
+                        group.errors = [];
34
+                    }
35
+                    ++group.count;
61 36
                 }
37
+            };
62 38
 
63
-                if (data.loaderGroups instanceof Array) {
64
-                    data.loaderGroups.forEach(function (group) {
65
-                        p.loaders.push(group);
66
-                    });
67
-                }
68
-                else if (typeof data.loaderGroups === 'string') {
69
-                    p.loaders.push(data.loaderGroups);
39
+            luBusyBusiness.isRunning = function(group)
40
+            {
41
+                var data = luBusyBusiness.groups[group];
42
+                if (data != null) {
43
+                    return data.count > 0;
70 44
                 }
45
+                return false;
46
+            };
71 47
 
72
-                if (data.errorGroups instanceof Array) {
73
-                    data.errorGroups.forEach(function (group) {
74
-                        p.errors.push(group);
75
-                    });
76
-                }
77
-                else if (typeof data.errorGroups === 'string') {
78
-                    p.errors.push(data.errorGroups);
48
+            luBusyBusiness.promise = function(group)
49
+            {
50
+                var data = luBusyBusiness.groups[group];
51
+                if (data != null && data.deferred != null) {
52
+                    return data.deferred.promise;
79 53
                 }
54
+                return null;
55
+            };
80 56
 
81
-                luBusyBusiness.promises[data.id] = p;
82
-
83
-                luBusyBusiness.build("loaders");
84
-                luBusyBusiness.build("errors");
57
+            luBusyBusiness.hasError = function(group)
58
+            {
59
+                var data = luBusyBusiness.groups[group];
60
+                if (data != null) {
61
+                    return data.errors.length != 0;
62
+                }
63
+                return null;
85 64
             };
86 65
 
87
-            luBusyBusiness.getLoadersGroup = function(group) {
88
-                if (luBusyBusiness.loaders[group] == null) {
89
-                    return null;
66
+            luBusyBusiness.errors = function(group)
67
+            {
68
+                var data = luBusyBusiness.groups[group];
69
+                if (data != null) {
70
+                    return data.errors;
90 71
                 }
91
-                return luBusyBusiness.loaders[group];
72
+                return null;
92 73
             };
93 74
 
94
-            luBusyBusiness.getErrorsGroup = function(group) {
95
-                if (luBusyBusiness.errors[group] == null) {
96
-                    return null;
75
+            luBusyBusiness.resolve = function(groups)
76
+            {
77
+                if (typeof groups === 'string') {
78
+                    groups = [groups];
79
+                }
80
+                for (var i = 0; i < groups.length; ++i) {
81
+                    var group = luBusyBusiness.groups[groups[i]];
82
+                    --group.count;
83
+                    if (group.count == 0) {
84
+                        if (!luBusyBusiness.hasError(group)) {
85
+                            group.deferred.resolve(null);
86
+                        }
87
+                        else {
88
+                            group.deferred.resolve(null);
89
+                        }
90
+                        group.deferred = null;
91
+                    }
97 92
                 }
98
-                return luBusyBusiness.errors[group];
99 93
             };
100 94
 
101
-            luBusyBusiness.reject = function(promise, error) {
102
-                luBusyBusiness.promises[promise.id].status = luBusyBusiness.STATUS_REJECTED;
103
-                luBusyBusiness.promises[promise.id].value = error;
95
+            luBusyBusiness.reject = function(groups, error)
96
+            {
97
+                if (typeof groups === 'string') {
98
+                    groups = [groups];
99
+                }
100
+                for (var i = 0; i < groups.length; ++i) {
101
+                    var group = luBusyBusiness.groups[groups[i]];
102
+                    --group.count;
103
+                    group.errors.push(error);
104
+                    if (group.count == 0) {
105
+                        group.deferred.resolve(null);
106
+                        group.deferred = null;
107
+                    }
108
+                }
104 109
             };
105 110
 
106
-            luBusyBusiness.resolve = function(promise) {
107
-                luBusyBusiness.promises[promise.id].status = luBusyBusiness.STATUS_RESOLVED;
108
-                luBusyBusiness.promises[promise.id].value = null;
111
+            luBusyBusiness.reset = function()
112
+            {
113
+                luBusyBusiness.groups = {};
114
+                return luBusyBusiness;
109 115
             };
110 116
 
111 117
             return luBusyBusiness;

+ 10
- 10
src/Business/lu-webapi-crud-business.js Ver arquivo

@@ -14,24 +14,24 @@
14 14
 
15 15
                 Business.dataAccess = dataAccess;
16 16
 
17
-                Business.getSingleById = function (id, luBusyDbo) {
18
-                    return Business.dataAccess.getSingleById(id, luBusyDbo);
17
+                Business.getSingleById = function (id, luBusyGroups) {
18
+                    return Business.dataAccess.getSingleById(id, luBusyGroups);
19 19
                 };
20 20
 
21
-                Business.getMultiple = function (orderBy, filter, page, perPage, luBusyDbo) {
22
-                    return Business.dataAccess.getMultiple(orderBy, filter, page, perPage, luBusyDbo);
21
+                Business.getMultiple = function (orderBy, filter, page, perPage, luBusyGroups) {
22
+                    return Business.dataAccess.getMultiple(orderBy, filter, page, perPage, luBusyGroups);
23 23
                 };
24 24
 
25
-                Business.addDbo = function(data, luBusyDbo) {
26
-                    return Business.dataAccess.addDbo(data, luBusyDbo);
25
+                Business.addDbo = function(data, luBusyGroups) {
26
+                    return Business.dataAccess.addDbo(data, luBusyGroups);
27 27
                 };
28 28
 
29
-                Business.editSingleByIdDbo = function(id, data, luBusyDbo) {
30
-                    return Business.dataAccess.editSingleByIdDbo(id, data, luBusyDbo);
29
+                Business.editSingleByIdDbo = function(id, data, luBusyGroups) {
30
+                    return Business.dataAccess.editSingleByIdDbo(id, data, luBusyGroups);
31 31
                 };
32 32
 
33
-                Business.deleteDbo = function(id, luBusyDbo) {
34
-                    return Business.dataAccess.deleteDbo(id, luBusyDbo);
33
+                Business.deleteDbo = function(id, luBusyGroups) {
34
+                    return Business.dataAccess.deleteDbo(id, luBusyGroups);
35 35
                 };
36 36
 
37 37
                 return Business;

+ 25
- 24
src/DataAccess/lu-request.js Ver arquivo

@@ -9,51 +9,52 @@
9 9
 
10 10
             var luRequest = {};
11 11
 
12
-            luRequest.get = function(url, dataGet, luBusyDbo)
12
+            luRequest.get = function(url, dataGet, luBusyGroups)
13 13
             {
14
-                return luRequest.request(url, 'GET', dataGet, null, luBusyDbo);
14
+                return luRequest.request(url, 'GET', dataGet, null, luBusyGroups);
15 15
             };
16 16
 
17
-            luRequest.post = function(url, dataGet, dataPost, luBusyDbo)
17
+            luRequest.post = function(url, dataGet, dataPost, luBusyGroups)
18 18
             {
19
-                return luRequest.request(url, 'POST', dataGet, dataPost, luBusyDbo);
19
+                return luRequest.request(url, 'POST', dataGet, dataPost, luBusyGroups);
20 20
             };
21 21
 
22
-            luRequest.put = function(url, dataGet, dataPost, luBusyDbo)
22
+            luRequest.put = function(url, dataGet, dataPost, luBusyGroups)
23 23
             {
24
-                return luRequest.request(url, 'PUT', dataGet, dataPost, luBusyDbo);
24
+                return luRequest.request(url, 'PUT', dataGet, dataPost, luBusyGroups);
25 25
             };
26 26
 
27
-            luRequest.delete = function(url, dataGet, dataPost, luBusyDbo)
27
+            luRequest.delete = function(url, dataGet, dataPost, luBusyGroups)
28 28
             {
29
-                return luRequest.request(url, 'DELETE', dataGet, dataPost, luBusyDbo);
29
+                return luRequest.request(url, 'DELETE', dataGet, dataPost, luBusyGroups);
30 30
             };
31 31
 
32
-            function reject(deferred, data, status, luBusyDbo)
32
+            function reject(deferred, data, status, luBusyGroups)
33 33
             {
34
-                var obj = {
34
+                var error = {
35 35
                     data: data,
36 36
                     status: status
37 37
                 };
38
-                deferred.reject(obj);
39
-                if (luBusyDbo != null) {
40
-                    luBusyBusiness.reject(luBusyDbo, obj);
38
+                deferred.reject(error);
39
+                if (luBusyGroups != null) {
40
+                    luBusyBusiness.reject(luBusyGroups, error);
41 41
                 }
42 42
             }
43 43
 
44
-            function resolve(deferred, data, luBusyDbo)
44
+            function resolve(deferred, data, luBusyGroups)
45 45
             {
46 46
                 deferred.resolve(data);
47
-                if (luBusyDbo != null) {
48
-                    luBusyBusiness.resolve(luBusyDbo);
47
+                if (luBusyGroups != null) {
48
+                    luBusyBusiness.resolve(luBusyGroups);
49 49
                 }
50 50
             }
51 51
 
52
-            luRequest.request = function(url, method, dataGet, dataPost, luBusyDbo)
52
+            luRequest.request = function(url, method, dataGet, dataPost, luBusyGroups)
53 53
             {
54
-                if (luBusyDbo != null) {
55
-                    luBusyBusiness.initLuBusy(luBusyDbo);
54
+                if (luBusyGroups != null) {
55
+                    luBusyBusiness.initGroups(luBusyGroups);
56 56
                 }
57
+                
57 58
                 var deferred = $q.defer();
58 59
 
59 60
                 url = url.replace(/\/+$/, '');
@@ -73,22 +74,22 @@
73 74
                         var result = response.data;
74 75
                         var status = response.status;
75 76
                         if (result == null || typeof result !== 'object') {
76
-                            reject(deferred, {message: "Failed to parse response", code: status}, status, luBusyDbo);
77
+                            reject(deferred, {message: "Failed to parse response", code: status}, status, luBusyGroups);
77 78
                         }
78 79
                         else if (result.message != null) {
79
-                            reject(deferred, result, status, luBusyDbo);
80
+                            reject(deferred, result, status, luBusyGroups);
80 81
                         }
81 82
                         else {
82
-                            resolve(deferred, result.data, luBusyDbo);
83
+                            resolve(deferred, result.data, luBusyGroups);
83 84
                         }
84 85
                     }, function (response) {
85 86
                         var result = response.data;
86 87
                         var status = response.status;
87 88
                         if (result == null || typeof result !== 'object') {
88
-                            reject(deferred, {message: "Failed to parse response", code: status}, status, luBusyDbo);
89
+                            reject(deferred, {message: "Failed to parse response", code: status}, status, luBusyGroups);
89 90
                         }
90 91
                         else {
91
-                            reject(deferred, result, status, luBusyDbo);
92
+                            reject(deferred, result, status, luBusyGroups);
92 93
                         }
93 94
                     });
94 95
                 return deferred.promise;

+ 10
- 10
src/DataAccess/lu-webapi-crud-dataaccess.js Ver arquivo

@@ -12,29 +12,29 @@
12 12
             luWebApiCrudDataAccess.create = function (entry_point) {
13 13
                 var DataAccess = luWebApiDataAccess.create(entry_point);
14 14
 
15
-                DataAccess.getSingleById = function (id, luBusyDbo) {
16
-                    return DataAccess.get(id, null, luBusyDbo);
15
+                DataAccess.getSingleById = function (id, luBusyGroups) {
16
+                    return DataAccess.get(id, null, luBusyGroups);
17 17
                 };
18 18
 
19
-                DataAccess.getMultiple = function (orderBy, filter, page, perPage, luBusyDbo) {
19
+                DataAccess.getMultiple = function (orderBy, filter, page, perPage, luBusyGroups) {
20 20
                     return DataAccess.get('', {
21 21
                         orderBy: orderBy,
22 22
                         filter: filter,
23 23
                         page: page,
24 24
                         perPage: perPage
25
-                    }, luBusyDbo);
25
+                    }, luBusyGroups);
26 26
                 };
27 27
 
28
-                DataAccess.addDbo = function(data, luBusyDbo) {
29
-                    return DataAccess.post('', null, data, luBusyDbo);
28
+                DataAccess.addDbo = function(data, luBusyGroups) {
29
+                    return DataAccess.post('', null, data, luBusyGroups);
30 30
                 };
31 31
 
32
-                DataAccess.editSingleByIdDbo = function(id, data, luBusyDbo) {
33
-                    return DataAccess.post(id, null, data, luBusyDbo);
32
+                DataAccess.editSingleByIdDbo = function(id, data, luBusyGroups) {
33
+                    return DataAccess.post(id, null, data, luBusyGroups);
34 34
                 };
35 35
 
36
-                DataAccess.deleteDbo = function(id, luBusyDbo) {
37
-                    return DataAccess.delete(id, null, null, luBusyDbo);
36
+                DataAccess.deleteDbo = function(id, luBusyGroups) {
37
+                    return DataAccess.delete(id, null, null, luBusyGroups);
38 38
                 };
39 39
 
40 40
                 return DataAccess;

+ 8
- 8
src/DataAccess/lu-webapi-dataaccess.js Ver arquivo

@@ -17,24 +17,24 @@
17 17
                     DataAccess.entry_point += '/';
18 18
                 }
19 19
 
20
-                DataAccess.get = function(url, dataGet, luBusyDbo)
20
+                DataAccess.get = function(url, dataGet, luBusyGroups)
21 21
                 {
22
-                    return luRequest.get(DataAccess.entry_point + url, dataGet, luBusyDbo);
22
+                    return luRequest.get(DataAccess.entry_point + url, dataGet, luBusyGroups);
23 23
                 };
24 24
 
25
-                DataAccess.post = function(url, dataGet, dataPost, luBusyDbo)
25
+                DataAccess.post = function(url, dataGet, dataPost, luBusyGroups)
26 26
                 {
27
-                    return luRequest.post(DataAccess.entry_point + url, dataGet, dataPost, luBusyDbo);
27
+                    return luRequest.post(DataAccess.entry_point + url, dataGet, dataPost, luBusyGroups);
28 28
                 };
29 29
 
30
-                DataAccess.put = function(url, dataGet, dataPost, luBusyDbo)
30
+                DataAccess.put = function(url, dataGet, dataPost, luBusyGroups)
31 31
                 {
32
-                    return luRequest.put(DataAccess.entry_point + url, dataGet, dataPost, luBusyDbo);
32
+                    return luRequest.put(DataAccess.entry_point + url, dataGet, dataPost, luBusyGroups);
33 33
                 };
34 34
 
35
-                DataAccess.delete = function(url, dataGet, dataPost, luBusyDbo)
35
+                DataAccess.delete = function(url, dataGet, dataPost, luBusyGroups)
36 36
                 {
37
-                    return luRequest.delete(DataAccess.entry_point + url, dataGet, dataPost, luBusyDbo);
37
+                    return luRequest.delete(DataAccess.entry_point + url, dataGet, dataPost, luBusyGroups);
38 38
                 };
39 39
 
40 40
                 return DataAccess;

+ 0
- 122
tests/Business/lu-busy-business.spec.js Ver arquivo

@@ -12,126 +12,4 @@ describe('lu-promise factory', function() {
12 12
     beforeEach(inject(function(_luBusyBusiness_) {
13 13
         luBusyBusiness = _luBusyBusiness_;
14 14
     }));
15
-
16
-    it('should init a simple promise', function()
17
-    {
18
-        var p  = luBusyBusiness.newPromise('my-id', 'all-groups', 'loader-groups', 'error-groups');
19
-        luBusyBusiness.initPromise(p);
20
-        expect(Object.keys(luBusyBusiness.promises).length).toEqual(1);
21
-
22
-        var d = luBusyBusiness.promises['my-id'];
23
-        expect(d).not.toBe(null);
24
-        expect(d).not.toBe(undefined);
25
-        expect(d.loaders).toEqual(['all-groups', 'loader-groups']);
26
-        expect(d.errors).toEqual(['all-groups', 'error-groups']);
27
-        expect(d.status).toBe(luBusyBusiness.STATUS_RUNNING);
28
-        expect(d.id).toBe('my-id');
29
-
30
-        expect(Object.keys(luBusyBusiness.errors).length).toEqual(2);
31
-        expect(luBusyBusiness.errors['all-groups'].length).toEqual(1);
32
-        expect(luBusyBusiness.errors['all-groups'][0]['id']).toEqual('my-id');
33
-        expect(luBusyBusiness.errors['error-groups'].length).toEqual(1);
34
-        expect(luBusyBusiness.errors['error-groups'][0]['id']).toEqual('my-id');
35
-
36
-        expect(Object.keys(luBusyBusiness.loaders).length).toEqual(2);
37
-        expect(luBusyBusiness.loaders['all-groups'].length).toEqual(1);
38
-        expect(luBusyBusiness.loaders['all-groups'][0]['id']).toEqual('my-id');
39
-        expect(luBusyBusiness.loaders['loader-groups'].length).toEqual(1);
40
-        expect(luBusyBusiness.loaders['loader-groups'][0]['id']).toEqual('my-id');
41
-    });
42
-
43
-    it('should init a more complex promise 1', function()
44
-    {
45
-        var p  = luBusyBusiness.newPromise('my-id', ['all-groups', 'another-group'], 'loader-groups');
46
-        luBusyBusiness.initPromise(p);
47
-        expect(Object.keys(luBusyBusiness.promises).length).toEqual(1);
48
-
49
-        var d = luBusyBusiness.promises['my-id'];
50
-        expect(d).not.toBe(null);
51
-        expect(d).not.toBe(undefined);
52
-        expect(d.loaders).toEqual(['all-groups', 'another-group', 'loader-groups']);
53
-        expect(d.errors).toEqual(['all-groups', 'another-group']);
54
-        expect(d.status).toBe(luBusyBusiness.STATUS_RUNNING);
55
-        expect(d.id).toBe('my-id');
56
-
57
-        expect(Object.keys(luBusyBusiness.errors).length).toEqual(2);
58
-        expect(luBusyBusiness.errors['all-groups'].length).toEqual(1);
59
-        expect(luBusyBusiness.errors['all-groups'][0]['id']).toEqual('my-id');
60
-        expect(luBusyBusiness.errors['another-group'].length).toEqual(1);
61
-        expect(luBusyBusiness.errors['another-group'][0]['id']).toEqual('my-id');
62
-
63
-        expect(Object.keys(luBusyBusiness.loaders).length).toEqual(3);
64
-        expect(luBusyBusiness.loaders['all-groups'].length).toEqual(1);
65
-        expect(luBusyBusiness.loaders['all-groups'][0]['id']).toEqual('my-id');
66
-        expect(luBusyBusiness.loaders['another-group'].length).toEqual(1);
67
-        expect(luBusyBusiness.loaders['another-group'][0]['id']).toEqual('my-id');
68
-        expect(luBusyBusiness.loaders['loader-groups'].length).toEqual(1);
69
-        expect(luBusyBusiness.loaders['loader-groups'][0]['id']).toEqual('my-id');
70
-    });
71
-
72
-    it('should init a more complex promise 2', function()
73
-    {
74
-        var p  = luBusyBusiness.newPromise('my-id', null, 'loader-groups');
75
-        luBusyBusiness.initPromise(p);
76
-        expect(Object.keys(luBusyBusiness.promises).length).toEqual(1);
77
-
78
-        var d = luBusyBusiness.promises['my-id'];
79
-        expect(d).not.toBe(null);
80
-        expect(d).not.toBe(undefined);
81
-        expect(d.loaders).toEqual(['loader-groups']);
82
-        expect(d.errors).toEqual([]);
83
-        expect(d.status).toBe(luBusyBusiness.STATUS_RUNNING);
84
-        expect(d.id).toBe('my-id');
85
-
86
-        expect(Object.keys(luBusyBusiness.errors).length).toEqual(0);
87
-
88
-        expect(Object.keys(luBusyBusiness.loaders).length).toEqual(1);
89
-        expect(luBusyBusiness.loaders['loader-groups'].length).toEqual(1);
90
-        expect(luBusyBusiness.loaders['loader-groups'][0]['id']).toEqual('my-id');
91
-    });
92
-
93
-    it('should init multiple more complex promise 1', function()
94
-    {
95
-        var p1  = luBusyBusiness.newPromise('my-id', ['all-groups', 'another-group'], 'loader-groups');
96
-        luBusyBusiness.initPromise(p1);
97
-        var p2  = luBusyBusiness.newPromise('my-id2', ['all-groups', 'another-group'], null, 'an-error-group');
98
-        luBusyBusiness.initPromise(p2);
99
-        expect(Object.keys(luBusyBusiness.promises).length).toEqual(2);
100
-
101
-        var d = luBusyBusiness.promises['my-id'];
102
-        expect(d).not.toBe(null);
103
-        expect(d).not.toBe(undefined);
104
-        expect(d.loaders).toEqual(['all-groups', 'another-group', 'loader-groups']);
105
-        expect(d.errors).toEqual(['all-groups', 'another-group']);
106
-        expect(d.status).toBe(luBusyBusiness.STATUS_RUNNING);
107
-        expect(d.id).toBe('my-id');
108
-
109
-        d = luBusyBusiness.promises['my-id2'];
110
-        expect(d).not.toBe(null);
111
-        expect(d).not.toBe(undefined);
112
-        expect(d.loaders).toEqual(['all-groups', 'another-group']);
113
-        expect(d.errors).toEqual(['all-groups', 'another-group', 'an-error-group']);
114
-        expect(d.status).toBe(luBusyBusiness.STATUS_RUNNING);
115
-        expect(d.id).toBe('my-id2');
116
-
117
-        expect(Object.keys(luBusyBusiness.errors).length).toEqual(3);
118
-        expect(luBusyBusiness.errors['all-groups'].length).toEqual(2);
119
-        expect(luBusyBusiness.errors['all-groups'][0]['id']).toEqual('my-id');
120
-        expect(luBusyBusiness.errors['all-groups'][1]['id']).toEqual('my-id2');
121
-        expect(luBusyBusiness.errors['another-group'].length).toEqual(2);
122
-        expect(luBusyBusiness.errors['another-group'][0]['id']).toEqual('my-id');
123
-        expect(luBusyBusiness.errors['another-group'][1]['id']).toEqual('my-id2');
124
-        expect(luBusyBusiness.errors['an-error-group'].length).toEqual(1);
125
-        expect(luBusyBusiness.errors['an-error-group'][0]['id']).toEqual('my-id2');
126
-
127
-        expect(Object.keys(luBusyBusiness.loaders).length).toEqual(3);
128
-        expect(luBusyBusiness.loaders['all-groups'].length).toEqual(2);
129
-        expect(luBusyBusiness.loaders['all-groups'][0]['id']).toEqual('my-id');
130
-        expect(luBusyBusiness.loaders['all-groups'][1]['id']).toEqual('my-id2');
131
-        expect(luBusyBusiness.loaders['another-group'].length).toEqual(2);
132
-        expect(luBusyBusiness.loaders['another-group'][0]['id']).toEqual('my-id');
133
-        expect(luBusyBusiness.loaders['another-group'][1]['id']).toEqual('my-id2');
134
-        expect(luBusyBusiness.loaders['loader-groups'].length).toEqual(1);
135
-        expect(luBusyBusiness.loaders['loader-groups'][0]['id']).toEqual('my-id');
136
-    });
137 15
 });

Carregando…
Cancelar
Salvar