Просмотр исходного кода

added filter in crud

tags/v0.1.1
Robin Thoni 8 лет назад
Родитель
Сommit
9d44dd0235

+ 1
- 1
dist/luticate-utils.min.js Просмотреть файл

@@ -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){return c.dataAccess.getMultiple(a,b,d,e)},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:i,headers:{"Content-Type":"application/json"}};return b(l).then(function(a){var b=a.data,c=a.status;null==b?d(k,"Failed to parse response",c,j):null!=b.message?d(k,b.message,c,j):e(k,b.data,j)},function(a){var b=a.data,c=a.status;null==b?d(k,"Failed to parse response",c,j):null!=b.message?d(k,b.message,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){return c.get("",{orderBy:a,page:b,perPage:d},e)},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",[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}])}();

+ 2
- 2
src/Business/lu-webapi-crud-business.js Просмотреть файл

@@ -18,8 +18,8 @@
18 18
                     return Business.dataAccess.getSingleById(id, luBusyDbo);
19 19
                 };
20 20
 
21
-                Business.getMultiple = function (orderBy, page, perPage, luBusyDbo) {
22
-                    return Business.dataAccess.getMultiple(orderBy, page, perPage, luBusyDbo);
21
+                Business.getMultiple = function (orderBy, filter, page, perPage, luBusyDbo) {
22
+                    return Business.dataAccess.getMultiple(orderBy, filter, page, perPage, luBusyDbo);
23 23
                 };
24 24
 
25 25
                 Business.addDbo = function(data, luBusyDbo) {

+ 6
- 9
src/DataAccess/lu-request.js Просмотреть файл

@@ -62,7 +62,7 @@
62 62
                     url: url,
63 63
                     method: method,
64 64
                     params: dataGet,
65
-                    data: dataPost,
65
+                    data: JSON.stringify(dataPost),
66 66
                     headers: {
67 67
                         'Content-Type': "application/json"
68 68
                     }
@@ -72,11 +72,11 @@
72 72
                     .then(function (response) {
73 73
                         var result = response.data;
74 74
                         var status = response.status;
75
-                        if (result == null) {
76
-                            reject(deferred, "Failed to parse response", status, luBusyDbo);
75
+                        if (result == null || typeof result !== 'object') {
76
+                            reject(deferred, {message: "Failed to parse response", code: status}, status, luBusyDbo);
77 77
                         }
78 78
                         else if (result.message != null) {
79
-                            reject(deferred, result.message, status, luBusyDbo);
79
+                            reject(deferred, result, status, luBusyDbo);
80 80
                         }
81 81
                         else {
82 82
                             resolve(deferred, result.data, luBusyDbo);
@@ -84,11 +84,8 @@
84 84
                     }, function (response) {
85 85
                         var result = response.data;
86 86
                         var status = response.status;
87
-                        if (result == null) {
88
-                            reject(deferred, "Failed to parse response", status, luBusyDbo);
89
-                        }
90
-                        else if (result.message != null) {
91
-                            reject(deferred, result.message, status, luBusyDbo);
87
+                        if (result == null || typeof result !== 'object') {
88
+                            reject(deferred, {message: "Failed to parse response", code: status}, status, luBusyDbo);
92 89
                         }
93 90
                         else {
94 91
                             reject(deferred, result, status, luBusyDbo);

+ 2
- 1
src/DataAccess/lu-webapi-crud-dataaccess.js Просмотреть файл

@@ -16,9 +16,10 @@
16 16
                     return DataAccess.get(id, null, luBusyDbo);
17 17
                 };
18 18
 
19
-                DataAccess.getMultiple = function (orderBy, page, perPage, luBusyDbo) {
19
+                DataAccess.getMultiple = function (orderBy, filter, page, perPage, luBusyDbo) {
20 20
                     return DataAccess.get('', {
21 21
                         orderBy: orderBy,
22
+                        filter: filter,
22 23
                         page: page,
23 24
                         perPage: perPage
24 25
                     }, luBusyDbo);

Загрузка…
Отмена
Сохранить