"use strict";!function(){angular.module("luticateUtils",[])}(),angular.module("luticateUtils").directive("luBasicTable",["dialogs","luticateDialogErrorHelper",function(a,b){return{restrict:"E",scope:{options:"&"},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){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",function(a,b,c){return{restrict:"E",scope:{options:"&"},templateUrl:"/luticate/lutable.html",link:function(d,e,f){if(d.tableOptions=d.options(),d.tableOptions.luEditTableScope=d,null==d.tableOptions.onItemDeleted&&(d.tableOptions.onItemDeleted=function(a){}),null==d.tableOptions.onItemEdited&&(d.tableOptions.onItemEdited=function(a){}),null==d.tableOptions.onItemAdded&&(d.tableOptions.onItemAdded=function(a){}),null==d.tableOptions.onItemClicked&&(d.tableOptions.onItemClicked=function(b){var c=d.tableOptions.getEditController();a.create("views/modals/"+c.toLowerCase()+".html",c+"Controller",b).result.then(function(a){d.tableOptions.luBasicTableScope.loadPage(d.tableOptions.page),d.tableOptions.onItemEdited(a)})}),null==d.tableOptions.addItem&&(d.tableOptions.addItem=function(){var b=d.tableOptions.getEditController();a.create("views/modals/"+b.toLowerCase()+".html",b+"Controller",d.tableOptions.editData).result.then(function(a){d.tableOptions.luBasicTableScope.loadPage(d.tableOptions.page),d.tableOptions.onItemAdded(a)})}),null==d.tableOptions.canDel&&(d.tableOptions.canDel=function(){return!1}),"string"==typeof d.tableOptions.canDel){var g=d.tableOptions.canDel;d.tableOptions.canDel=function(){return c.hasEffectivePermission(g)}}if(d.tableOptions.canCheck=d.tableOptions.canDel,null==d.tableOptions.canEdit&&(d.tableOptions.canEdit=function(){return!1}),"string"==typeof d.tableOptions.canEdit){var h=d.tableOptions.canEdit;d.tableOptions.canEdit=function(a){return c.hasEffectivePermission(h)}}if(d.tableOptions.canClick=d.tableOptions.canEdit,null==d.tableOptions.canAdd&&(d.tableOptions.canAdd=function(){return!1}),"string"==typeof d.tableOptions.canAdd){var i=d.tableOptions.canAdd;d.tableOptions.canAdd=function(){return c.hasEffectivePermission(i)}}d.deleteItems=function(){if(0==d.tableOptions.checkedItems.length)return void d.tableOptions.luBasicTableScope.loadPage(d.tableOptions.page);var a={id:"promiseDelItems",loaderGroups:[d.tableOptions.luBusy.group]},c=d.tableOptions.checkedItems[0];d.tableOptions.getDelPromise(c,a).then(function(a){d.tableOptions.onItemDeleted(c),d.tableOptions.checkedItems.splice(0,1),d.deleteItems()},function(a){b.errorDialog(a).result.then(function(a){d.tableOptions.luBasicTableScope.loadPage(d.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",["dialogs","luticateDialogErrorHelper",function(a,b){return{restrict:"E",scope:{options:"&"},templateUrl:"views/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;b ')}]),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")}}]),function(){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",'')}]),angular.module("luticateUtils").directive("dialogOkCancel",["luticateDialogErrorHelper",function(a){return{restrict:"EA",transclude:!0,templateUrl:"/luticateUtils/dialogokcancel.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.html",'')}]);