angular.module("Wizdom365.DepartmentUsers",[]).config(["$compileProvider",function(e){}]);
angular.module("Wizdom365.DepartmentUsers").directive("wizdom365DepartmentUsers",[function(){return{scope:{},template:'<div class="wizdom-departmentUsers bootstrap-wrapper"><div class="webpart-edit-button-container" ng-if="::editMode"><button class="editWebpartButton btn" ng-click="editWebpart()" type="button" title=\'{{"Edit Webpart" | translate}}\'><span class="ms-Icon ms-Icon--Edit"></span><span class="editWebpartButtonText">{{"Edit" | translate}}</span></button></div><div wizdom365-spinner loading="!dataReady"></div><div ng-show="dataReady"><div ng-show="isConfigured"><div class="wizdom-departmentUsers-main"><div wizdom-include="webpartProperties.templateUrl"></div></div><div ng-show="!users.length">{{\'There is no employees in the department\' | translate}}</div></div><div ng-show="!isConfigured">{{\'Please configure the web part\' | translate}}</div></div><div class="container-fluid text-center" ng-if="users.length > webpartProperties.itemsPerPage"><div class="wd-noticeboard-pagination-inner-container"><pagination total-items="users.length" style="margin-bottom:0; padding-bottom:0;" ng-change="setPage(currentPage)" ng-model="currentPage" items-per-page="webpartProperties.itemsPerPage" max-size="5" boundary-links="false" previous-text="&lsaquo;" next-text="&rsaquo;" first-text="&laquo;" last-text="&raquo;"></pagination></div></div></div>',link:function(e,t,r){},controller:["$scope","$element","$attrs","webpartPropertiesService","$modal","departmentUsersApi","$filter","sessionStorageService",function(e,t,r,s,a,i,n,p){function o(){var t=d();t&&(e.users=t,e.dataReady=!0,e.isConfigured=!0),e.webpartProperties.SelectDepartment||e.webpartProperties.useUsersDepartment?i.getUsers(e.webpartProperties.department,e.webpartProperties.useUsersDepartment,u(),e.webpartProperties.resultSource).then(function(t){e.users=t.users,e.dataReady=!0,e.isConfigured=!0,l(e.users)}):e.webpartProperties.selectPeopleManually&&e.webpartProperties.principals?i.ensureUsers(_.map(e.webpartProperties.principals,function(e){return e.loginName||e.groupId}),u(),e.webpartProperties.resultSource,e.webpartProperties.showSelectedOrder).then(function(t){e.users=t.users,e.dataReady=!0,e.isConfigured=!0,l(e.users)}):e.webpartProperties.UseExplicitQuery&&e.webpartProperties.explicitQuery?i.getUsersByQuery(e.webpartProperties.explicitQuery,u(),e.webpartProperties.resultSource).then(function(t){e.users=t.users,e.dataReady=!0,e.isConfigured=!0,l(e.users)}):(e.isConfigured=!1,e.dataReady=!0)}function u(){var t=["w365Birthday","w365HireDate"];return e.webpartProperties.userProperties&&angular.forEach(e.webpartProperties.userProperties,function(e){t.push(e)}),t}function d(){return JSON.parse(p.getItem("departmentUsers:"+e.webpartId))}function l(t){p.setItem("departmentUsers:"+e.webpartId,JSON.stringify(t))}e.webpartId=s.getWebpartId(t),e.editMode=s.isInEditMode(t);var c=r.webpartProperties?JSON.parse(r.webpartProperties):null;e.webpartProperties={itemsPerPage:c&&c.itemsPerPage||10,maxNumberOfPages:5,SelectDepartment:c&&c.SelectDepartment||!1,department:c&&c.department||"",templateUrl:c&&c.templateUrl||"DepartmentUsers/Templates/ViewTemplates/defaultlist.html",useUsersDepartment:c&&c.useUsersDepartment||!1,selectPeopleManually:c&&c.selectPeopleManually||!1,showSelectedOrder:c&&c.showSelectedOrder||!1,UseExplicitQuery:c&&c.UseExplicitQuery||!1,explicitQuery:c&&c.explicitQuery||"",principals:c&&c.principals||[],userProperties:c&&c.userProperties||[],resultSource:c&&c.resultSource||"b09a7990-05ea-4af9-81ef-edfab16c4e31"},s.hideEditCode(t),e.isConfigured=!1,e.dataReady=!1,e.users=[],e.currentPage=1,o(),e.editWebpart=function(){a.open({templateUrl:"DepartmentUsers/Templates/Dialogs/EditWebpart.html",controller:"departmentUsersEditCtrl",windowClass:"bootstrap-wrapper",resolve:{webpartId:function(){return e.webpartId},webpartProperties:function(){return e.webpartProperties}}}).result.then(function(t){t&&(e.webpartProperties=t,o())})},e.getId=function(t){return t==e.currentPage?"PagingSelf":"PagingLink"},e.setPage=function(t){e.currentPage=t},e.filter=function(t){var r=_.indexOf(e.users,t),s=e.webpartProperties.itemsPerPage*(e.currentPage-1),a=s+e.webpartProperties.itemsPerPage;return r>=s&&a>r},e.isObjectAllEmpty=function(e){for(var t in e)if(null!=e[t])return!1;return!0}}]}}]);
!function(){function e(e){var r={baseUrl:"api/wizdom/departmentusers",allowBatching:!1,getUsers:function(r,t,n,s){var a=this.baseUrl+"/?department="+encodeURIComponent(r)+"&useUsersDepartment="+t;return n&&angular.forEach(n,function(e){a+="&selectProperties="+e}),s&&(a+="&resultSource="+s),e.getAppCached(a,this.allowBatching)},getUsersByQuery:function(r,t,n){var s=this.baseUrl+"/?query="+encodeURIComponent(r);return t&&angular.forEach(t,function(e){s+="&selectProperties="+e}),n&&(s+="&resultSource="+n),e.getAppCached(s,this.allowBatching)},ensureUsers:function(r,t,n,s){var a=this.baseUrl+"/ensure?";return t&&angular.forEach(t,function(e){a+="&selectProperties="+e}),n&&(a+="&resultSource="+n),s&&(a+="&showSelectedOrder=true"),e.post(a,r)}};return r}angular.module("Wizdom365.DepartmentUsers").factory("departmentUsersApi",e),e.$inject=["webapiService"]}();
angular.module("Wizdom365").requires.push("Wizdom365.DepartmentUsers");
angular.module("Wizdom365").run(["$templateCache", function($templateCache) {if($templateCache.get('DepartmentUsers/Templates/ViewTemplates/defaultlist.html') == null) $templateCache.put('DepartmentUsers/Templates/ViewTemplates/defaultlist.html','<div ng-repeat=\"user in users | filter: filter\">\r\n    <div class=\"wizdom-departmentUsers-row\">\r\n        <div class=\"wizdom-departmentUsers-imgColumn\">\r\n            <div wizdom365-presence-picture=\"\" size=\"AVATAR\" email=\"::user.email\" accountname=\"::user.accountName\" name=\"::user.name\" image=\"::user.pictureURL\"></div>\r\n        </div>\r\n\r\n        <div class=\"wizdom-departmentUsers-textColumn\">\r\n            <div class=\"name notranslate\">\r\n                <a ng-href=\"{{::user.publicUrl}}\">{{::user.name}}</a>\r\n            </div>\r\n            <section>\r\n                <div class=\"email notranslate\" ng-show=\"::user.email.length\">\r\n                    <a ng-href=\"mailto:{{::user.email}}\">{{::user.email}}</a>\r\n                </div>\r\n                <div class=\"phone\" ng-show=\"::user.phone.length\">\r\n                    <a ng-href=\"tel:{{::user.phone}}\">\r\n                        {{::user.phone}}\r\n                    </a>\r\n                </div>\r\n            </section>\r\n        </div>\r\n    </div>\r\n</div>\r\n');
if($templateCache.get('DepartmentUsers/Templates/ViewTemplates/extendedlist.html') == null) $templateCache.put('DepartmentUsers/Templates/ViewTemplates/extendedlist.html','<div ng-repeat=\"user in users | filter: filter\">\r\n    <div class=\"wizdom-departmentUsers-row\">\r\n        <div class=\"wizdom-departmentUsers-imgColumn\">\r\n            <div wizdom365-presence-picture=\"\" size=\"AVATAR\" email=\"::user.email\" accountname=\"::user.accountName\" name=\"::user.name\" image=\"::user.pictureURL\"></div>\r\n        </div>\r\n\r\n        <div class=\"wizdom-departmentUsers-textColumn\">\r\n            <div class=\"name notranslate\">\r\n                <a ng-href=\"{{::user.publicUrl}}\">{{::user.name}}</a>\r\n            </div>\r\n            <section>\r\n                <div class=\"email notranslate\" ng-show=\"::user.email.length\">\r\n                    <a ng-href=\"mailto:{{::user.email}}\">{{::user.email}}</a>\r\n                </div>\r\n                <div class=\"phone\" ng-show=\"::user.phone.length\">\r\n                    <a ng-href=\"tel:{{::user.phone}}\">\r\n                        {{::user.phone}}\r\n                    </a>\r\n                </div>\r\n            </section>\r\n            <div class=\"showMore\" ng-show=\"!isObjectAllEmpty(user.extendedProperties)\" ng-click=\"user.showExtendedInfo = !user.showExtendedInfo\">\r\n                <span ng-show=\"!user.showExtendedInfo\">{{\'Show more\' | translate}}<i class=\"glyphicon glyphicon-menu-down\" title=\"{{\'Show more\' | translate}}\"></i></span>\r\n                <span ng-show=\"user.showExtendedInfo\">{{\'Show less\' | translate}}<i class=\"glyphicon glyphicon-menu-up\" title=\"{{\'Show less\' | translate}}\"></i></span>\r\n            </div>\r\n            <div class=\"extendedInfo\" ng-show=\"user.showExtendedInfo\">\r\n\r\n                <div class=\"birthday\" ng-show=\"user.extendedProperties.w365Birthday\">\r\n                    {{\'Birthday\' | translate}}: {{user.extendedProperties.w365Birthday | date:\'MMMM d\'}}\r\n                </div>\r\n                <div class=\"hireDate\" ng-show=\"user.extendedProperties.w365HireDate\">\r\n                    {{\'Hiredate\' | translate}}: {{user.extendedProperties.w365HireDate | date: \'longDate\'}}\r\n                </div>\r\n            </div>\r\n        </div>\r\n        \r\n    </div>\r\n</div>\r\n');
if($templateCache.get('DepartmentUsers/Templates/ViewTemplates/horizontal-list.html') == null) $templateCache.put('DepartmentUsers/Templates/ViewTemplates/horizontal-list.html','<ul class=\"list-unstyled\" style=\"width: 100%;\">\r\n    <li ng-repeat=\"user in users | filter: filter\" style=\"margin-right:10px;display:inline-block; vertical-align:top; width:300px;\">\r\n        <div class=\"wizdom-departmentUsers-row\" style=\"display: inline-block;\">\r\n            <div class=\"wizdom-departmentUsers-imgColumn\">\r\n                <div wizdom365-presence-picture=\"\" size=\"AVATAR\" email=\"::user.email\" accountname=\"::user.accountName\" name=\"::user.name\" image=\"::user.pictureURL\"></div>\r\n            </div>\r\n\r\n            <div class=\"wizdom-departmentUsers-textColumn\">\r\n                <div class=\"name notranslate\">\r\n                    <a ng-href=\"{{::user.publicUrl}}\">{{::user.name}}</a>\r\n                </div>\r\n                <section>\r\n                    <div class=\"email notranslate\" ng-show=\"::user.email.length\">\r\n                        <a ng-href=\"mailto:{{::user.email}}\">{{::user.email}}</a>\r\n                    </div>\r\n                    <div class=\"phone\" ng-show=\"::user.phone.length\">\r\n                        <a ng-href=\"tel:{{::user.phone}}\">\r\n                            {{::user.phone}}\r\n                        </a>\r\n                    </div>\r\n                </section>\r\n            </div>\r\n        </div>\r\n    </li>\r\n</ul>\r\n');}]);