Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

luticate-utils.min.js 9.4KB

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("luUtilsBusiness",["luUtilsDataAccess",function(a){var b={};return b.momentDateTimeToString=function(b){return a.momentDateTimeToString(b)},b.stringToMomentDateTime=function(b){return a.stringToMomentDateTime(b)},b.dateTimeToString=function(b){return a.dateTimeToString(b)},b.stringToDateTime=function(b){return a.stringToDateTime(b)},b}])}(),function(){"use strict";angular.module("luticate2Utils").factory("luWebApiCrudBusiness",["luBusiness","$q",function(a,b){var c={};return c.create=function(b){var c=a.create();return c.dataAccess=b,c.initDbo=function(a){return c.dataAccess.initDbo(a)},c.initListDbo=function(a){return c.dataAccess.initListDbo(a)},c.initPaginatedDbo=function(a){return c.dataAccess.initPaginatedDbo(a)},c.thenInitDbo=function(a){return c.dataAccess.thenInitDbo(a)},c.thenInitListDbo=function(a){return c.dataAccess.thenInitListDbo(a)},c.thenInitPaginatedDbo=function(a){return c.dataAccess.thenInitPaginatedDbo(a)},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("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("luUtilsDataAccess",[function(){var a={};return a.momentDateTimeToString=function(a){return null==a?null:a.toISOString()},a.stringToMomentDateTime=function(a){return null==a?null:new Date(a)},a.dateTimeToString=function(a){if(null==a)return null;var b=new Date(Date.UTC(a.getFullYear(),a.getMonth(),a.getDate(),a.getHours(),a.getMinutes(),a.getSeconds(),a.getMilliseconds())).toISOString();return b},a.stringToDateTime=function(a){if(null==a)return null;var b=new Date(a),c=new Date(b.getUTCFullYear(),b.getUTCMonth(),b.getUTCDate(),b.getUTCHours(),b.getUTCMinutes(),b.getUTCSeconds(),b.getUTCMilliseconds());return c},a}])}(),function(){"use strict";angular.module("luticate2Utils").factory("luWebApiCrudDataAccess",["luWebApiDataAccess","$q","luUtilsDataAccess",function(a,b,c){var d={};return d.create=function(d){var e=a.create(d);return e._initModel=function(a){return null==a?null:(a=angular.copy(a),delete a.id,delete a.updatedAt,delete a.createdAt,delete a._itemType,delete a.toString,a)},e.initModel=function(a){return e._initModel(a)},e.initListModel=function(a){for(var b=[],c=0;c<a.length;++c)b.push(e.initModel(a[c]));return b},e.initPaginatedModel=function(a){var b={count:a.count,data:e.initListModel(a.data)};return b},e.thenInitModel=function(a){var c=b.defer();return a.then(function(a){c.resolve(e.initModel(a))},c.reject),c.promise},e.thenInitListModel=function(a){var c=b.defer();return a.then(function(a){c.resolve(e.initListModel(a))},c.reject),c.promise},e.thenInitPaginatedModel=function(a){var c=b.defer();return a.then(function(a){c.resolve(e.initPaginatedModel(a))},c.reject),c.promise},e.defaultDbo={id:null,createdAt:null,updatedAt:null,toString:function(){return this.id}},e.extendDeep=function f(a){return angular.forEach(arguments,function(b){b!==a&&angular.forEach(b,function(b,c){a[c]&&a[c].constructor&&a[c].constructor===Object?f(a[c],b):a[c]=b})}),a},e._initDbo=function(a){if(null==a)return null;var b=e.extendDeep({},e.defaultDbo,a);return b.createdAt=c.stringToMomentDateTime(b.createdAt),b.updatedAt=c.stringToMomentDateTime(b.updatedAt),b},e.initDbo=function(a){return e._initDbo(a)},e.initListDbo=function(a){for(var b=[],c=0;c<a.length;++c)b.push(e.initDbo(a[c]));return b},e.initPaginatedDbo=function(a){var b={count:a.count,data:e.initListDbo(a.data)};return b},e.thenInitDbo=function(a){var c=b.defer();return a.then(function(a){c.resolve(e.initDbo(a))},c.reject),c.promise},e.thenInitListDbo=function(a){var c=b.defer();return a.then(function(a){c.resolve(e.initListDbo(a))},c.reject),c.promise},e.thenInitPaginatedDbo=function(a){var c=b.defer();return a.then(function(a){c.resolve(e.initPaginatedDbo(a))},c.reject),c.promise},e.getSingleById=function(a,b){return e.thenInitDbo(e.get(a,null,b))},e.getMultiple=function(a,b,c,d,f){return e.thenInitPaginatedDbo(e.get("",{orderBy:a,filter:b,page:c,perPage:d},f))},e.addDbo=function(a,b){var c=e.initModel(a);return e.thenInitDbo(e.post("",null,c,b))},e.editSingleByIdDbo=function(a,b,c){var d=e.initModel(b);return e.thenInitDbo(e.post(a,null,d,c))},e.deleteDbo=function(a,b){return e.thenInitDbo(e["delete"](a,null,null,b))},e},d}])}(),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}])}();