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.

luticate-utils.min.js 6.9KB

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",["$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("luNotificationsBusiness",["luNotificationsDataAccess",function(a){function b(a){return function(b,d,e,f){var g=c.businesses[d];return null!=g&&null!=g.initDbo&&(e=g.initDbo(e),f=g.initDbo(f)),a(b,d,e,f)}}var c={};return c.EVENT_CREATE="EVENT_CREATE",c.EVENT_UPDATE="EVENT_UPDATE",c.EVENT_DELETE="EVENT_DELETE",c.businesses={},c.init=function(b){c.businesses=b,a.init()},c.addEventCreateCallback=function(d,e){a.addCallback(c.EVENT_CREATE,d,b(e))},c.addEventUpdateCallback=function(d,e){a.addCallback(c.EVENT_UPDATE,d,b(e))},c.addEventDeleteCallback=function(d,e){a.addCallback(c.EVENT_DELETE,d,b(e))},c.addEventCrudCallback=function(a,b){c.addEventCreateCallback(a,b),c.addEventUpdateCallback(a,b),c.addEventDeleteCallback(a,b)},c}])}(),function(){"use strict";angular.module("luticate2Utils").factory("luWebApiCrudBusiness",["luBusiness","$q",function(a,b){var c={};return c.create=function(c){var d=a.create();return d.dataAccess=c,d.defaultDbo={id:null,toString:function(){return this.id}},d.extendDeep=function e(a){return angular.forEach(arguments,function(b){b!==a&&angular.forEach(b,function(b,c){a[c]&&a[c].constructor&&a[c].constructor===Object?e(a[c],b):a[c]=b})}),a},d._initDbo=function(a){return null==a?null:(a=d.extendDeep({},d.defaultDbo,a),null!=a.createdAt&&(a.createdAt=new Date(a.createdAt)),null!=a.updatedAt&&(a.updatedAt=new Date(a.updatedAt)),a)},d.initDbo=function(a){return d._initDbo(a)},d.initListDbo=function(a){for(var b=[],c=0;c<a.length;++c)b.push(d.initDbo(a[c]));return b},d.initPaginatedDbo=function(a){var b={count:a.count,data:d.initListDbo(a.data)};return b},d.thenInitDbo=function(a){var c=b.defer();return a.then(function(a){c.resolve(d.initDbo(a))},c.reject),c.promise},d.thenInitPaginatedDbo=function(a){var c=b.defer();return a.then(function(a){c.resolve(d.initPaginatedDbo(a))},c.reject),c.promise},d.getSingleById=function(a,b){return d.thenInitDbo(d.dataAccess.getSingleById(a,b))},d.getMultiple=function(a,b,c,e,f){return d.thenInitPaginatedDbo(d.dataAccess.getMultiple(a,b,c,e,f))},d.addDbo=function(a,b){return d.thenInitDbo(d.dataAccess.addDbo(a,b))},d.editSingleByIdDbo=function(a,b,c){return d.thenInitDbo(d.dataAccess.editSingleByIdDbo(a,b,c))},d.deleteDbo=function(a,b){return d.thenInitDbo(d.dataAccess.deleteDbo(a,b))},d},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("luNotificationsDataAccess",["Hub",function(a){var b={};return b.hub=null,b.callbacks={},b.addCallback=function(a,c,d){null==b.callbacks[a]&&(b.callbacks[a]={});var e=b.callbacks[a];null==e[c]&&(e[c]=[]),e[c].push(d)},b.init=function(){b.hub=new a("luNotificationsHub",{listeners:{notify:function(a,c,d,e){var f=b.callbacks[a];if(null!=f){var g=f[c];if(null!=g)for(var h=0;h<g.length;++h)g[h](a,c,d,e)}}},methods:[],queryParams:{},errorHandler:function(a){console.error(a)},stateChanged:function(a){switch(a.newState){case $.signalR.connectionState.connecting:break;case $.signalR.connectionState.connected:break;case $.signalR.connectionState.reconnecting:break;case $.signalR.connectionState.disconnected:}}})},b}])}(),function(){"use strict";angular.module("luticate2Utils").factory("luRequest",["$q","$http","luBusyBusiness",function(a,b,c){function d(a,b,d,e,g,h,i,j){for(var k={data:i,status:j},l=0;l<f.hooks.reject.length;++l)f.hooks.reject[l](a,b,d,e,g,k);h.reject(k),null!=g&&c.reject(g,k)}function e(a,b,d,e,g,h,i){for(var j=0;j<f.hooks.resolve.length;++j)f.hooks.resolve[j](a,b,d,e,g,i);h.resolve(i.data),null!=g&&c.resolve(g)}var f={};return f.hooks={before:[],resolve:[],reject:[]},f.addHook=function(a,b){f.hooks.hasOwnProperty(a)&&f.hooks[a].push(b)},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(g,h,i,j,k){null!=k&&c.initGroups(k);var l=a.defer();g=g.replace(/\/+$/,"");for(var m={url:g,method:h,params:i,data:JSON.stringify(j),headers:{"Content-Type":"application/json"}},n=0;n<f.hooks.before.length;++n)f.hooks.before[n](g,h,i,j,k);return b(m).then(function(a){var b=a.data,c=a.status;null==b||"object"!=typeof b?d(g,h,i,j,k,l,{message:"Failed to parse response",code:c,version:null,data:null},c):null!=b.message?d(g,h,i,j,k,l,b,c):e(g,h,i,j,k,l,b)},function(a){var b=a.data,c=a.status;null==b||"object"!=typeof b?d(g,h,i,j,k,l,{message:"Failed to parse response",code:c,version:null,data:null},c):d(g,h,i,j,k,l,b,c)}),l.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}])}();