angular.module("Wizdom365.Kanban",[]);
!function(){var a={};a.median=1024,a.max=2*a.median,angular.module("Wizdom365.Kanban").constant("kanbanOrder",a)}();
!function(){function e(e,a,n,r,t,i,o,c,d,s,l){e.card=angular.copy(o),e.card.assignedTo&&e.card.assignedTo.length&&e.card.assignedTo.forEach(function(e){return e.pictureUrl=d.getPictureUrl(e.loginName)}),e.socialCommentsTemplate=s,e.allowedCommentsLevel=l?2:1,e.originalCard=o,e.boardProperties=c,e.originalCard.listId=i,e.editable={name:e.originalCard.name,description:e.originalCard.description,estimatedHours:e.originalCard.estimatedHours},r.social.getSocialOverview(o.id,2).then(function(a){e.card.comments=a.comments,e.card.likes=a.likes}),e.card.members=[],e.addMembers=function(a){if(e.card.assignedTo){var n=e.card.assignedTo.map(function(e){return e.loginName});e.card.members.forEach(function(a,r){-1!==n.indexOf(a.loginName)&&e.card.members.splice(r,1)})}else e.card.assignedTo=[];e.card.members.forEach(function(a){e.card.assignedTo.push(a),a.pictureUrl=d.getPictureUrl(a.loginName)}),e.clearMembers(a)},e.clearMembers=function(a){e.card.members=[],a()},e.removeMember=function(a){var n=e.card.assignedTo.indexOf(a);e.card.assignedTo.splice(n,1),e.card.assignedTo.length||(e.card.assignedTo=null)},e.saveFieldChanges=function(a,n){e.card[a]=e.editable[a],n()},e.roundEstimatedHours=function(){e.editable.estimatedHours=Math.round(100*e.editable.estimatedHours)/100},e.discardFieldChanges=function(a,n){e.editable[a]=e.card[a],n()},e.changeSelectField=function(a,n){e.card[a]=n},e.getTagIndex=function(a){for(var n=0;n<e.card.tags.length;n++)if(angular.equals(e.card.tags[n],a))return n;return-1},e.toggleTag=function(a){var n=e.getTagIndex(a);-1===n?e.card.tags.push(a):e.card.tags.splice(n,1)},e.removeAttachment=function(a){e.working=!0,t.removeAttachment(i,o.listItemId,a).then(function(a){o.attachments=a,e.working=!1})},e.datepicker={opened:!1,options:{showWeeks:!1,startingDay:1},toggleDatepicker:function(){var a=e.datepicker.opened;n(function(){e.datepicker.opened=!a})}},e.cardChanged=function(){var a=["comments","likes","attachments"],n=!1;return angular.forEach(e.card,function(e,r){-1!==a.indexOf(r)||angular.equals(o[r],e)||(n=!0)}),n},e.remove=function(){if(confirm("The card will be permanently deleted.\n\nDelete card?")){var e={action:"remove"};a.close(e)}},e.save=function(){var n={action:"save",updates:{}},r=["comments","likes","attachments"];angular.forEach(e.card,function(a,t){-1!==r.indexOf(t)||angular.equals(e.originalCard[t],a)||(n.updates[t]=a)}),a.close(n)},e.close=function(){a.dismiss()}}angular.module("Wizdom365.Kanban").directive("kanbanFileread",["kanbanApi",function(e){return{scope:{fileread:"=",card:"="},link:function(a,n,r){n.bind("change",function(r){a.$apply(function(){for(var t,i=[],o=0;t=r.target.files[o];o++){var c=new FileReader;c.onload=function(t){return function(o){i.push({key:t.name,value:o.target.result.split(";base64,")[1]}),i.length===r.target.files.length&&(a.working=!0,e.addAttachment(a.card.listId,a.card.listItemId,i).then(function(e){a.card.attachments=e,n[0].value=null,a.working=!1}))}}(t),c.readAsDataURL(t)}})})}}}]),angular.module("Wizdom365.Kanban").controller("KanbanCardDetailsController",e),e.$inject=["$scope","$modalInstance","$timeout","webApiProxy","kanbanApi","listId","card","boardProperties","profileService","socialCommentsTemplate","allowRepliesToComments"]}();
!function(){function e(e,n,r,t,o,a,i){e.currentSwimlane=o,e.boardProperties=a,e.card={},e.datepicker={opened:!1,options:{showWeeks:!1,startingDay:1},toggleDatepicker:function(r){var t=e.datepicker.opened;n(function(){e.datepicker.opened=!t})}},e.toggleTag=function(e,n){var r=e.indexOf(n);-1===r?e.push(n):e.splice(r,1)},e.getTagsNameArray=function(e){return e.map(function(e){return e.value}).join(", ")},e.roundEstimatedHours=function(){e.card.estimatedHours=Math.round(100*e.card.estimatedHours)/100},e.create=function(e){e.assignedTo.forEach(function(e){e.pictureUrl=i.getPictureUrl(e.loginName)}),r.close(e)},e.cancel=function(){r.dismiss()}}angular.module("Wizdom365.Kanban").controller("KanbanCreateCardController",e),e.$inject=["$scope","$timeout","$modalInstance","kanbanApi","currentSwimlane","boardProperties","profileService"]}();
!function(){function n(n,i,e,a){n.swimlanes=angular.copy(a),n.swimlane={},n.moveDown=function(i,e){if(!e){var a=n.swimlanes.indexOf(i);n.swimlanes.splice(a,1),n.swimlanes.splice(a+1,0,i)}},n.moveUp=function(i,e){if(!e){var a=n.swimlanes.indexOf(i);n.swimlanes.splice(a,1),n.swimlanes.splice(a-1,0,i)}},n.remove=function(i){e.showConfirmationDialog({text:"Removing a swimlane will hide all cards contained in it. Remove swimlane?",type:"warning",layout:"center",successCalback:function(){n.$apply(function(){var e=n.swimlanes.indexOf(i);n.swimlanes.splice(e,1)})},errorCalback:function(){}})},n.add=function(){n.swimlanes.push(n.swimlane.name),n.swimlane.name=""},n.swimlanesChanged=function(){return!angular.equals(n.swimlanes,a)},n.save=function(){i.close(n.swimlanes)},n.close=function(){i.dismiss()}}angular.module("Wizdom365.Kanban").controller("KanbanEditSwimlanesController",n),n.$inject=["$scope","$modalInstance","notificationService","swimlanes"]}();
!function(){function t(t){function r(e,r,a){e.webpartId=t.getWebpartId(r),e.editMode=t.isInEditMode(r),t.hideEditCode(r);var n=a.webpartProperties?JSON.parse(a.webpartProperties):null;e.webpartProperties={templateUrl:n&&n.templateUrl||"Kanban/Templates/KanbanBoard.html",listId:n&&n.listId,socialCommentsTemplate:n&&n.socialCommentsTemplate,allowRepliesToComments:n&&n.allowRepliesToComments||!1},e.init()}return{scope:{},template:'<div class="bootstrap-wrapper">\n                        	<!-- \'Edit Webpart\'-button -->\n                        	<div ng-if="editMode">\n                                <div class="webpart-edit-button-container">\n                                    <button ng-click="editWebpart()" type="button" class="editWebpartButton btn" title=\'{{"Edit Webpart" | translate}}\'>\n                                        <span class="ms-Icon ms-Icon--Edit"></span><span class="editWebpartButtonText">{{"Edit" | translate}}</span>\n                                    </button>\n                                </div>\n                        	</div>\n                        	<!-- Include board template -->\n                        	<div ng-if="webpartProperties.listId" wizdom-include="webpartProperties.templateUrl"></div>\n                        	<!-- Missing list id error message -->\n                        	<div ng-if="!webpartProperties.listId">\n                        		<span>{{\'No list attached to webpart. Edit webpart to create a new list or select an existing.\' | translate}}</span>\n                        	</div>\n                        </div>',controller:e,link:r}}function e(t,e,r,a,n){function o(e){t.board.swimlanes=e,a.changeSwimlanes(t.webpartProperties.listId,e)["catch"](function(){t.showAlert=!0})}function i(e){var r=Math.max.apply(null,t.board.cards.filter(function(t){return t.status===e.status}).map(function(t){return t.order}));e.order=r!==-(1/0)?(r+n.max)/2:n.median,t.board.cards.push(e),a.addCard(t.webpartProperties.listId,e).then(function(r){e.id=t.webpartProperties.listId+r,e.listItemId=r})["catch"](function(){t.showAlert=!0})}function s(e,r){for(var n=null,o=0;o<t.board.cards.length;o++)if(t.board.cards[o].id==e.id){n=t.board.cards[o];break}null!=n&&(angular.forEach(r,function(t,e){n[e]=t}),a.updateCard(t.webpartProperties.listId,n)["catch"](function(){t.showAlert=!0}))}function l(e){var r=t.board.cards.indexOf(e);t.board.cards.splice(r,1),a.removeCard(t.webpartProperties.listId,e.listItemId)["catch"](function(){t.showAlert=!0})}t.editWebpart=function(){var r=e.open({templateUrl:"Kanban/Templates/Dialogs/EditKanban.html",controller:"EditKanbanController",windowClass:"bootstrap-wrapper edit-kanban",resolve:{webpartId:function(){return t.webpartId}}});r.result.then(function(e){e&&(t.webpartProperties=e)})},t.init=function(){t.webpartProperties&&t.webpartProperties.listId&&a.getBoard(t.webpartProperties.listId).then(function(e){t.board=e})},t.cardOrder=function(t){return t.order},t.getTagsNameArray=function(t){return t.map(function(t){return t.value}).join(", ")},t.showAlert=!1,t.closeAlert=function(){t.showAlert=!1},t.editSwimlanes=function(){var r=e.open({templateUrl:"Kanban/Templates/Dialogs/KanbanEditSwimlanes.html",controller:"KanbanEditSwimlanesController",windowClass:"bootstrap-wrapper kanban-edit-swimlanes",resolve:{swimlanes:function(){return t.board.swimlanes}}});r.result.then(function(t){t&&o(t)})},t.createNewCard=function(r){var a=e.open({templateUrl:"Kanban/Templates/Dialogs/KanbanCreateCard.html",controller:"KanbanCreateCardController",windowClass:"bootstrap-wrapper kanban-create-card",resolve:{currentSwimlane:function(){return r},boardProperties:function(){return{swimlanes:t.board.swimlanes,priorities:t.board.priorities,tags:t.board.tags}}}});a.result.then(function(t){t&&i(t)})},t.openCardDetails=function(r){var a=e.open({templateUrl:"Kanban/Templates/Dialogs/KanbanCardDetails.html",controller:"KanbanCardDetailsController",windowClass:"bootstrap-wrapper kanban-card-details",resolve:{listId:function(){return t.webpartProperties.listId},card:function(){return r},boardProperties:function(){return{swimlanes:t.board.swimlanes,priorities:t.board.priorities,tags:t.board.tags}},socialCommentsTemplate:function(){return t.webpartProperties.socialCommentsTemplate},allowRepliesToComments:function(){return t.webpartProperties.allowRepliesToComments}}});a.result.then(function(t){t&&("save"===t.action?s(r,t.updates):"remove"===t.action&&l(r))})},t.updateCard=s}angular.module("Wizdom365.Kanban").directive("wizdom365Kanban",t),t.$inject=["webpartPropertiesService"],e.$inject=["$scope","$modal","contextInfo","kanbanApi","kanbanOrder"]}();
!function(){function a(a){function t(a,t,r){"undefined"==typeof jQuery.ui?$.getScript(window.wizdomResources.js.JqueryUI).done(function(n,i){console.info("Jquery UI js loaded"),a.$applyAsync(function(){e(a,t,r)})}).fail(function(a,t,e){console.error("Jquery UI load failed in kanbanSortable.ts")}):e(a,t,r)}function e(t,e,n){var i=$(e).find(".kanban-add-card");$(e).sortable({items:"[kanban-card]",connectWith:"[kanban-swimlane]",placeholder:"kanban-placeholder",activate:function(a,t){t.item.data("originalOrder")||t.item.data("originalOrder",t.item.parent().contents().not(t.placeholder))},start:function(a,t){t.placeholder.height(t.item.height()-2)},over:function(a,t){i.is(":last-child")||i.appendTo(e)},receive:function(a,t){t.item.data("received",!0)},remove:function(a,t){r(t.item)},update:function(a,t){t.item.data("received")||(t.item.data("target",t.item.parent().attr("kanban-swimlane")),t.item.data("updated",!0),t.item.data("sortOrder",$(t.item.parent()).sortable("toArray",{attribute:"kanban-card"})),$(e).sortable("cancel"))},stop:function(e,n){if(r(n.item),n.item.data("updated")){var i=n.item.data("sortOrder").indexOf(n.item.attr("kanban-card")),d=t.board.cards.filter(function(a){return a.$$hashKey===n.item.data("sortOrder")[i-1]})[0],o=t.board.cards.filter(function(a){return a.$$hashKey===n.item.data("sortOrder")[i+1]})[0],c=d&&o?(d.order+o.order)/2:d?(d.order+a.max)/2:o?o.order/2:a.median,u={};u.order=c;var l=JSON.parse(n.item.attr("card"));l.status!==n.item.data("target")&&(u.status=n.item.data("target")),t.$apply(function(){t.updateCard(l,u)})}}})}function r(a){a.data("originalOrder")&&(a.parent().append(a.data("originalOrder")),a.removeData("originalOrder"))}return{link:t}}angular.module("Wizdom365.Kanban").directive("kanbanSortable",a),a.$inject=["kanbanOrder"]}();
!function(){function t(t,e){var n={baseUrl:"api/wizdom/kanban",getBoard:function(e){return t.get(this.baseUrl+"?listId="+e)},updateCard:function(e,n){return t.put(this.baseUrl+"?listId="+e,n)},addCard:function(e,n){return t.post(this.baseUrl+"?listId="+e,n)},removeCard:function(e,n){return t["delete"](this.baseUrl+"?listId="+e+"&cardId="+n)},addAttachment:function(e,n,a){return t.post(this.baseUrl+"/attachment?listId="+e+"&cardId="+n,a)},removeAttachment:function(e,n,a){return t["delete"](this.baseUrl+"/attachment?listId="+e+"&cardId="+n+"&attachmentName="+a)},changeSwimlanes:function(e,n){return t.put(this.baseUrl+"/swimlanes?listId="+e,n)},getKanbanLists:function(){return t.get(this.baseUrl+"/edit")},createKanbanList:function(e,n,a){return t.post(this.baseUrl+"/edit?listName="+e+"&termSetId="+n,a)}};return n}angular.module("Wizdom365.Kanban").factory("kanbanApi",t),t.$inject=["webapiService","contextInfo"]}();
!function(){function n(){function n(n,e,i,t){t.$validators.unique=function(e){return!e||!n.existing||!n.existing.some(function(n){return n.toLowerCase()===e.toLowerCase()})}}return{scope:{existing:"=kanbanUnique"},require:"ngModel",link:n}}angular.module("Wizdom365.Kanban").directive("kanbanUnique",n),n.$inject=[]}();
angular.module("Wizdom365").requires.push("Wizdom365.Kanban");