!function(){angular.module("luticateUtils",[])}(),angular.module("luticateUtils").directive("luBasicTable",["dialogs","luticateDialogErrorHelper",function(a,b){return{restrict:"E",scope:{options:"&"},transclude:{"lu-basic-table-filter":"?lu-basic-table-filter"},templateUrl:"/luticate/lubasictable.html",link:function(a,c,d){a.items=[],a.pages=[],a.maxPage=1,a.tableOptions=a.options(),a.tableOptions.luBasicTableScope=a,null==a.tableOptions.tableName&&(a.tableOptions.tableName=a.$id),"string"==typeof a.tableOptions.luBusy&&(a.tableOptions.luBusy={group:a.tableOptions.luBusy}),null==a.tableOptions.luBusy&&(a.tableOptions.luBusy={group:"luBasicTableItemList_"+a.$id}),null==a.tableOptions.page&&(a.tableOptions.page=0),null==a.tableOptions.perPage&&(a.tableOptions.perPage=15),null==a.tableOptions.query&&(a.tableOptions.query=""),null==a.tableOptions.checkedItems&&(a.tableOptions.checkedItems=[]),null==a.tableOptions.canCheck&&(a.tableOptions.canCheck=function(){return!1}),null==a.tableOptions.canClick&&(a.tableOptions.canClick=function(a){return!1}),null==a.tableOptions.canFilter&&(a.tableOptions.canFilter=function(){return!0});var e=a.tableOptions.onItemClicked;a.tableOptions.onItemClicked=function(b){a.tableOptions.canClick(b)&&e(b)},null==a.tableOptions.onItemChecked&&(a.tableOptions.onItemChecked=function(a,b){}),a.tableOptions.onPageChanged||(a.tableOptions.onPageChanged=function(){}),a.tableOptions.getItemId||(a.tableOptions.getItemId=function(a){return a.Id}),a.loadPage=function(c){if(!(0>c||c>=a.maxPage)){a.tableOptions.checkedItems=[];var d={id:"promiseLoadItems_"+a.$id,groups:[a.tableOptions.luBusy.group]};a.tableOptions.getLoadPagePromise(c,a.tableOptions.perPage,a.tableOptions.query,d).then(function(b){a.tableOptions.page=c,a.items=b,a.pages=[],a.maxPage=Math.max(b.Count/a.tableOptions.perPage,1);for(var d=Math.max(0,a.tableOptions.page-5),e=Math.min(d+10,a.maxPage),f=d;e>f;++f)a.pages.push(f);a.tableOptions.onPageChanged()},b.errorDialog)}},a.toggleCheckedItem=function(b){var c=a.tableOptions.getItemId(b);a.toggleCheckedId(c,b)},a.toggleCheckedId=function(b,c){c=c||a.items.Data.find(function(c){return a.tableOptions.getItemId(c)==b});var d=a.tableOptions.checkedItems.indexOf(b);d>-1?(a.tableOptions.onItemChecked(c,!1),a.tableOptions.checkedItems.splice(d,1)):(a.tableOptions.onItemChecked(c,!0),a.tableOptions.checkedItems.push(b))},a.unCheckAll=function(){for(;0!=a.tableOptions.checkedItems.length;)a.toggleCheckedId(a.tableOptions.checkedItems[0])},a.checkAll=function(){a.unCheckAll();for(var b=0;b-1},a.onItemClicked=function(b){a.tableOptions.onItemClicked(b)},a.loadPage(a.tableOptions.page)}}}]),angular.module("luticateUtils").run(["$templateCache",function(a){a.put("/luticate/lubasictable.html",'
{{ col.name }}
{{ col.getValue(item) }}
')}]),angular.module("luticateUtils").directive("luBusy",["$compile","$http","luticatePromises","$templateCache","luticateDialogErrorHelper",function(a,b,c,d,e){return{restrict:"A",scope:{luBusy:"&"},link:function(f,g,h){function i(c,e){b.get(c,{cache:d}).success(function(b){var c=f.$new(),d='
',h=a(d)(c);g.append(h);var i='
'+b+"
",j=a(i)(c);g.append(j)}).error(function(a){throw new Error("Template specified for luBusy ("+c+") could not be loaded. "+a)})}f.isLoading=!1,f.hasError=!1;var j={group:h.luBusy,templateLoader:"/luticate/lubusy-loader.html",templateError:"/luticate/lubusy-error.html"};f.update=function(){var a=f.luBusy();null!=a&&("string"==typeof a?j.group=a:angular.extend(j,a));var b=c.getLoadersGroup(j.group);f.isLoading=!1,null!=b&&(f.isLoading=b.some(function(a){return 0==a.status}));var d=c.getErrorsGroup(j.group);f.hasError=!1,null!=d&&(f.hasError=d.some(function(a){return 2==a.status}))},f.loaderSplashIsActive=function(){return f.update(),f.isLoading&&!f.hasError},f.errorSplashIsActive=function(){return f.update(),f.hasError},f.showError=function(){var a=c.getErrorsGroup(j.group),b=null;null!=a&&(b=a.find(function(a){return 2==a.status})),null!=b&&e.errorDialog(b.value)},i(j.templateLoader,"loaderSplashIsActive()"),i(j.templateError,"errorSplashIsActive()")}}}]),angular.module("luticateUtils").run(["$templateCache",function(a){"use strict";a.put("/luticate/lubusy-loader.html",'
\n\n
\n\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n\n
Please wait...
\n\n
\n\n
'),a.put("/luticate/lubusy-error.html",'
\n\n
\n\n \n\n
\n\n
')}]),angular.module("luticateUtils").directive("luEditTable",["dialogs","luticateDialogErrorHelper","luticateAuthCache","luticateDialogOkCancelHelper",function(a,b,c,d){return{restrict:"E",scope:{options:"&"},transclude:{"lu-basic-table-filter":"?lu-basic-table-filter"},templateUrl:"/luticate/lutable.html",link:function(e,f,g){if(e.tableOptions=e.options(),e.tableOptions.luEditTableScope=e,null==e.tableOptions.onItemDeleted&&(e.tableOptions.onItemDeleted=function(a){}),null==e.tableOptions.onItemEdited&&(e.tableOptions.onItemEdited=function(a){}),null==e.tableOptions.onItemAdded&&(e.tableOptions.onItemAdded=function(a){}),null==e.tableOptions.onItemClicked&&(e.tableOptions.onItemClicked=function(b){var c=e.tableOptions.getEditController();a.create("views/modals/"+c.toLowerCase()+".html",c+"Controller",b).result.then(function(a){e.tableOptions.luBasicTableScope.loadPage(e.tableOptions.page),e.tableOptions.onItemEdited(a)})}),null==e.tableOptions.addItem&&(e.tableOptions.addItem=function(){var b=e.tableOptions.getEditController();a.create("views/modals/"+b.toLowerCase()+".html",b+"Controller",e.tableOptions.editData).result.then(function(a){e.tableOptions.luBasicTableScope.loadPage(e.tableOptions.page),e.tableOptions.onItemAdded(a)})}),null==e.tableOptions.canDel&&(e.tableOptions.canDel=function(){return!1}),"string"==typeof e.tableOptions.canDel){var h=e.tableOptions.canDel;e.tableOptions.canDel=function(){return c.hasEffectivePermission(h)}}if(e.tableOptions.canCheck=e.tableOptions.canDel,null==e.tableOptions.canEdit&&(e.tableOptions.canEdit=function(){return!1}),"string"==typeof e.tableOptions.canEdit){var i=e.tableOptions.canEdit;e.tableOptions.canEdit=function(a){return c.hasEffectivePermission(i)}}if(e.tableOptions.canClick=e.tableOptions.canEdit,null==e.tableOptions.canAdd&&(e.tableOptions.canAdd=function(){return!1}),"string"==typeof e.tableOptions.canAdd){var j=e.tableOptions.canAdd;e.tableOptions.canAdd=function(){return c.hasEffectivePermission(j)}}e.askDeleteItems=function(){d.okCancelDialog({title:"Delete items",text:"Do you really want to delete selected items?"}).result.then(function(){e.deleteItems()})},e.deleteItems=function(){if(0==e.tableOptions.checkedItems.length)return void e.tableOptions.luBasicTableScope.loadPage(e.tableOptions.page);var a={id:"promiseDelItems",loaderGroups:[e.tableOptions.luBusy.group]},c=e.tableOptions.checkedItems[0];e.tableOptions.getDelPromise(c,a).then(function(a){e.tableOptions.onItemDeleted(c),e.tableOptions.checkedItems.splice(0,1),e.deleteItems()},function(a){b.errorDialog(a).result.then(function(a){e.tableOptions.luBasicTableScope.loadPage(e.tableOptions.page)},function(a){})})}}}}]),angular.module("luticateUtils").run(["$templateCache",function(a){a.put("/luticate/lutable.html",'
')}]),function(){function a(a,b){for(var c=a.split(","),d=0;d0?a.tmpPermission.Name=a.allPermissionsCleared[0].Name:a.tmpPermission.Name=""},b.errorDialog)},a.loadAllPermissions=function(){var d={id:"promiseLoadAllPermissions",groups:["permissionList"]};c.getAll(null,d).then(function(b){a.allPermissions=b.Data,a.loadPermissions()},b.errorDialog)},d.hasEffectivePermission("LU_PERM_GET")?a.loadAllPermissions():a.loadPermissions()}}}]),angular.module("luticateUtils").run(["$templateCache",function(a){a.put("/luticate/lupermissionedit.html",'
')}]),angular.module("luticateUtils").directive("luPickerTable",[function(){return{restrict:"E",scope:{options:"&"},templateUrl:"/luticate/lupickertable.html",link:function(a,b,c){a.pickerOptions=a.options(),a.pickerOptions.luPickerTableScope=a,a.pickerOptions.pickedItems=[];var d=a.pickerOptions.onItemClicked;a.pickerOptions.onItemClicked=function(b){null!=d&&d(b),a.pickerOptions.luBasicTableScope.toggleCheckedItem(b)};var e=a.pickerOptions.onItemChecked;a.pickerOptions.onItemChecked=function(b,c){null!=e&&e(b,c);var d=a.pickerOptions.getItemId(b),f=a.pickerOptions.pickedItems.find(function(b){return a.pickerOptions.getItemId(b)==d}),g=a.pickerOptions.pickedItems.indexOf(f);g>-1?c||a.pickerOptions.pickedItems.splice(g,1):c&&a.pickerOptions.pickedItems.push(b)};var f=a.pickerOptions.onPageChanged;a.pickerOptions.onPageChanged=function(){null!=f&&f();for(var b=0;bSelected items:
{{ pickerOptions.getItemText(item) }}
')}]),function(){"use strict";angular.module("luticateUtils").factory("luticatePromises",[function(){var a={};return a.promises={},a.loaders=[],a.errors=[],a.build=function(b){a[b]={};for(var c in a.promises){var d=a.promises[c];d[b].forEach(function(c){null==a[b][c]&&(a[b][c]=[]),a[b][c].push(d)})}},a.initPromise=function(b){var c={loaders:[],errors:[],status:0,id:b.id};b.groups&&b.groups.forEach(function(a){c.loaders.push(a),c.errors.push(a)}),b.loaderGroups&&b.loaderGroups.forEach(function(a){c.loaders.push(a)}),b.errorGroups&&b.errorGroups.forEach(function(a){c.errors.push(a)}),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=2,a.promises[b.id].value=c},a.resolve=function(b,c){a.promises[b.id].status=1,a.promises[b.id].value=c},a}])}(),function(){"use strict";angular.module("luticateUtils").factory("luticateRequest",["$q","$http","luticatePromises",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,b)}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",c,b,d)},f.put=function(a,b,c,d){return f.request(a,"PUT",c,b,d)},f["delete"]=function(a,b,c,d){return f.request(a,"DELETE",c,b,d)},f.request=function(f,g,h,i,j){null!=j&&c.initPromise(j);var k=a.defer();f=f.replace(/\/+$/,"");var l={url:f,method:g,params:h,data:null==i?null:$.param(i),headers:{"Content-Type":"application/x-www-form-urlencoded"}};return b(l).success(function(a,b){if(null==a||null!=a.Message){var c=null==a?"Failed to parse response":a.Message;d(k,c,b,j)}else e(k,a.Data,j)}).error(function(a,b){if(null==a||null!=a.Message){var c=null==a?"Failed to parse response":a.Message;d(k,c,b,j)}else d(k,a,b,j)}),k.promise},f}])}(),function(){"use strict";angular.module("luticateUtils").controller("luticateDialogError",["$scope","data","$state","luticateAuthCache",function(a,b,c,d){a.message=b.message,a.showLogin=401==b.data.Status,a.reconnect=function(){a.$dismiss(),d.removeUser(),c.go("login")}}]),angular.module("luticateUtils").factory("luticateDialogErrorHelper",["dialogs",function(a){var b={};return b.errorMessage=function(a){var b=a.Data;return b+=" (HTTP code: "+a.Status+")"},b.errorDialog=function(c){var d=b.errorMessage(c);return a.create("/luticateUtils/dialogerror.html","luticateDialogError",{message:d,data:c},{})},b}]),angular.module("luticateUtils").run(["$templateCache",function(a){a.put("/luticateUtils/dialogerror.html",'')}])}(),function(){"use strict";angular.module("luticateUtils").controller("luticateDialogOkCancel",["$scope","data",function(a,b){a.text=b.text,a.title=b.title,a.submitForm=function(){a.$close()}}]),angular.module("luticateUtils").factory("luticateDialogOkCancelHelper",["dialogs",function(a){var b={};return b.okCancelDialog=function(b){return a.create("/luticateUtils/dialogokcancel-dialog.html","luticateDialogOkCancel",b,{})},b}]),angular.module("luticateUtils").run(["$templateCache",function(a){a.put("/luticateUtils/dialogokcancel-dialog.html",' ')}])}(),angular.module("luticateUtils").directive("dialogClose",["luticateDialogErrorHelper",function(a){return{restrict:"EA",transclude:!0,templateUrl:"/luticateUtils/dialogclose-directive.html",link:function(a,b,c){a.title=c.title,a.__close=function(){a.onClosed&&a.onClosed(),a.$close()}}}}]),angular.module("luticateUtils").run(["$templateCache",function(a){a.put("/luticateUtils/dialogclose-directive.html",'')}]),function(){"use strict";angular.module("luticateUtils").directive("dialogOkCancel",["luticateDialogErrorHelper",function(a){return{restrict:"EA",transclude:!0,templateUrl:"/luticateUtils/dialogokcancel-directive.html",link:function(b,c,d){b.title=d.title,b.model={},b.pending=!1,b.submitted=!1,b.__submit=function(){b.submitted=!0,b.form.$valid&&(b.pending=!0,b.promise=b.submitForm(),b.promise?b.promise.then(function(a){b.onDone&&b.onDone(a),b.$close(a),b.pending=!1})["catch"](function(c){b.onError&&b.onError(c),a.errorDialog(c).result.then(function(a){},function(a){b.$dismiss(c)}),b.pending=!1}):(b.$close(),b.pending=!1))},b.__cancel=function(){b.onCanceled&&b.onCanceled(),b.$dismiss(),b.pending=!1}}}}]),angular.module("luticateUtils").run(["$templateCache",function(a){a.put("/luticateUtils/dialogokcancel-directive.html",'')}])}();