!function(){"use strict";function a(a,f){a.state("app",{url:"/addressbooks","abstract":!0,views:{addressbooks:{templateUrl:"UIxContactFoldersView",controller:"AddressBooksController",controllerAs:"app"}},resolve:{stateAddressbooks:b}}).state("app.addressbook",{url:"/:addressbookId",views:{addressbook:{templateUrl:"addressbook",controller:"AddressBookController",controllerAs:"addressbook"}},resolve:{stateAddressbook:c}}).state("app.addressbook.new",{url:"/{contactType:(?:card|list)}/new",views:{card:{templateUrl:"UIxContactEditorTemplate",controller:"CardController",controllerAs:"editor"}},resolve:{stateCard:d}}).state("app.addressbook.card",{url:"/:cardId","abstract":!0,views:{card:{template:""}},resolve:{stateCard:e}}).state("app.addressbook.card.view",{url:"/view",views:{"card@app.addressbook":{templateUrl:"UIxContactViewTemplate",controller:"CardController",controllerAs:"editor"}}}).state("app.addressbook.card.editor",{url:"/edit",views:{"card@app.addressbook":{templateUrl:"UIxContactEditorTemplate",controller:"CardController",controllerAs:"editor"}}}),f.otherwise("/addressbooks/personal")}function b(a){return a.$findAll(window.contactFolders)}function c(a,b,c,d){var e=_.find(d.$findAll(),function(a){return a.id==c.addressbookId});return e?(e.$reload(),e):a.reject("Addressbook "+c.addressbookId+" not found")}function d(a,b,c){var d="v"+a.contactType,e=new c({pid:a.addressbookId,c_component:d});return b.selectedCard=!0,e}function e(a,b){return b.selectedCard=a.cardId,b.$getCard(a.cardId)}function f(a,b,c){a.$on("$stateChangeError",function(a,d,e,f,g,h){b.error(h),c.go("app.addressbook",{addressbookId:"personal"})}),a.$on("$routeChangeError",function(a,c,d,e){b.error(a,c,d,e)})}angular.module("SOGo.ContactsUI",["ngSanitize","ui.router","angularFileUpload","ck","SOGo.Common","SOGo.PreferencesUI","SOGo.MailerUI"]).config(a).run(f),a.$inject=["$stateProvider","$urlRouterProvider"],b.$inject=["AddressBook"],c.$inject=["$q","$state","$stateParams","AddressBook"],d.$inject=["$stateParams","stateAddressbook","Card"],e.$inject=["$stateParams","stateAddressbook"],f.$inject=["$rootScope","$log","$state"]}(),function(){"use strict";function a(a,b,c,d,e,f,g,h,i,j,k,m){function n(a){c.go("app.addressbook.card.view",{addressbookId:m.id,cardId:a.id})}function o(a,b){b.selected=!b.selected,a.preventDefault(),a.stopPropagation()}function p(a){function b(a,b,c,d){a.create=function(a){b.hide(),c.go("app.addressbook.new",{addressbookId:d,contactType:a})}}e.show({parent:angular.element(document.body),targetEvent:a,clickOutsideToClose:!0,escapeToClose:!0,template:[''," ",' '," "," "+l("Contact")," "," "," "+l("List")," ","
"," ",""].join(""),locals:{addressbookId:C.selectedFolder.id},controller:b}),b.$inject=["scope","$mdDialog","$state","addressbookId"]}function q(a,b){return a&&a.c_component==b&&!a.selected}function r(){_.each(C.selectedFolder.cards,function(a){a.selected=!1})}function s(){i.confirm(l("Warning"),l("Are you sure you want to delete the selected contacts?")).then(function(){var a=_.filter(C.selectedFolder.cards,function(a){return a.selected});C.selectedFolder.$deleteCards(a),delete C.selectedFolder.selectedCard},function(a,b){})}function t(){var a=_.filter(C.selectedFolder.cards,function(a){return a.selected}),b=_.pluck(a,"id");window.location.href=ApplicationBaseURL+"/"+C.selectedFolder.id+"/export?uid="+b.join("&uid=")}function u(a){var b=_.filter(C.selectedFolder.cards,function(a){return a.selected});C.selectedFolder.$copyCards(b,a).then(function(){},function(a){i.alert(l("Error"),a)})}function v(){_.each(C.selectedFolder.cards,function(a){a.selected=!0})}function w(a){C.selectedFolder.$filter("",{sort:a})}function x(a){return h.$query.sort==a}function y(){C.mode.search=!1,C.selectedFolder.$filter("")}function z(a,b){f.$findAll().then(function(c){var d=_.filter(c,function(a){return 0===a.id?a:void 0})[0];d.$getMailboxes().then(function(f){d.$newMessage().then(function(d){e.show({parent:angular.element(document.body),targetEvent:a,clickOutsideToClose:!1,escapeToClose:!1,templateUrl:"../Mail/UIxMailEditor",controller:"MessageEditorController",controllerAs:"editor",locals:{stateAccounts:c,stateMessage:d,stateRecipients:b}})})})})}function A(a,b,c){var d=[{full:c+" <"+b+">"}];C.newMessage(a,d),a.stopPropagation(),a.preventDefault()}function B(a){var c=_.filter(C.selectedFolder.cards,function(a){return a.selected}),d=[],e=[];_.each(c,function(a){"vcard"==a.c_component&&a.c_mail.length?e.push({full:a.c_cn+" <"+a.c_mail+">"}):"vlist"==a.c_component&&(angular.isDefined(a.refs)&&a.refs.length?_.each(a.refs,function(a){a.email.length&&e.push({full:a.c_cn+" <"+a.email+">"})}):d.push(C.selectedFolder.$getCard(a.id).then(function(a){return a.$futureCardData.then(function(a){_.each(a.refs,function(a){a.email.length&&e.push({full:a.c_cn+" <"+a.email+">"})})})})))}),b.all(d).then(function(){e.length&&C.newMessage(a,e)})}var C=this;h.selectedFolder=m,C.service=h,C.selectedFolder=m,C.selectCard=n,C.toggleCardSelection=o,C.newComponent=p,C.notSelectedComponent=q,C.unselectCards=r,C.confirmDeleteSelectedCards=s,C.saveSelectedCards=t,C.copySelectedCards=u,C.selectAll=v,C.sort=w,C.sortedBy=x,C.cancelSearch=y,C.newMessage=z,C.newMessageWithSelectedCards=B,C.newMessageWithRecipient=A,C.mode={search:!1}}a.$inject=["$scope","$q","$state","$timeout","$mdDialog","Account","Card","AddressBook","Dialog","sgSettings","stateAddressbooks","stateAddressbook"],angular.module("SOGo.ContactsUI").controller("AddressBookController",a)}(),function(){"use strict";function a(a,b,c,d,e,f,g,h,i,j,k,m,n,o,p,q,r){function s(b,c){a.params.addressbookId!=c.id&&E.editMode!=c.id?(E.editMode=!1,n.$query.value="",h("sm")&&i("left").close(),a.go("app.addressbook",{addressbookId:c.id})):(b.preventDefault(),b.stopPropagation())}function t(){o.prompt(l("New addressbook"),l("Name of new addressbook")).then(function(a){var b=new n({name:a,isEditable:!0,isRemote:!1,owner:UserLogin});n.$add(b)})}function u(a){a.isRemote||(E.editMode=a.id,E.originalAddressbook=angular.extend({},a.$omit()),k("addressBookName_"+a.id))}function v(a){a.name=E.originalAddressbook.name,E.editMode=!1}function w(a){var b=a.name;b&&b.length>0&&b!=E.originalAddressbook.name&&a.$rename(b).then(function(a){E.editMode=!1},function(a,b){o.alert(l("Warning"),a)})}function x(){E.service.selectedFolder.isSubscription?E.service.selectedFolder.$delete().then(function(){E.service.selectedFolder=null,a.go("app.addressbook",{addressbookId:"personal"})},function(a,b){o.alert(l('An error occured while deleting the addressbook "%{0}".',E.service.selectedFolder.name),l(a.error))}):o.confirm(l("Warning"),l("Are you sure you want to delete the addressbook %{0}?",E.service.selectedFolder.name)).then(function(){return E.service.selectedFolder.$delete()}).then(function(){return E.service.selectedFolder=null,!0})["catch"](function(a){var b=a.data.message||a.statusText;o.alert(l('An error occured while deleting the addressbook "%{0}".',E.service.selectedFolder.name),b)})}function y(a,b){function c(a,b,c){function d(a){var b=0===a.type.indexOf("text")||/\.(ldif|vcf|vcard)$/.test(a.name);return b||g.show({template:["",' ',' error_outline'," "+l("Select a vCard or LDIF file.")+"","
",""].join(""),position:"top right",hideDelay:3e3}),b}var e=this;e.uploader=new j({url:ApplicationBaseURL+[c.id,"import"].join("/"),autoUpload:!0,queueLimit:1,filters:[{name:d,fn:d}],onSuccessItem:function(a,c,d,e){var f;b.hide(),0===c.imported?f=l("No card was imported."):(f=l("A total of %{0} cards were imported in the addressbook.",c.imported),n.selectedFolder.$reload()),g.show(g.simple().content(f).position("top right").hideDelay(3e3))},onErrorItem:function(a,b,c,d){g.show({template:["",' ',' error_outline'," "+l("An error occured while importing contacts.")+"","
",""].join(""),position:"top right",hideDelay:3e3})}}),e.close=function(){b.hide()}}f.show({parent:angular.element(document.body),targetEvent:a,clickOutsideToClose:!0,escapeToClose:!0,templateUrl:"UIxContactsImportDialog",controller:c,controllerAs:"$CardsImportDialogController",locals:{folder:b}}),c.$inject=["scope","$mdDialog","folder"]}function z(){window.location.href=ApplicationBaseURL+"/"+E.service.selectedFolder.id+"/exportFolder"}function A(a){function b(a,b){function c(){a.hide()}this.addressbook=b,this.close=c}f.show({parent:angular.element(document.body),clickOutsideToClose:!0,escapeToClose:!0,templateUrl:a.id+"/links",controller:b,controllerAs:"links",locals:{addressbook:a}}),b.$inject=["$mdDialog","addressbook"]}function B(a){function b(a,b,c){function d(){f.addressbook.$save().then(function(){c.init(f.addressbook.$omit()),b.hide()},function(){})}function e(){b.cancel()}var f=this;f.addressbook=new n(c.$omit()),f.saveProperties=d,f.close=e}f.show({templateUrl:a.id+"/properties",controller:b,controllerAs:"properties",clickOutsideToClose:!0,escapeToClose:!0,locals:{srcAddressBook:a}})["catch"](function(){}),b.$inject=["$scope","$mdDialog","srcAddressBook"]}function C(a){a.$acl.$users().then(function(){f.show({templateUrl:a.id+"/UIxAclEditor",controller:"AclController",controllerAs:"acl",clickOutsideToClose:!0,escapeToClose:!0,locals:{usersWithACL:a.$acl.users,User:q,folder:a}})})}function D(a){console.debug("subscribeToFolder "+a.owner+a.name),n.$subscribe(a.owner,a.name).then(function(a){g.show(g.simple().content(l("Sucessfully subscribed to address book")).position("top right").hideDelay(3e3))})}var E=this;E.activeUser=p.activeUser,E.service=n,E.select=s,E.newAddressbook=t,E.edit=u,E.revertEditing=v,E.save=w,E.confirmDelete=x,E.importCards=y,E.exportCards=z,E.showLinks=A,E.showProperties=B,E.share=C,E.subscribeToFolder=D}a.$inject=["$state","$scope","$rootScope","$stateParams","$timeout","$mdDialog","$mdToast","$mdMedia","$mdSidenav","FileUploader","sgFocus","Card","AddressBook","Dialog","sgSettings","User","stateAddressbooks"],angular.module("SOGo.ContactsUI").controller("AddressBooksController",a)}(),function(){"use strict";function a(a,b,c,d,e,f,g,h,i,j){function k(){var a=B.card.$addOrgUnit("");g("orgUnit_"+a)}function m(){B.card.birthday=new Date}function n(){B.card.$addScreenName("")}function o(){var a=B.card.$addEmail("");g("email_"+a)}function p(){var a=B.card.$addPhone("");g("phone_"+a)}function q(){var a=B.card.$addUrl("","");g("url_"+a)}function r(){var a=B.card.$addAddress("","","","","","","","");g("address_"+a)}function s(){var a=B.card.$addMember("");g("ref_"+a)}function t(a,b){return d.selectedFolder.$filter(a,{dry:!0,excludeLists:!0},b),d.selectedFolder.$cards}function u(a){a.$valid&&B.card.$save().then(function(a){var b=_.indexOf(_.pluck(d.selectedFolder.cards,"id"),B.card.id);0>b?d.selectedFolder.$reload():d.selectedFolder.cards[b]=angular.copy(B.card),h.go("app.addressbook.card.view",{cardId:B.card.id})})["catch"](function(a){console.log(a)})}function v(){h.go("app.addressbook",{addressbookId:d.selectedFolder.id}).then(function(){B.card=null,delete d.selectedFolder.selectedCard})}function w(){B.card.$reset()}function x(){B.card.$reset(),B.card.isNew?(B.card=null,delete d.selectedFolder.selectedCard,h.go("app.addressbook",{addressbookId:d.selectedFolder.id})):h.go("app.addressbook.card.view",{cardId:B.card.id})}function y(a){f.confirm(l("Warning"),l("Are you sure you want to delete the card of %{0}?",a.$fullname()),{ok:l("Yes"),cancel:l("No")}).then(function(){a.$delete().then(function(){d.selectedFolder.cards=_.reject(d.selectedFolder.cards,function(b){return b.id==a.id}),v()},function(b,c){f.alert(l("Warning"),l('An error occured while deleting the card "%{0}".',a.$fullname()))})})}function z(){window.location.href=ApplicationBaseURL+"/"+B.currentFolder.id+"/export?uid="+B.card.id}function A(a){B.showRawSource||B.rawSource?B.showRawSource=!B.showRawSource:e.$$resource.post(B.currentFolder.id+"/"+B.card.id,"raw").then(function(a){B.rawSource=a,B.showRawSource=!0})}var B=this;B.card=j,B.currentFolder=d.selectedFolder,B.allEmailTypes=e.$EMAIL_TYPES,B.allTelTypes=e.$TEL_TYPES,B.allUrlTypes=e.$URL_TYPES,B.allAddressTypes=e.$ADDRESS_TYPES,B.categories={},B.userFilterResults=[],B.addOrgUnit=k,B.addBirthday=m,B.addScreenName=n,B.addEmail=o,B.addPhone=p,B.addUrl=q,B.addAddress=r,B.addMember=s,B.userFilter=t,B.save=u,B.close=v,B.reset=w,B.cancel=x,B.confirmDelete=y,B.exportCard=z,B.toggleRawSource=A,B.showRawSource=!1}a.$inject=["$scope","$timeout","$mdDialog","AddressBook","Card","Dialog","sgFocus","$state","$stateParams","stateCard"],angular.module("SOGo.ContactsUI").controller("CardController",a)}(),function(){"use strict";function a(){return{restrict:"A",scope:{data:"=sgAddress"},controller:["$scope",function(a){a.addressLines=function(a){var b=[],c=[];return a.street&&b.push(a.street),a.street2&&b.push(a.street2),a.locality&&c.push(a.locality),a.region&&c.push(a.region),c.length>0&&b.push(c.join(", ")),a.country&&b.push(a.country),a.postalcode&&b.push(a.postalcode),b.join("
")}}],template:'
'}}angular.module("SOGo.Common").directive("sgAddress",a)}();
//# sourceMappingURL=Contacts.js.map