From 565ad6900b7dd25d22b29ce481290ff96dfd5c46 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Wed, 13 Jan 2016 09:18:14 -0500 Subject: [PATCH] Updated JS files for new build --- UI/WebServerResources/angular-material | 2 +- UI/WebServerResources/js/Administration.js | 2 +- UI/WebServerResources/js/Administration.services.js | 2 +- UI/WebServerResources/js/Contacts.js | 2 +- UI/WebServerResources/js/Contacts.services.js | 2 +- UI/WebServerResources/js/Main.js | 2 +- UI/WebServerResources/js/Preferences.js | 2 +- UI/WebServerResources/js/Scheduler.services.js | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/UI/WebServerResources/angular-material b/UI/WebServerResources/angular-material index 80a8929f5..8ef798f0f 160000 --- a/UI/WebServerResources/angular-material +++ b/UI/WebServerResources/angular-material @@ -1 +1 @@ -Subproject commit 80a8929f513c508da49a347a2a52bef48c15fb2a +Subproject commit 8ef798f0fe242c555ef7c11fa0abe762fb218a02 diff --git a/UI/WebServerResources/js/Administration.js b/UI/WebServerResources/js/Administration.js index 3b526f87d..b1fbdbd4e 100644 --- a/UI/WebServerResources/js/Administration.js +++ b/UI/WebServerResources/js/Administration.js @@ -1,2 +1,2 @@ -!function(){"use strict";function a(a,d){a.state("administration",{"abstract":!0,views:{administration:{templateUrl:"administration.html",controller:"AdministrationController",controllerAs:"app"}}}).state("administration.rights",{url:"/rights",views:{module:{templateUrl:"rights.html"}}}).state("administration.rights.edit",{url:"/:userId/:folderId/edit",views:{acl:{templateUrl:"UIxAdministrationAclEditor",controller:"AdministrationAclController",controllerAs:"acl"}},resolve:{stateUser:b,stateFolder:c}}),d.otherwise("/rights")}function b(a,b,c){var d;return d=_.find(c.$users,function(a){return a.uid==b.userId}),angular.isUndefined(d)?c.$filter(b.userId).then(function(e){return d=_.find(c.$users,function(a){return a.uid==b.userId}),angular.isUndefined(d)?a.reject("User with ID "+b.userId+" not found"):d.$folders().then(function(){return d})}):d}function c(a,b,c,d,e,f){var g,h,i=c(b.folderId);return g=_.find(d.$$folders,function(a){return a.name==i}),h="Appointment"==g.type?new f({id:g.name.split("/").pop(),owner:g.owner,name:g.displayName}):new e({id:g.name.split("/").pop(),owner:g.owner,name:g.displayName}),d.selectedFolder=h.id,h}function d(a,b,c){b.$on("$stateChangeError",function(b,d,e,f,g,h){a.error(h),c.go("administration.rights")}),b.$on("$routeChangeError",function(b,c,d,e){a.error(b,c,d,e)})}angular.module("SOGo.AdministrationUI",["ui.router","SOGo.Common","SOGo.Authentication","SOGo.PreferencesUI","SOGo.ContactsUI","SOGo.SchedulerUI"]).config(a).run(d),a.$inject=["$stateProvider","$urlRouterProvider"],b.$inject=["$q","$stateParams","User"],c.$inject=["$state","$stateParams","decodeUriFilter","stateUser","AddressBook","Calendar"],d.$inject=["$log","$rootScope","$state"]}(),function(){"use strict";function a(a,b,c,d,e,f){function g(){return angular.isDefined(e.$cards)?"../"+e.owner+"/Contacts/"+e.id+"/UIxContactsUserRightsEditor":"../"+e.owner+"/Calendar/"+e.id+"/UIxCalUserRightsEditor"}function h(a){o.selectedUid==a.uid?o.selectedUid=null:(o.selectedUid=a.uid,o.selectedUser=a,o.selectedUser.$rights())}function i(a){return f.$filter(a,e.$acl.users,{dry:!0})}function j(a){e.$acl.$removeUser(a.uid)["catch"](function(a,b){Dialog.alert(l("Warning"),l("An error occured please try again."))})}function k(a){a&&e.$acl.$addUser(a,e.owner).then(function(){o.userToAdd="",o.searchText=""},function(a){Dialog.alert(l("Warning"),a)})}function m(){b.go("administration.rights").then(function(){delete o.user.selectedFolder,o.user=null})}function n(){e.$acl.$saveUsersRights(e.owner).then(function(){c.show(c.simple().content(l("ACLs saved")).position("top right").hideDelay(3e3))},function(a,b){Dialog.alert(l("Warning"),l("An error occured please try again."))})}var o=this;o.user=d,o.folder=e,o.folderType=angular.isDefined(e.$cards)?"AddressBook":"Calendar",o.selectedUser=null,o.selectedUid=null,o.selectUser=h,o.removeUser=j,o.getTemplate=g,o.close=m,o.save=n,o.userToAdd="",o.searchText="",o.userFilter=i,o.addUser=k,e.$acl.$users(e.owner).then(function(a){o.users=a})}a.$inject=["$animate","$state","$mdToast","stateUser","stateFolder","User"],angular.module("SOGo.AdministrationUI").controller("AdministrationAclController",a)}(),function(){"use strict";function a(a,b,c,d,e){function f(b){a.go("administration."+b)}function g(a){e.$filter(a)}function h(a){j.selectedUser==j.users[a]?j.selectedUser=null:j.users[a].$folders().then(function(){j.selectedUser=j.users[a]})}function i(b){a.go("administration.rights.edit",{userId:j.selectedUser.uid,folderId:d(b.name)})}var j=this;j.service=e,j.selectedUser=null,j.users=e.$users,j.go=f,j.filter=g,j.selectUser=h,j.selectFolder=i}a.$inject=["$state","$mdToast","Dialog","encodeUriFilter","User"],angular.module("SOGo.AdministrationUI").controller("AdministrationController",a)}(); +(function(){"use strict";angular.module("SOGo.AdministrationUI",["ui.router","SOGo.Common","SOGo.Authentication","SOGo.PreferencesUI","SOGo.ContactsUI","SOGo.SchedulerUI"]).config(configure).run(runBlock);configure.$inject=["$stateProvider","$urlRouterProvider"];function configure($stateProvider,$urlRouterProvider){$stateProvider.state("administration",{"abstract":true,views:{administration:{templateUrl:"administration.html",controller:"AdministrationController",controllerAs:"app"}}}).state("administration.rights",{url:"/rights",views:{module:{templateUrl:"rights.html"}}}).state("administration.rights.edit",{url:"/:userId/:folderId/edit",views:{acl:{templateUrl:"UIxAdministrationAclEditor",controller:"AdministrationAclController",controllerAs:"acl"}},resolve:{stateUser:stateUser,stateFolder:stateFolder}});$urlRouterProvider.otherwise("/rights")}stateUser.$inject=["$q","$stateParams","User"];function stateUser($q,$stateParams,User){var user;user=_.find(User.$users,function(user){return user.uid==$stateParams.userId});if(angular.isUndefined(user)){return User.$filter($stateParams.userId).then(function(users){user=_.find(User.$users,function(user){return user.uid==$stateParams.userId});if(angular.isUndefined(user)){return $q.reject("User with ID "+$stateParams.userId+" not found")}else{return user.$folders().then(function(){return user})}return user})}return user}stateFolder.$inject=["$state","$stateParams","decodeUriFilter","stateUser","AddressBook","Calendar"];function stateFolder($state,$stateParams,decodeUriFilter,stateUser,AddressBook,Calendar){var folder,o,folderId=decodeUriFilter($stateParams.folderId);folder=_.find(stateUser.$$folders,function(folder){return folder.name==folderId});if(folder.type=="Appointment"){o=new Calendar({id:folder.name.split("/").pop(),owner:folder.owner,name:folder.displayName})}else{o=new AddressBook({id:folder.name.split("/").pop(),owner:folder.owner,name:folder.displayName})}stateUser.selectedFolder=o.id;return o}runBlock.$inject=["$log","$rootScope","$state"];function runBlock($log,$rootScope,$state){$rootScope.$on("$stateChangeError",function(event,toState,toParams,fromState,fromParams,error){$log.error(error);$state.go("administration.rights")});$rootScope.$on("$routeChangeError",function(event,current,previous,rejection){$log.error(event,current,previous,rejection)})}})();(function(){"use strict";AdministrationAclController.$inject=["$animate","$state","$mdToast","stateUser","stateFolder","User"];function AdministrationAclController($animate,$state,$mdToast,stateUser,stateFolder,User){var vm=this;vm.user=stateUser;vm.folder=stateFolder;vm.folderType=angular.isDefined(stateFolder.$cards)?"AddressBook":"Calendar";vm.selectedUser=null;vm.selectedUid=null;vm.selectUser=selectUser;vm.removeUser=removeUser;vm.getTemplate=getTemplate;vm.close=close;vm.save=save;vm.userToAdd="";vm.searchText="";vm.userFilter=userFilter;vm.addUser=addUser;stateFolder.$acl.$users(stateFolder.owner).then(function(data){vm.users=data});function getTemplate(){if(angular.isDefined(stateFolder.$cards))return"../"+stateFolder.owner+"/Contacts/"+stateFolder.id+"/UIxContactsUserRightsEditor";return"../"+stateFolder.owner+"/Calendar/"+stateFolder.id+"/UIxCalUserRightsEditor"}function selectUser(user){if(vm.selectedUid==user.uid){vm.selectedUid=null}else{vm.selectedUid=user.uid;vm.selectedUser=user;vm.selectedUser.$rights()}}function userFilter($query){return User.$filter($query,stateFolder.$acl.users,{dry:true})}function removeUser(user){stateFolder.$acl.$removeUser(user.uid).catch(function(data,status){Dialog.alert(l("Warning"),l("An error occured please try again."))})}function addUser(data){if(data){stateFolder.$acl.$addUser(data,stateFolder.owner).then(function(){vm.userToAdd="";vm.searchText=""},function(error){Dialog.alert(l("Warning"),error)})}}function close(){$state.go("administration.rights").then(function(){delete vm.user.selectedFolder;vm.user=null})}function save(){stateFolder.$acl.$saveUsersRights(stateFolder.owner).then(function(){$mdToast.show($mdToast.simple().content(l("ACLs saved")).position("top right").hideDelay(3e3))},function(data,status){Dialog.alert(l("Warning"),l("An error occured please try again."))})}}angular.module("SOGo.AdministrationUI").controller("AdministrationAclController",AdministrationAclController)})();(function(){"use strict";AdministrationController.$inject=["$state","$mdToast","Dialog","encodeUriFilter","User"];function AdministrationController($state,$mdToast,Dialog,encodeUriFilter,User){var vm=this;vm.service=User;vm.selectedUser=null;vm.users=User.$users;vm.go=go;vm.filter=filter;vm.selectUser=selectUser;vm.selectFolder=selectFolder;function go(module){$state.go("administration."+module)}function filter(searchText){User.$filter(searchText)}function selectUser(i){if(vm.selectedUser==vm.users[i]){vm.selectedUser=null}else{vm.users[i].$folders().then(function(){vm.selectedUser=vm.users[i]})}}function selectFolder(folder){$state.go("administration.rights.edit",{userId:vm.selectedUser.uid,folderId:encodeUriFilter(folder.name)})}}angular.module("SOGo.AdministrationUI").controller("AdministrationController",AdministrationController)})(); //# sourceMappingURL=Administration.js.map \ No newline at end of file diff --git a/UI/WebServerResources/js/Administration.services.js b/UI/WebServerResources/js/Administration.services.js index 9b7444046..a6871ac22 100644 --- a/UI/WebServerResources/js/Administration.services.js +++ b/UI/WebServerResources/js/Administration.services.js @@ -1,2 +1,2 @@ -!function(){"use strict";function a(){}a.$factory=["$q","$timeout","$log","sgSettings","Resource","User",function(b,c,d,e,f,g){return angular.extend(a,{$q:b,$timeout:c,$log:d,$$resource:new f(e.activeUser("folderURL"),e.activeUser()),activeUser:e.activeUser(),$User:g}),new a}];try{angular.module("SOGo.AdministrationUI")}catch(b){angular.module("SOGo.AdministrationUI",["SOGo.Common"])}angular.module("SOGo.AdministrationUI").factory("Administration",a.$factory)}(); +(function(){"use strict";function Administration(){}Administration.$factory=["$q","$timeout","$log","sgSettings","Resource","User",function($q,$timeout,$log,Settings,Resource,User){angular.extend(Administration,{$q:$q,$timeout:$timeout,$log:$log,$$resource:new Resource(Settings.activeUser("folderURL"),Settings.activeUser()),activeUser:Settings.activeUser(),$User:User});return new Administration}];try{angular.module("SOGo.AdministrationUI")}catch(e){angular.module("SOGo.AdministrationUI",["SOGo.Common"])}angular.module("SOGo.AdministrationUI").factory("Administration",Administration.$factory)})(); //# sourceMappingURL=Administration.services.js.map \ No newline at end of file diff --git a/UI/WebServerResources/js/Contacts.js b/UI/WebServerResources/js/Contacts.js index b7304d6f7..97b69bc68 100644 --- a/UI/WebServerResources/js/Contacts.js +++ b/UI/WebServerResources/js/Contacts.js @@ -1,2 +1,2 @@ -!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",["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("xs")&&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)}(); +(function(){"use strict";angular.module("SOGo.ContactsUI",["ui.router","angularFileUpload","ck","SOGo.Common","SOGo.PreferencesUI","SOGo.MailerUI"]).config(configure).run(runBlock);configure.$inject=["$stateProvider","$urlRouterProvider"];function configure($stateProvider,$urlRouterProvider){$stateProvider.state("app",{url:"/addressbooks","abstract":true,views:{addressbooks:{templateUrl:"UIxContactFoldersView",controller:"AddressBooksController",controllerAs:"app"}},resolve:{stateAddressbooks:stateAddressbooks}}).state("app.addressbook",{url:"/:addressbookId",views:{addressbook:{templateUrl:"addressbook",controller:"AddressBookController",controllerAs:"addressbook"}},resolve:{stateAddressbook:stateAddressbook}}).state("app.addressbook.new",{url:"/{contactType:(?:card|list)}/new",views:{card:{templateUrl:"UIxContactEditorTemplate",controller:"CardController",controllerAs:"editor"}},resolve:{stateCard:stateNewCard}}).state("app.addressbook.card",{url:"/:cardId","abstract":true,views:{card:{template:""}},resolve:{stateCard:stateCard}}).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"}}});$urlRouterProvider.otherwise("/addressbooks/personal")}stateAddressbooks.$inject=["AddressBook"];function stateAddressbooks(AddressBook){return AddressBook.$findAll(window.contactFolders)}stateAddressbook.$inject=["$q","$state","$stateParams","AddressBook"];function stateAddressbook($q,$state,$stateParams,AddressBook){var addressbook=_.find(AddressBook.$findAll(),function(addressbook){return addressbook.id==$stateParams.addressbookId});if(addressbook){addressbook.$reload();return addressbook}return $q.reject("Addressbook "+$stateParams.addressbookId+" not found")}stateNewCard.$inject=["$stateParams","stateAddressbook","Card"];function stateNewCard($stateParams,stateAddressbook,Card){var tag="v"+$stateParams.contactType,card=new Card({pid:$stateParams.addressbookId,c_component:tag});stateAddressbook.selectedCard=true;return card}stateCard.$inject=["$stateParams","stateAddressbook"];function stateCard($stateParams,stateAddressbook){stateAddressbook.selectedCard=$stateParams.cardId;return stateAddressbook.$getCard($stateParams.cardId)}runBlock.$inject=["$rootScope","$log","$state"];function runBlock($rootScope,$log,$state){$rootScope.$on("$stateChangeError",function(event,toState,toParams,fromState,fromParams,error){$log.error(error);$state.go("app.addressbook",{addressbookId:"personal"})});$rootScope.$on("$routeChangeError",function(event,current,previous,rejection){$log.error(event,current,previous,rejection)})}})();(function(){"use strict";AddressBookController.$inject=["$scope","$q","$state","$timeout","$mdDialog","Account","Card","AddressBook","Dialog","sgSettings","stateAddressbooks","stateAddressbook"];function AddressBookController($scope,$q,$state,$timeout,$mdDialog,Account,Card,AddressBook,Dialog,Settings,stateAddressbooks,stateAddressbook){var vm=this;AddressBook.selectedFolder=stateAddressbook;vm.service=AddressBook;vm.selectedFolder=stateAddressbook;vm.selectCard=selectCard;vm.toggleCardSelection=toggleCardSelection;vm.newComponent=newComponent;vm.notSelectedComponent=notSelectedComponent;vm.unselectCards=unselectCards;vm.confirmDeleteSelectedCards=confirmDeleteSelectedCards;vm.saveSelectedCards=saveSelectedCards;vm.copySelectedCards=copySelectedCards;vm.selectAll=selectAll;vm.sort=sort;vm.sortedBy=sortedBy;vm.cancelSearch=cancelSearch;vm.newMessage=newMessage;vm.newMessageWithSelectedCards=newMessageWithSelectedCards;vm.newMessageWithRecipient=newMessageWithRecipient;vm.mode={search:false};function selectCard(card){$state.go("app.addressbook.card.view",{addressbookId:stateAddressbook.id,cardId:card.id})}function toggleCardSelection($event,card){card.selected=!card.selected;$event.preventDefault();$event.stopPropagation()}function newComponent(ev){$mdDialog.show({parent:angular.element(document.body),targetEvent:ev,clickOutsideToClose:true,escapeToClose:true,template:[''," ",'
'," "," "+l("Contact")," "," "," "+l("List")," ","
","
","
"].join(""),locals:{addressbookId:vm.selectedFolder.id},controller:ComponentDialogController});ComponentDialogController.$inject=["scope","$mdDialog","$state","addressbookId"];function ComponentDialogController(scope,$mdDialog,$state,addressbookId){scope.create=function(type){$mdDialog.hide();$state.go("app.addressbook.new",{addressbookId:addressbookId,contactType:type})}}}function notSelectedComponent(currentCard,type){return currentCard&¤tCard.c_component==type&&!currentCard.selected}function unselectCards(){_.each(vm.selectedFolder.cards,function(card){card.selected=false})}function confirmDeleteSelectedCards(){Dialog.confirm(l("Warning"),l("Are you sure you want to delete the selected contacts?")).then(function(){var selectedCards=_.filter(vm.selectedFolder.cards,function(card){return card.selected});vm.selectedFolder.$deleteCards(selectedCards);delete vm.selectedFolder.selectedCard},function(data,status){})}function saveSelectedCards(){var selectedCards=_.filter(vm.selectedFolder.cards,function(card){return card.selected});var selectedUIDs=_.pluck(selectedCards,"id");window.location.href=ApplicationBaseURL+"/"+vm.selectedFolder.id+"/export?uid="+selectedUIDs.join("&uid=")}function copySelectedCards(folder){var selectedCards=_.filter(vm.selectedFolder.cards,function(card){return card.selected});vm.selectedFolder.$copyCards(selectedCards,folder).then(function(){},function(error){Dialog.alert(l("Error"),error)})}function selectAll(){_.each(vm.selectedFolder.cards,function(card){card.selected=true})}function sort(field){vm.selectedFolder.$filter("",{sort:field})}function sortedBy(field){return AddressBook.$query.sort==field}function cancelSearch(){vm.mode.search=false;vm.selectedFolder.$filter("")}function newMessage($event,recipients){Account.$findAll().then(function(accounts){var account=_.filter(accounts,function(o){if(o.id===0)return o})[0];account.$getMailboxes().then(function(mailboxes){account.$newMessage().then(function(message){$mdDialog.show({parent:angular.element(document.body),targetEvent:$event,clickOutsideToClose:false,escapeToClose:false,templateUrl:"../Mail/UIxMailEditor",controller:"MessageEditorController",controllerAs:"editor",locals:{stateAccounts:accounts,stateMessage:message,stateRecipients:recipients}})})})})}function newMessageWithRecipient($event,recipient,fn){var recipients=[{full:fn+" <"+recipient+">"}];vm.newMessage($event,recipients);$event.stopPropagation();$event.preventDefault()}function newMessageWithSelectedCards($event){var selectedCards=_.filter(vm.selectedFolder.cards,function(card){return card.selected});var promises=[],recipients=[];_.each(selectedCards,function(card){if(card.c_component=="vcard"&&card.c_mail.length){recipients.push({full:card.c_cn+" <"+card.c_mail+">"})}else if(card.c_component=="vlist"){if(angular.isDefined(card.refs)&&card.refs.length){_.each(card.refs,function(ref){if(ref.email.length)recipients.push({full:ref.c_cn+" <"+ref.email+">"})})}else{promises.push(vm.selectedFolder.$getCard(card.id).then(function(card){return card.$futureCardData.then(function(data){_.each(data.refs,function(ref){if(ref.email.length)recipients.push({full:ref.c_cn+" <"+ref.email+">"})})})}))}}});$q.all(promises).then(function(){if(recipients.length)vm.newMessage($event,recipients)})}}angular.module("SOGo.ContactsUI").controller("AddressBookController",AddressBookController)})();(function(){"use strict";AddressBooksController.$inject=["$state","$scope","$rootScope","$stateParams","$timeout","$mdDialog","$mdToast","$mdMedia","$mdSidenav","FileUploader","sgFocus","Card","AddressBook","Dialog","sgSettings","User","stateAddressbooks"];function AddressBooksController($state,$scope,$rootScope,$stateParams,$timeout,$mdDialog,$mdToast,$mdMedia,$mdSidenav,FileUploader,focus,Card,AddressBook,Dialog,Settings,User,stateAddressbooks){var vm=this;vm.activeUser=Settings.activeUser;vm.service=AddressBook;vm.select=select;vm.newAddressbook=newAddressbook;vm.edit=edit;vm.revertEditing=revertEditing;vm.save=save;vm.confirmDelete=confirmDelete;vm.importCards=importCards;vm.exportCards=exportCards;vm.showLinks=showLinks;vm.showProperties=showProperties;vm.share=share;vm.subscribeToFolder=subscribeToFolder;function select($event,folder){if($state.params.addressbookId!=folder.id&&vm.editMode!=folder.id){vm.editMode=false;AddressBook.$query.value="";if($mdMedia("xs"))$mdSidenav("left").close();$state.go("app.addressbook",{addressbookId:folder.id})}else{$event.preventDefault();$event.stopPropagation()}}function newAddressbook(){Dialog.prompt(l("New addressbook"),l("Name of new addressbook")).then(function(name){var addressbook=new AddressBook({name:name,isEditable:true,isRemote:false,owner:UserLogin});AddressBook.$add(addressbook)})}function edit(folder){if(!folder.isRemote){vm.editMode=folder.id;vm.originalAddressbook=angular.extend({},folder.$omit());focus("addressBookName_"+folder.id)}}function revertEditing(folder){folder.name=vm.originalAddressbook.name;vm.editMode=false}function save(folder){var name=folder.name;if(name&&name.length>0&&name!=vm.originalAddressbook.name){folder.$rename(name).then(function(data){vm.editMode=false},function(data,status){Dialog.alert(l("Warning"),data)})}}function confirmDelete(){if(vm.service.selectedFolder.isSubscription){vm.service.selectedFolder.$delete().then(function(){vm.service.selectedFolder=null;$state.go("app.addressbook",{addressbookId:"personal"})},function(data,status){Dialog.alert(l('An error occured while deleting the addressbook "%{0}".',vm.service.selectedFolder.name),l(data.error))})}else{Dialog.confirm(l("Warning"),l("Are you sure you want to delete the addressbook %{0}?",vm.service.selectedFolder.name)).then(function(){return vm.service.selectedFolder.$delete()}).then(function(){vm.service.selectedFolder=null;return true}).catch(function(response){var message=response.data.message||response.statusText;Dialog.alert(l('An error occured while deleting the addressbook "%{0}".',vm.service.selectedFolder.name),message)})}}function importCards($event,folder){$mdDialog.show({parent:angular.element(document.body),targetEvent:$event,clickOutsideToClose:true,escapeToClose:true,templateUrl:"UIxContactsImportDialog",controller:CardsImportDialogController,controllerAs:"$CardsImportDialogController",locals:{folder:folder}});CardsImportDialogController.$inject=["scope","$mdDialog","folder"];function CardsImportDialogController(scope,$mdDialog,folder){var vm=this;vm.uploader=new FileUploader({url:ApplicationBaseURL+[folder.id,"import"].join("/"),autoUpload:true,queueLimit:1,filters:[{name:filterByExtension,fn:filterByExtension}],onSuccessItem:function(item,response,status,headers){var msg;$mdDialog.hide();if(response.imported===0)msg=l("No card was imported.");else{msg=l("A total of %{0} cards were imported in the addressbook.",response.imported);AddressBook.selectedFolder.$reload()}$mdToast.show($mdToast.simple().content(msg).position("top right").hideDelay(3e3))},onErrorItem:function(item,response,status,headers){$mdToast.show({template:["",'
',' error_outline'," "+l("An error occured while importing contacts.")+"","
","
"].join(""),position:"top right",hideDelay:3e3})}});vm.close=function(){$mdDialog.hide()};function filterByExtension(item){var isTextFile=item.type.indexOf("text")===0||/\.(ldif|vcf|vcard)$/.test(item.name);if(!isTextFile)$mdToast.show({template:["",'
',' error_outline'," "+l("Select a vCard or LDIF file.")+"","
","
"].join(""),position:"top right",hideDelay:3e3});return isTextFile}}}function exportCards(){window.location.href=ApplicationBaseURL+"/"+vm.service.selectedFolder.id+"/exportFolder"}function showLinks(addressbook){$mdDialog.show({parent:angular.element(document.body),clickOutsideToClose:true,escapeToClose:true,templateUrl:addressbook.id+"/links",controller:LinksDialogController,controllerAs:"links",locals:{addressbook:addressbook}});LinksDialogController.$inject=["$mdDialog","addressbook"];function LinksDialogController($mdDialog,addressbook){var vm=this;this.addressbook=addressbook;this.close=close;function close(){$mdDialog.hide()}}}function showProperties(addressbook){$mdDialog.show({templateUrl:addressbook.id+"/properties",controller:PropertiesDialogController,controllerAs:"properties",clickOutsideToClose:true,escapeToClose:true,locals:{srcAddressBook:addressbook}}).catch(function(){});PropertiesDialogController.$inject=["$scope","$mdDialog","srcAddressBook"];function PropertiesDialogController($scope,$mdDialog,srcAddressBook){var vm=this;vm.addressbook=new AddressBook(srcAddressBook.$omit());vm.saveProperties=saveProperties;vm.close=close;function saveProperties(){vm.addressbook.$save().then(function(){srcAddressBook.init(vm.addressbook.$omit());$mdDialog.hide()},function(){})}function close(){$mdDialog.cancel()}}}function share(addressbook){addressbook.$acl.$users().then(function(){$mdDialog.show({templateUrl:addressbook.id+"/UIxAclEditor",controller:"AclController",controllerAs:"acl",clickOutsideToClose:true,escapeToClose:true,locals:{usersWithACL:addressbook.$acl.users,User:User,folder:addressbook}})})}function subscribeToFolder(addressbookData){console.debug("subscribeToFolder "+addressbookData.owner+addressbookData.name);AddressBook.$subscribe(addressbookData.owner,addressbookData.name).then(function(data){$mdToast.show($mdToast.simple().content(l("Sucessfully subscribed to address book")).position("top right").hideDelay(3e3))})}}angular.module("SOGo.ContactsUI").controller("AddressBooksController",AddressBooksController)})();(function(){"use strict";CardController.$inject=["$scope","$timeout","$mdDialog","AddressBook","Card","Dialog","sgFocus","$state","$stateParams","stateCard"];function CardController($scope,$timeout,$mdDialog,AddressBook,Card,Dialog,focus,$state,$stateParams,stateCard){var vm=this;vm.card=stateCard;vm.currentFolder=AddressBook.selectedFolder;vm.allEmailTypes=Card.$EMAIL_TYPES;vm.allTelTypes=Card.$TEL_TYPES;vm.allUrlTypes=Card.$URL_TYPES;vm.allAddressTypes=Card.$ADDRESS_TYPES;vm.categories={};vm.userFilterResults=[];vm.addOrgUnit=addOrgUnit;vm.addBirthday=addBirthday;vm.addScreenName=addScreenName;vm.addEmail=addEmail;vm.addPhone=addPhone;vm.addUrl=addUrl;vm.addAddress=addAddress;vm.addMember=addMember;vm.userFilter=userFilter;vm.save=save;vm.close=close;vm.reset=reset;vm.cancel=cancel;vm.confirmDelete=confirmDelete;vm.exportCard=exportCard;vm.toggleRawSource=toggleRawSource;vm.showRawSource=false;function addOrgUnit(){var i=vm.card.$addOrgUnit("");focus("orgUnit_"+i)}function addBirthday(){vm.card.birthday=new Date}function addScreenName(){vm.card.$addScreenName("")}function addEmail(){var i=vm.card.$addEmail("");focus("email_"+i)}function addPhone(){var i=vm.card.$addPhone("");focus("phone_"+i)}function addUrl(){var i=vm.card.$addUrl("","");focus("url_"+i)}function addAddress(){var i=vm.card.$addAddress("","","","","","","","");focus("address_"+i)}function addMember(){var i=vm.card.$addMember("");focus("ref_"+i)}function userFilter($query,excludedCards){AddressBook.selectedFolder.$filter($query,{dry:true,excludeLists:true},excludedCards);return AddressBook.selectedFolder.$cards}function save(form){if(form.$valid){vm.card.$save().then(function(data){var i=_.indexOf(_.pluck(AddressBook.selectedFolder.cards,"id"),vm.card.id);if(i<0){AddressBook.selectedFolder.$reload()}else{AddressBook.selectedFolder.cards[i]=angular.copy(vm.card)}$state.go("app.addressbook.card.view",{cardId:vm.card.id})}).catch(function(err){console.log(err)})}}function close(){$state.go("app.addressbook",{addressbookId:AddressBook.selectedFolder.id}).then(function(){vm.card=null;delete AddressBook.selectedFolder.selectedCard})}function reset(){vm.card.$reset()}function cancel(){vm.card.$reset();if(vm.card.isNew){vm.card=null;delete AddressBook.selectedFolder.selectedCard;$state.go("app.addressbook",{addressbookId:AddressBook.selectedFolder.id})}else{$state.go("app.addressbook.card.view",{cardId:vm.card.id})}}function confirmDelete(card){Dialog.confirm(l("Warning"),l("Are you sure you want to delete the card of %{0}?",card.$fullname()),{ok:l("Yes"),cancel:l("No")}).then(function(){card.$delete().then(function(){AddressBook.selectedFolder.cards=_.reject(AddressBook.selectedFolder.cards,function(o){return o.id==card.id});close()},function(data,status){Dialog.alert(l("Warning"),l('An error occured while deleting the card "%{0}".',card.$fullname()))})})}function exportCard(){window.location.href=ApplicationBaseURL+"/"+vm.currentFolder.id+"/export?uid="+vm.card.id}function toggleRawSource($event){if(!vm.showRawSource&&!vm.rawSource){Card.$$resource.post(vm.currentFolder.id+"/"+vm.card.id,"raw").then(function(data){vm.rawSource=data;vm.showRawSource=true})}else{vm.showRawSource=!vm.showRawSource}}}angular.module("SOGo.ContactsUI").controller("CardController",CardController)})();(function(){"use strict";function sgAddress(){return{restrict:"A",scope:{data:"=sgAddress"},controller:["$scope",function($scope){$scope.addressLines=function(data){var lines=[],locality_region=[];if(data.street)lines.push(data.street);if(data.street2)lines.push(data.street2);if(data.locality)locality_region.push(data.locality);if(data.region)locality_region.push(data.region);if(locality_region.length>0)lines.push(locality_region.join(", "));if(data.country)lines.push(data.country);if(data.postalcode)lines.push(data.postalcode);return lines.join("
")}}],template:'
'}}angular.module("SOGo.Common").directive("sgAddress",sgAddress)})(); //# sourceMappingURL=Contacts.js.map \ No newline at end of file diff --git a/UI/WebServerResources/js/Contacts.services.js b/UI/WebServerResources/js/Contacts.services.js index e035d8e48..6eb83abdd 100644 --- a/UI/WebServerResources/js/Contacts.services.js +++ b/UI/WebServerResources/js/Contacts.services.js @@ -1,2 +1,2 @@ -!function(){"use strict";function a(b){if("function"!=typeof b.then)if(this.init(b),this.name&&!this.id){var c=a.$$resource.create("createFolder",this.name);this.$unwrap(c)}else this.id&&(this.$acl=new a.$$Acl("Contacts/"+this.id));else this.$unwrap(b)}a.$factory=["$q","$timeout","$log","sgSettings","Resource","Card","Acl","Preferences",function(b,c,d,e,f,g,h,i){return angular.extend(a,{$q:b,$timeout:c,$log:d,$$resource:new f(e.activeUser("folderURL")+"Contacts",e.activeUser()),$Card:g,$$Acl:h,$Preferences:i,$query:{search:"name_or_address",value:"",sort:"c_cn",asc:1},activeUser:e.activeUser(),selectedFolder:null,$refreshTimeout:null}),i.ready().then(function(){i.settings.Contact.SortingState&&(a.$query.sort=i.settings.Contact.SortingState[0],a.$query.asc=parseInt(i.settings.Contact.SortingState[1]))}),a}];try{angular.module("SOGo.ContactsUI")}catch(b){angular.module("SOGo.ContactsUI",["SOGo.Common","SOGo.PreferencesUI"])}angular.module("SOGo.ContactsUI").factory("AddressBook",a.$factory),a.$filterAll=function(b,c,d){var e={search:b};if(!b)return a.$cards=[],a.$q.when(a.$cards);if(angular.isUndefined(a.$cards))a.$cards=[];else if(a.$query.value==b)return a.$q.when(a.$cards);return a.$query.value=b,angular.extend(e,c),a.$$resource.fetch(null,"allContactSearch",e).then(function(c){var e,f,g,h=function(a){return this.id==a.id};for(e=d?_.filter(c.contacts,function(a){return _.isUndefined(_.find(d,h,a))}):c.contacts,g=a.$cards.length-1;g>=0;g--)f=a.$cards[g],_.isUndefined(_.find(e,h,f))&&a.$cards.splice(g,1);return _.each(e,function(c,d){if(_.isUndefined(_.find(a.$cards,h,c))){var e=new a.$Card(c,b);a.$cards.splice(d,0,e)}}),a.$log.debug(a.$cards),a.$cards})},a.$add=function(a){var b,c,d;b=a.isSubscription?this.$subscriptions:this.$addressbooks,c=_.find(b,function(b){return"personal"==a.id||"personal"!=b.id&&1===b.name.localeCompare(a.name)}),d=c?_.indexOf(_.pluck(b,"id"),c.id):1,b.splice(d,0,a)},a.$findAll=function(b){var c=this;return b&&(this.$addressbooks=[],this.$subscriptions=[],this.$remotes=[],angular.forEach(b,function(b,d){var e=new a(b);e.isRemote?c.$remotes.push(e):e.isSubscription?c.$subscriptions.push(e):c.$addressbooks.push(e)})),_.union(this.$addressbooks,this.$subscriptions,this.$remotes)},a.$find=function(b){var c=a.$Preferences.ready().then(function(){return a.$$resource.fetch(b,"view",a.$query)});return new a(c)},a.$subscribe=function(b,c){var d=this;return a.$$resource.userResource(b).fetch(c,"subscribe").then(function(b){var c=new a(b);return _.isUndefined(_.find(d.$subscriptions,function(a){return a.id==b.id}))&&a.$add(c),c})},a.prototype.init=function(b,c){this.$cards||(this.$isLoading=!0,this.$cards=[],this.cards=[]),angular.extend(this,b),this.isOwned=a.activeUser.isSuperUser||this.owner==a.activeUser.login,this.isSubscription=!this.isRemote&&this.owner!=a.activeUser.login},a.prototype.$id=function(){return this.id?a.$q.when(this.id):this.$futureAddressBookData.then(function(a){return a.id})},a.prototype.isSelectedCard=function(a){return this.selectedCard==a},a.prototype.$selectedCount=function(){var a;return a=0,this.cards&&(a=_.filter(this.cards,function(a){return a.selected}).length),a},a.prototype.$startRefreshTimeout=function(){var b=this;a.$refreshTimeout&&a.$timeout.cancel(a.$refreshTimeout),a.$Preferences.ready().then(function(){var c=a.$Preferences.defaults.SOGoRefreshViewCheck;if(c&&"manually"!=c){var d=angular.bind(b,a.prototype.$reload);a.$refreshTimeout=a.$timeout(d,1e3*c.timeInterval())}})},a.prototype.$reload=function(){return this.$startRefreshTimeout(),this.$filter()},a.prototype.$filter=function(b,c,d){var e=this;return c&&c.dry||(this.$isLoading=!0),a.$Preferences.ready().then(function(){if(c&&(angular.extend(a.$query,c),c.dry)){if(!b)return e.$cards=[],a.$q.when(e.$cards);if(a.$query.value==b)return a.$q.when(e.$cards)}return angular.isDefined(b)&&(a.$query.value=b),e.$id().then(function(b){return a.$$resource.fetch(b,"view",a.$query)}).then(function(f){var g,h,i,j,k=function(a){return e.id==a.id};for(h=c&&c.dry?e.$cards:e.cards,g=d?_.filter(f.cards,function(a){return _.isUndefined(_.find(d,k,a))}):f.cards,j=h.length-1;j>=0;j--)i=h[j],_.isUndefined(_.find(g,k,i))&&h.splice(j,1);return _.each(g,function(c,d){if(_.isUndefined(_.find(h,k,c))){var e=new a.$Card(c,b);h.splice(d,0,e)}}),_.each(g,function(a,b){var c,d;h[b].id!=a.id&&(c=_.findIndex(h,k,a),d=h.splice(c,1),h.splice(b,0,d[0]))}),e.$isLoading=!1,h})})},a.prototype.$rename=function(b){var c=_.indexOf(_.pluck(a.$addressbooks,"id"),this.id);return this.name=b,a.$addressbooks.splice(c,1),a.$add(this),this.$save()},a.prototype.$delete=function(){var b,c,d=this,e=a.$q.defer();return this.isSubscription?(c=a.$$resource.fetch(this.id,"unsubscribe"),b=a.$subscriptions):(c=a.$$resource.remove(this.id),b=a.$addressbooks),c.then(function(){var a=_.indexOf(_.pluck(b,"id"),d.id);b.splice(a,1),e.resolve()},e.reject),e.promise},a.prototype.$deleteCards=function(b){var c=_.map(b,function(a){return a.id}),d=this;return a.$$resource.post(this.id,"batchDelete",{uids:c}).then(function(){d.cards=_.difference(d.cards,b)})},a.prototype.$copyCards=function(b,c){var d=_.map(b,function(a){return a.id});return a.$$resource.post(this.id,"copy",{uids:d,folder:c})},a.prototype.$save=function(){return a.$$resource.save(this.id,this.$omit()).then(function(a){return a})},a.prototype.$getCard=function(b){var c=this;return this.$id().then(function(d){var e,f=_.find(c.cards,function(a){return b==a.id});return f&&f.$futureCardData?f:(e=a.$Card.$find(d,b),e.$id().then(function(a){f&&angular.extend(f,e)}),e)})},a.prototype.$unwrap=function(b){var c=this;this.$futureAddressBookData=b.then(function(b){return a.$timeout(function(){return angular.forEach(a.$findAll(),function(a,d){a.id==b.id&&angular.extend(c,a)}),c.init(b),angular.forEach(c.cards,function(b,d){c.cards[d]=new a.$Card(b)}),c.$acl=new a.$$Acl("Contacts/"+c.id),c.$startRefreshTimeout(),c.$isLoading=!1,c})},function(b){c.isError=!0,angular.isObject(b)&&a.$timeout(function(){angular.extend(c,b)})})},a.prototype.$omit=function(){var a={};return angular.forEach(this,function(b,c){"constructor"!=c&&"cards"!=c&&"$"!=c[0]&&(a[c]=b)}),a}}(),function(){"use strict";function a(b,c){if("function"!=typeof b.then){if(this.init(b,c),this.pid&&!this.id){var d=a.$$resource.newguid(this.pid);this.$unwrap(d),this.isNew=!0}}else this.$unwrap(b)}a.$TEL_TYPES=["work","home","cell","fax","pager"],a.$EMAIL_TYPES=["work","home","pref"],a.$URL_TYPES=["work","home","pref"],a.$ADDRESS_TYPES=["work","home"],a.$factory=["$timeout","sgSettings","Resource","Preferences","Gravatar",function(b,c,d,e,f){return angular.extend(a,{$$resource:new d(c.activeUser("folderURL")+"Contacts",c.activeUser()),$timeout:b,$gravatar:f}),e.ready().then(function(){e.defaults.SOGoContactsCategories&&(a.$categories=e.defaults.SOGoContactsCategories),e.defaults.SOGoAlternateAvatar&&(a.$alternateAvatar=e.defaults.SOGoAlternateAvatar)}),a}];try{angular.module("SOGo.ContactsUI")}catch(b){angular.module("SOGo.ContactsUI",["SOGo.Common","SOGo.PreferencesUI"])}angular.module("SOGo.ContactsUI").factory("Card",a.$factory),a.$find=function(b,c){var d=this.$$resource.fetch([b,c].join("/"),"view");return c?new a(d):a.$unwrapCollection(d)},a.filterCategories=function(b){var c=new RegExp(b,"i");return _.filter(a.$categories,function(a){return-1!=a.search(c)})},a.$unwrapCollection=function(b){var c={};return c.$futureCardData=b,b.then(function(b){a.$timeout(function(){angular.forEach(b,function(b,d){c[b.id]=new a(b)})})}),c},a.prototype.init=function(b,c){this.refs=[],angular.extend(this,b),this.$$fullname||(this.$$fullname=this.$fullname()),this.$$email||(this.$$email=this.$preferredEmail(c)),this.$$image||(this.$$image=this.image||a.$gravatar(this.$preferredEmail(c),32,a.$alternateAvatar,{no_404:!0})),this.selected=!1,this.empty=" "},a.prototype.$id=function(){return this.$futureCardData.then(function(a){return a.id})},a.prototype.$save=function(){var b=this,c="saveAsContact";return"vlist"==this.c_component&&(c="saveAsList"),a.$$resource.save([this.pid,this.id||"_new_"].join("/"),this.$omit(),{action:c}).then(function(a){return b.$shadowData=b.$omit(!0),a})},a.prototype.$delete=function(b,c){return b?void(c>-1&&this[b].length>c?this[b].splice(c,1):delete this[b]):a.$$resource.remove([this.pid,this.id].join("/"))},a.prototype.$fullname=function(){var a,b=this.c_cn||"";return 0===b.length&&(a=[],this.c_givenname&&this.c_givenname.length>0&&a.push(this.c_givenname),this.nickname&&this.nickname.length>0&&a.push(""+this.nickname+""),this.c_sn&&this.c_sn.length>0&&a.push(this.c_sn),a.length>0?b=a.join(" "):this.c_org&&this.c_org.length>0?b=this.c_org:this.emails&&this.emails.length>0?b=_.find(this.emails,function(a){return""!==a.value}).value:this.c_cn&&this.c_cn.length>0&&(b=this.c_cn)),b},a.prototype.$description=function(){var a=[];return this.title&&a.push(this.title),this.role&&a.push(this.role),this.orgUnits&&this.orgUnits.length>0&&_.forEach(this.orgUnits,function(b){""!==b.value&&a.push(b.value)}),this.c_org&&a.push(this.c_org),this.description&&a.push(this.description),a.join(", ")},a.prototype.$preferredEmail=function(a){var b,c;return a&&(c=new RegExp(a,"i"),b=_.find(this.emails,function(a){return c.test(a.value)})),b?b=b.value:(b=_.find(this.emails,function(a){return"pref"==a.type}),b=b?b.value:this.emails&&this.emails.length?this.emails[0].value:""),b},a.prototype.$shortFormat=function(a){var b=[this.$$fullname],c=this.$preferredEmail(a);return c&&c!=this.$$fullname&&b.push(" <"+c+">"),b.join(" ")},a.prototype.$birthday=function(){return this.birthday?[this.birthday.getFullYear(),this.birthday.getMonth()+1,this.birthday.getDate()].join("/"):""},a.prototype.$isCard=function(){return"vcard"==this.c_component},a.prototype.$isList=function(){return"vlist"==this.c_component},a.prototype.$addOrgUnit=function(a){if(angular.isUndefined(this.orgUnits))this.orgUnits=[{value:a}];else{for(var b=0;b"),"["+a+"]"}}(); +(function(){"use strict";function AddressBook(futureAddressBookData){if(typeof futureAddressBookData.then!=="function"){this.init(futureAddressBookData);if(this.name&&!this.id){var newAddressBookData=AddressBook.$$resource.create("createFolder",this.name);this.$unwrap(newAddressBookData)}else if(this.id){this.$acl=new AddressBook.$$Acl("Contacts/"+this.id)}}else{this.$unwrap(futureAddressBookData)}}AddressBook.$factory=["$q","$timeout","$log","sgSettings","Resource","Card","Acl","Preferences",function($q,$timeout,$log,Settings,Resource,Card,Acl,Preferences){angular.extend(AddressBook,{$q:$q,$timeout:$timeout,$log:$log,$$resource:new Resource(Settings.activeUser("folderURL")+"Contacts",Settings.activeUser()),$Card:Card,$$Acl:Acl,$Preferences:Preferences,$query:{search:"name_or_address",value:"",sort:"c_cn",asc:1},activeUser:Settings.activeUser(),selectedFolder:null,$refreshTimeout:null});Preferences.ready().then(function(){if(Preferences.settings.Contact.SortingState){AddressBook.$query.sort=Preferences.settings.Contact.SortingState[0];AddressBook.$query.asc=parseInt(Preferences.settings.Contact.SortingState[1])}});return AddressBook}];try{angular.module("SOGo.ContactsUI")}catch(e){angular.module("SOGo.ContactsUI",["SOGo.Common","SOGo.PreferencesUI"])}angular.module("SOGo.ContactsUI").factory("AddressBook",AddressBook.$factory);AddressBook.$filterAll=function(search,options,excludedCards){var params={search:search};if(!search){AddressBook.$cards=[];return AddressBook.$q.when(AddressBook.$cards)}if(angular.isUndefined(AddressBook.$cards)){AddressBook.$cards=[]}else if(AddressBook.$query.value==search){return AddressBook.$q.when(AddressBook.$cards)}AddressBook.$query.value=search;angular.extend(params,options);return AddressBook.$$resource.fetch(null,"allContactSearch",params).then(function(response){var results,card,index,compareIds=function(data){return this.id==data.id};if(excludedCards){results=_.filter(response.contacts,function(data){return _.isUndefined(_.find(excludedCards,compareIds,data))})}else{results=response.contacts}for(index=AddressBook.$cards.length-1;index>=0;index--){card=AddressBook.$cards[index];if(_.isUndefined(_.find(results,compareIds,card))){AddressBook.$cards.splice(index,1)}}_.each(results,function(data,index){if(_.isUndefined(_.find(AddressBook.$cards,compareIds,data))){var card=new AddressBook.$Card(data,search);AddressBook.$cards.splice(index,0,card)}});AddressBook.$log.debug(AddressBook.$cards);return AddressBook.$cards})};AddressBook.$add=function(addressbook){var list,sibling,i;list=addressbook.isSubscription?this.$subscriptions:this.$addressbooks;sibling=_.find(list,function(o){return addressbook.id=="personal"||o.id!="personal"&&o.name.localeCompare(addressbook.name)===1});i=sibling?_.indexOf(_.pluck(list,"id"),sibling.id):1;list.splice(i,0,addressbook)};AddressBook.$findAll=function(data){var _this=this;if(data){this.$addressbooks=[];this.$subscriptions=[];this.$remotes=[];angular.forEach(data,function(o,i){var addressbook=new AddressBook(o);if(addressbook.isRemote)_this.$remotes.push(addressbook);else if(addressbook.isSubscription)_this.$subscriptions.push(addressbook);else _this.$addressbooks.push(addressbook)})}return _.union(this.$addressbooks,this.$subscriptions,this.$remotes)};AddressBook.$find=function(addressbookId){var futureAddressBookData=AddressBook.$Preferences.ready().then(function(){return AddressBook.$$resource.fetch(addressbookId,"view",AddressBook.$query)});return new AddressBook(futureAddressBookData)};AddressBook.$subscribe=function(uid,path){var _this=this;return AddressBook.$$resource.userResource(uid).fetch(path,"subscribe").then(function(addressbookData){var addressbook=new AddressBook(addressbookData);if(_.isUndefined(_.find(_this.$subscriptions,function(o){return o.id==addressbookData.id}))){AddressBook.$add(addressbook)}return addressbook})};AddressBook.prototype.init=function(data,options){if(!this.$cards){this.$isLoading=true;this.$cards=[];this.cards=[]}angular.extend(this,data);this.isOwned=AddressBook.activeUser.isSuperUser||this.owner==AddressBook.activeUser.login;this.isSubscription=!this.isRemote&&this.owner!=AddressBook.activeUser.login};AddressBook.prototype.$id=function(){if(this.id){return AddressBook.$q.when(this.id)}else{return this.$futureAddressBookData.then(function(addressbook){return addressbook.id})}};AddressBook.prototype.isSelectedCard=function(cardId){return this.selectedCard==cardId};AddressBook.prototype.$selectedCount=function(){var count;count=0;if(this.cards){count=_.filter(this.cards,function(card){return card.selected}).length}return count};AddressBook.prototype.$startRefreshTimeout=function(){var _this=this;if(AddressBook.$refreshTimeout)AddressBook.$timeout.cancel(AddressBook.$refreshTimeout);AddressBook.$Preferences.ready().then(function(){var refreshViewCheck=AddressBook.$Preferences.defaults.SOGoRefreshViewCheck;if(refreshViewCheck&&refreshViewCheck!="manually"){var f=angular.bind(_this,AddressBook.prototype.$reload);AddressBook.$refreshTimeout=AddressBook.$timeout(f,refreshViewCheck.timeInterval()*1e3)}})};AddressBook.prototype.$reload=function(){var _this=this;this.$startRefreshTimeout();return this.$filter()};AddressBook.prototype.$filter=function(search,options,excludedCards){var _this=this;if(!options||!options.dry)this.$isLoading=true;return AddressBook.$Preferences.ready().then(function(){if(options){angular.extend(AddressBook.$query,options);if(options.dry){if(!search){_this.$cards=[];return AddressBook.$q.when(_this.$cards)}else if(AddressBook.$query.value==search){return AddressBook.$q.when(_this.$cards)}}}if(angular.isDefined(search))AddressBook.$query.value=search;return _this.$id().then(function(addressbookId){return AddressBook.$$resource.fetch(addressbookId,"view",AddressBook.$query)}).then(function(response){var results,cards,card,index,compareIds=function(data){return _this.id==data.id};if(options&&options.dry){cards=_this.$cards}else{cards=_this.cards}if(excludedCards){results=_.filter(response.cards,function(card){return _.isUndefined(_.find(excludedCards,compareIds,card))})}else{results=response.cards}for(index=cards.length-1;index>=0;index--){card=cards[index];if(_.isUndefined(_.find(results,compareIds,card))){cards.splice(index,1)}}_.each(results,function(data,index){if(_.isUndefined(_.find(cards,compareIds,data))){var card=new AddressBook.$Card(data,search);cards.splice(index,0,card)}});_.each(results,function(data,index){var oldIndex,removedCards;if(cards[index].id!=data.id){oldIndex=_.findIndex(cards,compareIds,data);removedCards=cards.splice(oldIndex,1);cards.splice(index,0,removedCards[0])}});_this.$isLoading=false;return cards})})};AddressBook.prototype.$rename=function(name){var i=_.indexOf(_.pluck(AddressBook.$addressbooks,"id"),this.id);this.name=name;AddressBook.$addressbooks.splice(i,1);AddressBook.$add(this);return this.$save()};AddressBook.prototype.$delete=function(){var _this=this,d=AddressBook.$q.defer(),list,promise;if(this.isSubscription){promise=AddressBook.$$resource.fetch(this.id,"unsubscribe");list=AddressBook.$subscriptions}else{promise=AddressBook.$$resource.remove(this.id);list=AddressBook.$addressbooks}promise.then(function(){var i=_.indexOf(_.pluck(list,"id"),_this.id);list.splice(i,1);d.resolve()},d.reject);return d.promise};AddressBook.prototype.$deleteCards=function(cards){var uids=_.map(cards,function(card){return card.id});var _this=this;return AddressBook.$$resource.post(this.id,"batchDelete",{uids:uids}).then(function(){_this.cards=_.difference(_this.cards,cards)})};AddressBook.prototype.$copyCards=function(cards,folder){var uids=_.map(cards,function(card){return card.id});return AddressBook.$$resource.post(this.id,"copy",{uids:uids,folder:folder})};AddressBook.prototype.$save=function(){return AddressBook.$$resource.save(this.id,this.$omit()).then(function(data){return data})};AddressBook.prototype.$getCard=function(cardId){var _this=this;return this.$id().then(function(addressbookId){var fullCard,cachedCard=_.find(_this.cards,function(data){return cardId==data.id});if(cachedCard&&cachedCard.$futureCardData)return cachedCard;fullCard=AddressBook.$Card.$find(addressbookId,cardId);fullCard.$id().then(function(cardId){if(cachedCard)angular.extend(cachedCard,fullCard)});return fullCard})};AddressBook.prototype.$unwrap=function(futureAddressBookData){var _this=this;this.$futureAddressBookData=futureAddressBookData.then(function(data){return AddressBook.$timeout(function(){angular.forEach(AddressBook.$findAll(),function(o,i){if(o.id==data.id){angular.extend(_this,o)}});_this.init(data);angular.forEach(_this.cards,function(o,i){_this.cards[i]=new AddressBook.$Card(o)});_this.$acl=new AddressBook.$$Acl("Contacts/"+_this.id);_this.$startRefreshTimeout();_this.$isLoading=false;return _this})},function(data){_this.isError=true;if(angular.isObject(data)){AddressBook.$timeout(function(){angular.extend(_this,data)})}})};AddressBook.prototype.$omit=function(){var addressbook={};angular.forEach(this,function(value,key){if(key!="constructor"&&key!="cards"&&key[0]!="$"){addressbook[key]=value}});return addressbook}})();(function(){"use strict";function Card(futureCardData,partial){if(typeof futureCardData.then!=="function"){this.init(futureCardData,partial);if(this.pid&&!this.id){var newCardData=Card.$$resource.newguid(this.pid);this.$unwrap(newCardData);this.isNew=true}}else{this.$unwrap(futureCardData)}}Card.$TEL_TYPES=["work","home","cell","fax","pager"];Card.$EMAIL_TYPES=["work","home","pref"];Card.$URL_TYPES=["work","home","pref"];Card.$ADDRESS_TYPES=["work","home"];Card.$factory=["$timeout","sgSettings","Resource","Preferences","Gravatar",function($timeout,Settings,Resource,Preferences,Gravatar){angular.extend(Card,{$$resource:new Resource(Settings.activeUser("folderURL")+"Contacts",Settings.activeUser()),$timeout:$timeout,$gravatar:Gravatar});Preferences.ready().then(function(){if(Preferences.defaults.SOGoContactsCategories){Card.$categories=Preferences.defaults.SOGoContactsCategories}if(Preferences.defaults.SOGoAlternateAvatar)Card.$alternateAvatar=Preferences.defaults.SOGoAlternateAvatar});return Card}];try{angular.module("SOGo.ContactsUI")}catch(e){angular.module("SOGo.ContactsUI",["SOGo.Common","SOGo.PreferencesUI"])}angular.module("SOGo.ContactsUI").factory("Card",Card.$factory);Card.$find=function(addressbookId,cardId){var futureCardData=this.$$resource.fetch([addressbookId,cardId].join("/"),"view");if(cardId)return new Card(futureCardData);return Card.$unwrapCollection(futureCardData)};Card.filterCategories=function(query){var re=new RegExp(query,"i");return _.filter(Card.$categories,function(category){return category.search(re)!=-1})};Card.$unwrapCollection=function(futureCardData){var collection={};collection.$futureCardData=futureCardData;futureCardData.then(function(cards){Card.$timeout(function(){angular.forEach(cards,function(data,index){collection[data.id]=new Card(data)})})});return collection};Card.prototype.init=function(data,partial){this.refs=[];angular.extend(this,data);if(!this.$$fullname)this.$$fullname=this.$fullname();if(!this.$$email)this.$$email=this.$preferredEmail(partial);if(!this.$$image)this.$$image=this.image||Card.$gravatar(this.$preferredEmail(partial),32,Card.$alternateAvatar,{no_404:true});this.selected=false;this.empty=" "};Card.prototype.$id=function(){return this.$futureCardData.then(function(data){return data.id})};Card.prototype.$save=function(){var _this=this,action="saveAsContact";if(this.c_component=="vlist")action="saveAsList";return Card.$$resource.save([this.pid,this.id||"_new_"].join("/"),this.$omit(),{action:action}).then(function(data){_this.$shadowData=_this.$omit(true);return data})};Card.prototype.$delete=function(attribute,index){if(attribute){if(index>-1&&this[attribute].length>index){this[attribute].splice(index,1)}else delete this[attribute]}else{return Card.$$resource.remove([this.pid,this.id].join("/"))}};Card.prototype.$fullname=function(){var fn=this.c_cn||"",names;if(fn.length===0){names=[];if(this.c_givenname&&this.c_givenname.length>0)names.push(this.c_givenname);if(this.nickname&&this.nickname.length>0)names.push(""+this.nickname+"");if(this.c_sn&&this.c_sn.length>0)names.push(this.c_sn);if(names.length>0)fn=names.join(" ");else if(this.c_org&&this.c_org.length>0){fn=this.c_org}else if(this.emails&&this.emails.length>0){fn=_.find(this.emails,function(i){return i.value!==""}).value}else if(this.c_cn&&this.c_cn.length>0){fn=this.c_cn}}return fn};Card.prototype.$description=function(){var description=[];if(this.title)description.push(this.title);if(this.role)description.push(this.role);if(this.orgUnits&&this.orgUnits.length>0)_.forEach(this.orgUnits,function(unit){if(unit.value!=="")description.push(unit.value)});if(this.c_org)description.push(this.c_org);if(this.description)description.push(this.description);return description.join(", ")};Card.prototype.$preferredEmail=function(partial){var email,re;if(partial){re=new RegExp(partial,"i");email=_.find(this.emails,function(o){return re.test(o.value)})}if(email){email=email.value}else{email=_.find(this.emails,function(o){return o.type=="pref"});if(email){email=email.value}else if(this.emails&&this.emails.length){email=this.emails[0].value}else{email=""}}return email};Card.prototype.$shortFormat=function(partial){var fullname=[this.$$fullname],email=this.$preferredEmail(partial);if(email&&email!=this.$$fullname)fullname.push(" <"+email+">");return fullname.join(" ")};Card.prototype.$birthday=function(){if(this.birthday){return[this.birthday.getFullYear(),this.birthday.getMonth()+1,this.birthday.getDate()].join("/")}return""};Card.prototype.$isCard=function(){return this.c_component=="vcard"};Card.prototype.$isList=function(){return this.c_component=="vlist"};Card.prototype.$addOrgUnit=function(orgUnit){if(angular.isUndefined(this.orgUnits)){this.orgUnits=[{value:orgUnit}]}else{for(var i=0;i";return"["+desc+"]"}})(); //# sourceMappingURL=Contacts.services.js.map \ No newline at end of file diff --git a/UI/WebServerResources/js/Main.js b/UI/WebServerResources/js/Main.js index 2421b418b..a98571b73 100644 --- a/UI/WebServerResources/js/Main.js +++ b/UI/WebServerResources/js/Main.js @@ -1,2 +1,2 @@ -!function(){"use strict";function a(a,b,c,d,e){function f(){return e.login(h.creds).then(function(a){window.location.href===a?window.location.reload(!0):window.location.href=a},function(a){c.alert(l("Authentication Failed"),a.error)}),!1}function g(a){function b(a){this.closeDialog=function(){a.hide()}}d.show({targetEvent:a,templateUrl:"aboutBox.html",controller:b,controllerAs:"about"}),b.$inject=["$mdDialog"]}var h=this;h.creds={username:cookieUsername,password:null},h.login=f,h.showAbout=g,h.showLogin=!1,b(function(){h.showLogin=!0},100)}angular.module("SOGo.MainUI",["SOGo.Common","SOGo.Authentication"]),a.$inject=["$scope","$timeout","Dialog","$mdDialog","Authentication"],angular.module("SOGo.MainUI").controller("LoginController",a)}(); +(function(){"use strict";angular.module("SOGo.MainUI",["SOGo.Common","SOGo.Authentication"]);LoginController.$inject=["$scope","$timeout","Dialog","$mdDialog","Authentication"];function LoginController($scope,$timeout,Dialog,$mdDialog,Authentication){var vm=this;vm.creds={username:cookieUsername,password:null};vm.login=login;vm.showAbout=showAbout;vm.showLogin=false;$timeout(function(){vm.showLogin=true},100);function login(){Authentication.login(vm.creds).then(function(url){if(window.location.href===url)window.location.reload(true);else window.location.href=url},function(msg){Dialog.alert(l("Authentication Failed"),msg.error)});return false}function showAbout($event){$mdDialog.show({targetEvent:$event,templateUrl:"aboutBox.html",controller:AboutDialogController,controllerAs:"about"});AboutDialogController.$inject=["$mdDialog"];function AboutDialogController($mdDialog){this.closeDialog=function(){$mdDialog.hide()}}}}angular.module("SOGo.MainUI").controller("LoginController",LoginController)})(); //# sourceMappingURL=Main.js.map \ No newline at end of file diff --git a/UI/WebServerResources/js/Preferences.js b/UI/WebServerResources/js/Preferences.js index b1c69d760..4052eb0cc 100644 --- a/UI/WebServerResources/js/Preferences.js +++ b/UI/WebServerResources/js/Preferences.js @@ -1,2 +1,2 @@ -!function(){"use strict";function a(a,c){a.state("preferences",{"abstract":!0,views:{preferences:{templateUrl:"preferences.html",controller:"PreferencesController",controllerAs:"app"}},resolve:{statePreferences:b}}).state("preferences.general",{url:"/general",views:{module:{templateUrl:"generalPreferences.html"}}}).state("preferences.calendars",{url:"/calendars",views:{module:{templateUrl:"calendarsPreferences.html"}}}).state("preferences.addressbooks",{url:"/addressbooks",views:{module:{templateUrl:"addressbooksPreferences.html"}}}).state("preferences.mailer",{url:"/mailer",views:{module:{templateUrl:"mailerPreferences.html"}}}),c.otherwise("/general")}function b(a){return a}function c(a){a.$on("$routeChangeError",function(a,b,c,d){console.error(a,b,c,d)})}angular.module("SOGo.PreferencesUI",["ui.router","ck","SOGo.Common","SOGo.MailerUI","SOGo.ContactsUI","SOGo.Authentication"]).config(a).run(c),a.$inject=["$stateProvider","$urlRouterProvider"],b.$inject=["Preferences"],c.$inject=["$rootScope"]}(),function(){"use strict";function a(a,b,c,d,e){function f(){return d>0?!1:!e}function g(){a.cancel()}function h(){a.hide()}var i=this;i.defaults=b,i.account=c,i.accountId=d,i.customFromIsReadonly=f,i.cancel=g,i.save=h}a.$inject=["$mdDialog","defaults","account","accountId","mailCustomFromEnabled"],angular.module("SOGo.PreferencesUI").controller("AccountDialogController",a)}(),function(){"use strict";function a(a,b,c,d,e,f){function g(){c.cancel()}function h(a){c.hide()}function i(a){n.filter.rules||(n.filter.rules=[]),n.filter.rules.push({field:"subject",operator:"contains"})}function j(a){n.filter.rules.splice(a,1)}function k(a){n.filter.actions||(n.filter.actions=[]),n.filter.actions.push({method:"discard"})}function m(a){n.filter.actions.splice(a,1)}var n=this,o=b.sieveCapabilities;n.filter=d,n.mailboxes=e,n.labels=f,n.cancel=g,n.save=h,n.addMailFilterRule=i,n.removeMailFilterRule=j,n.addMailFilterAction=k,n.removeMailFilterAction=m,n.fieldLabels={subject:l("Subject"),from:l("From"),to:l("To"),cc:l("Cc"),to_or_cc:l("To or Cc"),size:l("Size (Kb)"),header:l("Header")},o.indexOf("body")>-1&&(n.fieldLabels.body=l("Body")),n.methodLabels={discard:l("Discard the message"),keep:l("Keep the message"),redirect:l("Forward the message to"),vacation:l("Send a vacation message"),stop:l("Stop processing filter rules")},o.indexOf("reject")>-1&&(n.methodLabels.reject=l("Send a reject message")),o.indexOf("fileinto")>-1&&(n.methodLabels.fileinto=l("File the message in")),(o.indexOf("imapflags")>-1||o.indexOf("imap4flags")>-1)&&(n.methodLabels.addflag=l("Flag the message with")),n.numberOperatorLabels={under:l("is under"),over:l("is over")},n.textOperatorLabels={is:l("is"),is_not:l("is not"),contains:l("contains"),contains_not:l("does not contain"),matches:l("matches"),matches_not:l("does not match")},o.indexOf("regex")>-1&&(n.textOperatorLabels.regex=l("matches regex"),n.textOperatorLabels.regex_not=l("does not match regex")),n.flagLabels={seen:l("Seen"),deleted:l("Deleted"),answered:l("Answered"),flagged:l("Flagged"),junk:l("Junk"),not_junk:l("Not Junk")}}a.$inject=["$scope","$window","$mdDialog","filter","mailboxes","labels"],angular.module("SOGo.PreferencesUI").controller("FiltersDialogController",a)}(),function(){"use strict";function a(a,b,c,d,e,f,g,h,i,j,k,m,n){function o(a){d("xs")&&e("left").close(),c.go("preferences."+a)}function p(){i.confirm(l("Warning"),l("Save preferences and reload page now?"),{ok:l("Yes"),cancel:l("No")}).then(function(){D().then(function(){b.location.reload(!0)})})}function q(){I.preferences.defaults.SOGoCalendarCategoriesColors["New category"]="#aaa",I.preferences.defaults.SOGoCalendarCategories.push("New category"),h("calendarCategory_"+(I.preferences.defaults.SOGoCalendarCategories.length-1))}function r(a){var b=I.preferences.defaults.SOGoCalendarCategories[a];I.preferences.defaults.SOGoCalendarCategories.splice(a,1),delete I.preferences.defaults.SOGoCalendarCategoriesColors[b]}function s(){I.preferences.defaults.SOGoContactsCategories.push(""),h("contactCategory_"+(I.preferences.defaults.SOGoContactsCategories.length-1))}function t(a){I.preferences.defaults.SOGoContactsCategories.splice(a,1)}function u(a){var b;I.preferences.defaults.AuxiliaryMailAccounts.push({}),b=_.last(I.preferences.defaults.AuxiliaryMailAccounts),b.name=l("New account"),b.identities=[{fullName:"",email:""}],b.receipts={receiptAction:"ignore",receiptNonRecipientAction:"ignore",receiptOutsideDomainAction:"ignore",receiptAnyAction:"ignore"},f.show({controller:"AccountDialogController",controllerAs:"$AccountDialogController",templateUrl:"editAccount?account=new",targetEvent:a,locals:{defaults:I.preferences.defaults,account:b,accountId:I.preferences.defaults.AuxiliaryMailAccounts.length-1,mailCustomFromEnabled:window.mailCustomFromEnabled}})}function v(a,b){var c=I.preferences.defaults.AuxiliaryMailAccounts[b];f.show({controller:"AccountDialogController",controllerAs:"$AccountDialogController",templateUrl:"editAccount?account="+b,targetEvent:a,locals:{defaults:I.preferences.defaults,account:c,accountId:b,mailCustomFromEnabled:window.mailCustomFromEnabled}}).then(function(){I.preferences.defaults.AuxiliaryMailAccounts[b]=c})}function w(a){I.preferences.defaults.AuxiliaryMailAccounts.splice(a,1)}function x(){var a="_$$"+guid();I.preferences.defaults.SOGoMailLabelsColors[a]=["New label","#aaa"]}function y(a){delete I.preferences.defaults.SOGoMailLabelsColors[a]}function z(a){var b={match:"all"};f.show({templateUrl:"editFilter?filter=new",controller:"FiltersDialogController",controllerAs:"filterEditor",targetEvent:a,locals:{filter:b,mailboxes:J,labels:I.preferences.defaults.SOGoMailLabelsColors}}).then(function(){I.preferences.defaults.SOGoSieveFilters||(I.preferences.defaults.SOGoSieveFilters=[]),I.preferences.defaults.SOGoSieveFilters.push(b)})}function A(a,b){var c=angular.copy(I.preferences.defaults.SOGoSieveFilters[b]);f.show({templateUrl:"editFilter?filter="+b,controller:"FiltersDialogController",controllerAs:"filterEditor",targetEvent:null,locals:{filter:c,mailboxes:J,labels:I.preferences.defaults.SOGoMailLabelsColors}}).then(function(){I.preferences.defaults.SOGoSieveFilters[b]=c})}function B(a){I.preferences.defaults.SOGoSieveFilters.splice(a,1)}function C(){var a=[];angular.isDefined(I.preferences.defaults.Vacation.autoReplyEmailAddresses)&&(a=I.preferences.defaults.Vacation.autoReplyEmailAddresses.split(",")),I.preferences.defaults.Vacation.autoReplyEmailAddresses=_.union(window.defaultEmailAddresses.split(","),a).join(",")}function D(){var b,c,d,e,f,h;if(c=!0,f=[],window.forwardConstraints>0&&angular.isDefined(I.preferences.defaults.Forward)&&I.preferences.defaults.Forward.enabled&&angular.isDefined(I.preferences.defaults.Forward.forwardAddress))for(d=I.preferences.defaults.Forward.forwardAddress.split(","),e=window.defaultEmailAddresses.split(/, */),_.forEach(e,function(a){var b=a.split("@")[1];b&&f.push(b.toLowerCase())}),b=0;b=0&&2==window.forwardConstraints&&(i.alert(l("Error"),l("You are not allowed to forward your messages to an internal email address.")),c=!1);return c?I.preferences.$save().then(function(a){g.show({controller:"savePreferencesToastCtrl",template:["",'
'," "+l("Preferences saved")+"",' '," close"," ","
","
"].join(""),hideDelay:2e3,position:"top right"})}):a.reject()}function E(){return I.passwords.newPassword&&I.passwords.newPassword.length>0&&I.passwords.newPasswordConfirmation&&I.passwords.newPasswordConfirmation.length&&I.passwords.newPassword==I.passwords.newPasswordConfirmation?!0:!1}function F(){n.changePassword(I.passwords.newPassword).then(function(){var a=f.alert({title:l("Password"),content:l("The password was changed successfully."),ok:l("OK")});f.show(a)["finally"](function(){a=void 0})},function(a){var b=f.alert({title:l("Password"),content:a,ok:l("OK")});f.show(b)["finally"](function(){b=void 0})})}function G(a){return _.filter(I.timeZonesList,function(b){return b.toUpperCase().indexOf(a.toUpperCase())>=0})}var H,I=this,J=[];I.preferences=m,I.passwords={newPassword:null,newPasswordConfirmation:null},I.go=o,I.onLanguageChange=p,I.addCalendarCategory=q,I.removeCalendarCategory=r,I.addContactCategory=s,I.removeContactCategory=t,I.addMailAccount=u,I.editMailAccount=v,I.removeMailAccount=w,I.addMailLabel=x,I.removeMailLabel=y,I.addMailFilter=z,I.editMailFilter=A,I.removeMailFilter=B,I.addDefaultEmailAddresses=C,I.userFilter=j.$filter,I.save=D,I.canChangePassword=E,I.changePassword=F,I.timeZonesList=window.timeZonesList,I.timeZonesListFilter=G,I.timeZonesSearchText="",H=new k({id:0}),H.$getMailboxes().then(function(){for(var a=H.$flattenMailboxes({all:!0}),b=-1,c=a.length;++b0)return false;return!mailCustomFromEnabled}function cancel(){$mdDialog.cancel()}function save(){$mdDialog.hide()}}angular.module("SOGo.PreferencesUI").controller("AccountDialogController",AccountDialogController)})();(function(){"use strict";FiltersDialogController.$inject=["$scope","$window","$mdDialog","filter","mailboxes","labels"];function FiltersDialogController($scope,$window,$mdDialog,filter,mailboxes,labels){var vm=this,sieveCapabilities=$window.sieveCapabilities;vm.filter=filter;vm.mailboxes=mailboxes;vm.labels=labels;vm.cancel=cancel;vm.save=save;vm.addMailFilterRule=addMailFilterRule;vm.removeMailFilterRule=removeMailFilterRule;vm.addMailFilterAction=addMailFilterAction;vm.removeMailFilterAction=removeMailFilterAction;vm.fieldLabels={subject:l("Subject"),from:l("From"),to:l("To"),cc:l("Cc"),to_or_cc:l("To or Cc"),size:l("Size (Kb)"),header:l("Header")};if(sieveCapabilities.indexOf("body")>-1)vm.fieldLabels.body=l("Body");vm.methodLabels={discard:l("Discard the message"),keep:l("Keep the message"),redirect:l("Forward the message to"),vacation:l("Send a vacation message"),stop:l("Stop processing filter rules")};if(sieveCapabilities.indexOf("reject")>-1)vm.methodLabels.reject=l("Send a reject message");if(sieveCapabilities.indexOf("fileinto")>-1)vm.methodLabels.fileinto=l("File the message in");if(sieveCapabilities.indexOf("imapflags")>-1||sieveCapabilities.indexOf("imap4flags")>-1)vm.methodLabels.addflag=l("Flag the message with");vm.numberOperatorLabels={under:l("is under"),over:l("is over")};vm.textOperatorLabels={is:l("is"),is_not:l("is not"),contains:l("contains"),contains_not:l("does not contain"),matches:l("matches"),matches_not:l("does not match")};if(sieveCapabilities.indexOf("regex")>-1){vm.textOperatorLabels.regex=l("matches regex");vm.textOperatorLabels.regex_not=l("does not match regex")}vm.flagLabels={seen:l("Seen"),deleted:l("Deleted"),answered:l("Answered"),flagged:l("Flagged"),junk:l("Junk"),not_junk:l("Not Junk")};function cancel(){$mdDialog.cancel()}function save(form){$mdDialog.hide()}function addMailFilterRule(event){if(!vm.filter.rules)vm.filter.rules=[];vm.filter.rules.push({field:"subject",operator:"contains"})}function removeMailFilterRule(index){vm.filter.rules.splice(index,1)}function addMailFilterAction(event){if(!vm.filter.actions)vm.filter.actions=[];vm.filter.actions.push({method:"discard"})}function removeMailFilterAction(index){vm.filter.actions.splice(index,1)}}angular.module("SOGo.PreferencesUI").controller("FiltersDialogController",FiltersDialogController)})();(function(){"use strict";PreferencesController.$inject=["$q","$window","$state","$mdMedia","$mdSidenav","$mdDialog","$mdToast","sgFocus","Dialog","User","Account","statePreferences","Authentication"];function PreferencesController($q,$window,$state,$mdMedia,$mdSidenav,$mdDialog,$mdToast,focus,Dialog,User,Account,statePreferences,Authentication){var vm=this,account,mailboxes=[];vm.preferences=statePreferences;vm.passwords={newPassword:null,newPasswordConfirmation:null};vm.go=go;vm.onLanguageChange=onLanguageChange;vm.addCalendarCategory=addCalendarCategory;vm.removeCalendarCategory=removeCalendarCategory;vm.addContactCategory=addContactCategory;vm.removeContactCategory=removeContactCategory;vm.addMailAccount=addMailAccount;vm.editMailAccount=editMailAccount;vm.removeMailAccount=removeMailAccount;vm.addMailLabel=addMailLabel;vm.removeMailLabel=removeMailLabel;vm.addMailFilter=addMailFilter;vm.editMailFilter=editMailFilter;vm.removeMailFilter=removeMailFilter;vm.addDefaultEmailAddresses=addDefaultEmailAddresses;vm.userFilter=User.$filter;vm.save=save;vm.canChangePassword=canChangePassword;vm.changePassword=changePassword;vm.timeZonesList=window.timeZonesList;vm.timeZonesListFilter=timeZonesListFilter;vm.timeZonesSearchText="";account=new Account({id:0});account.$getMailboxes().then(function(){var allMailboxes=account.$flattenMailboxes({all:true}),index=-1,length=allMailboxes.length;while(++index0&&angular.isDefined(vm.preferences.defaults.Forward)&&vm.preferences.defaults.Forward.enabled&&angular.isDefined(vm.preferences.defaults.Forward.forwardAddress)){addresses=vm.preferences.defaults.Forward.forwardAddress.split(",");defaultAddresses=window.defaultEmailAddresses.split(/, */);_.forEach(defaultAddresses,function(adr){var domain=adr.split("@")[1];if(domain){domains.push(domain.toLowerCase())}});for(i=0;i=0&&window.forwardConstraints==2){Dialog.alert(l("Error"),l("You are not allowed to forward your messages to an internal email address."));sendForm=false}}}if(sendForm)return vm.preferences.$save().then(function(data){$mdToast.show({controller:"savePreferencesToastCtrl",template:["",'
'," "+l("Preferences saved")+"",' '," close"," ","
","
"].join(""),hideDelay:2e3,position:"top right"})});return $q.reject()}function canChangePassword(){if(vm.passwords.newPassword&&vm.passwords.newPassword.length>0&&vm.passwords.newPasswordConfirmation&&vm.passwords.newPasswordConfirmation.length&&vm.passwords.newPassword==vm.passwords.newPasswordConfirmation)return true;return false}function changePassword(){Authentication.changePassword(vm.passwords.newPassword).then(function(){var alert=$mdDialog.alert({title:l("Password"),content:l("The password was changed successfully."),ok:l("OK")});$mdDialog.show(alert).finally(function(){alert=undefined})},function(msg){var alert=$mdDialog.alert({title:l("Password"),content:msg,ok:l("OK")});$mdDialog.show(alert).finally(function(){alert=undefined})})}function timeZonesListFilter(filter){return _.filter(vm.timeZonesList,function(value){return value.toUpperCase().indexOf(filter.toUpperCase())>=0})}}savePreferencesToastCtrl.$inject=["$scope","$mdToast"];function savePreferencesToastCtrl($scope,$mdToast){$scope.closeToast=function(){$mdToast.hide()}}angular.module("SOGo.PreferencesUI").controller("savePreferencesToastCtrl",savePreferencesToastCtrl).controller("PreferencesController",PreferencesController)})(); //# sourceMappingURL=Preferences.js.map \ No newline at end of file diff --git a/UI/WebServerResources/js/Scheduler.services.js b/UI/WebServerResources/js/Scheduler.services.js index 519d0785d..80e84739d 100644 --- a/UI/WebServerResources/js/Scheduler.services.js +++ b/UI/WebServerResources/js/Scheduler.services.js @@ -1,2 +1,2 @@ -!function(){"use strict";function a(b){if(this.init(b),this.name&&!this.id){var c=a.$$resource.create("createFolder",this.name);this.$unwrap(c)}this.id&&(this.$acl=new a.$$Acl("Calendar/"+this.id))}a.$factory=["$q","$timeout","$log","sgSettings","Resource","Preferences","Component","Acl",function(b,c,d,e,f,g,h,i){return angular.extend(a,{$q:b,$timeout:c,$log:d,$$resource:new f(e.activeUser("folderURL")+"Calendar",e.activeUser()),$Preferences:g,$Component:h,$$Acl:i,activeUser:e.activeUser(),$view:null}),a}];try{angular.module("SOGo.SchedulerUI")}catch(b){angular.module("SOGo.SchedulerUI",["SOGo.Common"])}angular.module("SOGo.SchedulerUI").value("CalendarSettings",{EventDragDayLength:96,EventDragHorizontalOffset:3}).factory("Calendar",a.$factory),a.$defaultCalendar=function(){var b,c=a.$Preferences.defaults.SOGoDefaultCalendar;return"first"==c&&(b=_.find(a.$findAll(null,!0),function(a){return a.active}))?b.id:"personal"},a.$add=function(a){var b,c,d;b=a.isWebCalendar?this.$webcalendars:a.isSubscription?this.$subscriptions:this.$calendars,c=_.find(b,function(b){return"personal"!=b.id&&1===b.name.localeCompare(a.name)}),d=c?_.indexOf(_.pluck(b,"id"),c.id):1,b.splice(d,0,a)},a.$findAll=function(b,c){var d=this;return b&&(this.$calendars=[],this.$subscriptions=[],this.$webcalendars=[],angular.forEach(b,function(b,c){var e=new a(b);e.isWebCalendar?d.$webcalendars.push(e):e.isSubscription?d.$subscriptions.push(e):d.$calendars.push(e)})),c?_.union(this.$calendars,_.filter(this.$subscriptions,function(a){return a.acls.objectCreator})):_.union(this.$calendars,this.$subscriptions,this.$webcalendars)},a.$get=function(b){var c;return c=_.find(a.$calendars,function(a){return a.id==b}),c||(c=_.find(a.$subscriptions,function(a){return a.id==b})),c||(c=_.find(a.$webcalendars,function(a){return a.id==b})),c},a.$getIndex=function(b){var c;return c=_.indexOf(_.pluck(a.$calendars,"id"),b),0>c&&(c=_.indexOf(_.pluck(a.$subscriptions,"id"),b)),0>c&&(c=_.indexOf(_.pluck(a.$webcalendars,"id"),b)),c},a.$subscribe=function(b,c){var d=this;return a.$$resource.userResource(b).fetch(c,"subscribe").then(function(b){var c=new a(b);return _.find(d.$subscriptions,function(a){return a.id==b.id})||a.$add(c),c})},a.$addWebCalendar=function(b){var c=this,d=a.$q.defer();return _.find(c.$webcalendars,function(a){return a.urls.webCalendarURL==b})?d.reject():a.$$resource.post(null,"addWebCalendar",{url:b}).then(function(c){angular.extend(c,{isWebCalendar:!0,isEditable:!0,isRemote:!1,owner:a.activeUser.login,urls:{webCalendarURL:b}});var e=new a(c);a.$add(e),a.$$resource.fetch(e.id,"reload").then(function(b){a.$log.debug(JSON.stringify(b,void 0,2))}),d.resolve()},function(){d.reject()}),d.promise},a.$deleteComponents=function(b){var c={},d=this;_.forEach(b,function(a){angular.isDefined(c[a.c_folder])||(c[a.c_folder]=[]),c[a.c_folder].push(a.c_name)}),_.forEach(c,function(b,c){a.$$resource.post(c,"batchDelete",{uids:b})}),d.$Component.$events=_.difference(d.$Component.$events,b),d.$Component.$tasks=_.difference(d.$Component.$tasks,b)},a.prototype.init=function(b){this.color=this.color||"#AAAAAA",angular.extend(this,b),this.isOwned=a.activeUser.isSuperUser||this.owner==a.activeUser.login,this.isSubscription=!this.isRemote&&this.owner!=a.activeUser.login,angular.isUndefined(this.$shadowData)&&(this.$shadowData=this.$omit())},a.prototype.$id=function(){return this.id?a.$q.when(this.id):this.$futureCalendarData.then(function(a){return a.id})},a.prototype.getClassName=function(a){return angular.isUndefined(a)&&(a="fg"),a+"-folder"+this.id},a.prototype.$rename=function(){var b,c,d=this;return this.name==this.$shadowData.name?a.$q.when():(c=this.isWebCalendar?a.$webcalendars:this.isSubscription?a.$subscriptions:a.$calendars,b=_.indexOf(_.pluck(c,"id"),this.id),b>-1?this.$save().then(function(){c.splice(b,1),a.$add(d)}):a.$q.reject())},a.prototype.$delete=function(){var b,c,d=this;return this.isSubscription?(c=a.$$resource.fetch(this.id,"unsubscribe"),b=a.$subscriptions):(c=a.$$resource.remove(this.id),b=this.isWebCalendar?a.$webcalendars:a.$calendars),c.then(function(){var a=_.indexOf(_.pluck(b,"id"),d.id);b.splice(a,1)})},a.prototype.$reset=function(){var a=this;angular.forEach(this,function(b,c){"constructor"!=c&&"$"!=c[0]&&delete a[c]}),angular.extend(this,this.$shadowData),this.$shadowData=this.$omit()},a.prototype.$save=function(){var b=this;return a.$$resource.save(this.id,this.$omit()).then(function(a){return b.$shadowData=b.$omit(),a},function(c){return a.$log.error(JSON.stringify(c,void 0,2)),b.$reset(),c})},a.prototype.$setActivation=function(){return a.$$resource.fetch(this.id,(this.active?"":"de")+"activateFolder")},a.prototype.$getComponent=function(b,c){return a.$Component.$find(this.id,b,c)},a.prototype.$unwrap=function(b){var c=this;this.$futureCalendarData=b.then(function(b){return a.$timeout(function(){return c.init(b),c})},function(b){c.isError=!0,angular.isObject(b)&&a.$timeout(function(){angular.extend(c,b)})})},a.prototype.$omit=function(){var a={};return angular.forEach(this,function(b,c){"constructor"!=c&&"$"!=c[0]&&(a[c]=b)}),a}}(),function(){"use strict";function a(b){if("function"!=typeof b.then){if(this.init(b),this.pid&&!this.id){var c=a.$$resource.newguid(this.pid);this.$unwrap(c),this.isNew=!0}}else this.$unwrap(b)}a.$factory=["$q","$timeout","$log","sgSettings","Preferences","Card","Gravatar","Resource",function(b,c,d,e,f,g,h,i){return angular.extend(a,{$q:b,$timeout:c,$log:d,$Preferences:f,$Card:g,$gravatar:h,$$resource:new i(e.baseURL(),e.activeUser()),timeFormat:"%H:%M",$query:{value:"",search:"title_Category_Location"},$queryEvents:{sort:"start",asc:1,filterpopup:"view_next7"},$queryTasks:{sort:"status",asc:1,filterpopup:"view_incomplete"},$refreshTimeout:null,$ghost:{}}),f.ready().then(function(){f.settings.Calendar.EventsFilterState&&(a.$queryEvents.filterpopup=f.settings.Calendar.EventsFilterState),f.settings.Calendar.TasksFilterState&&(a.$queryTasks.filterpopup=f.settings.Calendar.TasksFilterState),f.settings.Calendar.EventsSortingState&&(a.$queryEvents.sort=f.settings.Calendar.EventsSortingState[0],a.$queryEvents.asc=parseInt(f.settings.Calendar.EventsSortingState[1])),f.settings.Calendar.TasksSortingState&&(a.$queryTasks.sort=f.settings.Calendar.TasksSortingState[0],a.$queryTasks.asc=parseInt(f.settings.Calendar.TasksSortingState[1])),a.$queryTasks.show_completed=parseInt(f.settings.ShowCompletedTasks),a.$categories=f.defaults.SOGoCalendarCategoriesColors,f.defaults.SOGoTimeFormat&&(a.timeFormat=f.defaults.SOGoTimeFormat)}),a}];try{angular.module("SOGo.SchedulerUI")}catch(b){angular.module("SOGo.SchedulerUI",["SOGo.Common"])}angular.module("SOGo.SchedulerUI").factory("Component",a.$factory),a.$selectedCount=function(){var b;return b=0,a.$events&&(b+=_.filter(a.$events,function(a){return a.selected}).length),a.$tasks&&(b+=_.filter(a.$tasks,function(a){return a.selected}).length),b},a.$startRefreshTimeout=function(b){var c=this;a.$refreshTimeout&&a.$timeout.cancel(a.$refreshTimeout),a.$Preferences.ready().then(function(){var d=a.$Preferences.defaults.SOGoRefreshViewCheck;if(d&&"manually"!=d){var e=angular.bind(c,a.$filter,b);a.$refreshTimeout=a.$timeout(e,1e3*d.timeInterval())}})},a.$filter=function(b,c){var d=this,e=new Date,f=e.getDate(),g=e.getMonth()+1,h=e.getFullYear(),i="$query"+b.capitalize(),j={day:""+h+(10>g?"0":"")+g+(10>f?"0":"")+f};return a.$startRefreshTimeout(b),this.$Preferences.ready().then(function(){var e,f,g=!1;return angular.extend(d.$query,j),c&&_.each(_.keys(c),function(b){g|=d.$query[b]&&c[b]!=a.$query[b],"reload"==b&&c[b]?g=!0:angular.isDefined(d.$query[b])?d.$query[b]=c[b]:d[i][b]=c[b]}),e=d.$$resource.fetch(null,b+"list",angular.extend(d[i],d.$query)),f="tasks"==b?"$events":"$tasks",g&&(delete a[f],a.$log.debug("force reload of "+f)),d.$unwrapCollection(b,e)})},a.$find=function(b,c,d){var e,f=[b,c];return d&&f.push(d),e=this.$$resource.fetch(f.join("/"),"view"),new a(e)},a.filterCategories=function(b){var c=new RegExp(b,"i");return _.filter(_.keys(a.$categories),function(a){return-1!=a.search(c)})},a.saveSelectedList=function(a){return this.$$resource.post(null,"saveSelectedList",{list:a+"ListView"})},a.$eventsBlocksForView=function(a,b){var c,d,e;return"day"==a?(c="dayView",d=e=b):"multicolumnday"==a?(c="multicolumndayView",d=e=b):"week"==a?(c="weekView",d=b.beginOfWeek(),e=new Date,e.setTime(d.getTime()),e.addDays(6)):"month"==a&&(c="monthView",d=b,d.setDate(1),d=d.beginOfWeek(),e=new Date,e.setTime(d.getTime()),e.setMonth(e.getMonth()+1),e.addDays(-1),e=e.endOfWeek()),this.$eventsBlocks(c,d,e)},a.$eventsBlocks=function(b,c,d){var e,f,g,h,i=[],j=a.$q.defer();return e={view:b.toLowerCase(),sd:c.getDayString(),ed:d.getDayString()},a.$log.debug("eventsblocks "+JSON.stringify(e,void 0,2)),f=this.$$resource.fetch(null,"eventsblocks",e),f.then(function(b){var d,e;d=function(b,c,d){var e=_.object(this.eventsFields,c),f=new Date(1e3*e.c_startdate);return e.hour=f.getHourString(),e.blocks=[],b.push(new a(e)),b},e=function(a){this[a.nbr].blocks.push(a),a.component=this[a.nbr]},a.$views=[],a.$timeout(function(){_.forEach(b,function(b){var f,j=[],k={},l={};if(b.eventsFields.splice(_.indexOf(b.eventsFields,"c_folder"),1,"pid"),b.eventsFields.splice(_.indexOf(b.eventsFields,"c_name"),1,"id"),b.eventsFields.splice(_.indexOf(b.eventsFields,"c_recurrence_id"),1,"occurrenceId"),b.eventsFields.splice(_.indexOf(b.eventsFields,"c_title"),1,"summary"),_.reduce(b.events,d,j,b),_.forEach(_.flatten(b.blocks),e,j),_.each(_.flatten(b.allDayBlocks),e,j),0===i.length)for(g=0;g1||this.repeat.days&&this.repeat.days.length>0||this.repeat.monthdays&&this.repeat.monthdays.length>0||this.repeat.months&&this.repeat.months.length>0);return a},a.prototype.isEditable=function(){return!this.occurrenceId&&!this.isReadOnly},a.prototype.isEditableOccurrence=function(){return this.occurrenceId&&!this.isReadOnly},a.prototype.isInvitation=function(){return!this.occurrenceId&&this.userHasRSVP},a.prototype.isInvitationOccurrence=function(){return this.occurrenceId&&this.userHasRSVP},a.prototype.isReadOnly=function(){return this.isReadOnly&&!this.userHasRSVP},a.prototype.enablePercentComplete=function(){return"task"==this.type&&"not-specified"!=this.status&&"cancelled"!=this.status},a.prototype.coversFreeBusy=function(a,b,c){var d=angular.isDefined(this.freebusy[a])&&angular.isDefined(this.freebusy[a][b])&&1==this.freebusy[a][b][c];return d},a.prototype.updateFreeBusyCoverage=function(){var a=this,b={};if(this.start&&this.end){var c=new Date(this.start.getTime()),d=new Date(this.end.getTime()),e=parseInt(c.getMinutes()/15+.5),f=parseInt(d.getMinutes()/15+.5);return c.setMinutes(15*e),d.setMinutes(15*f),_.each(c.daysUpTo(d),function(c,d){var f,g=c.getDate(),h=c.getDayString();if(h==a.start.getDayString())for(f=c.getHours().toString(),b[h]={},b[h][f]=[];e>0;)b[h][f].push(0),e--;else c=c.beginOfDay(),b[h]={};for(;c.getTime()=e;e++)d=e.toString(),a[c][d]?b.freebusy[c][d]=[a[c][d][0],a[c][d][15],a[c][d][30],a[c][d][45]]:b.freebusy[c][d]=[0,0,0,0]})}))},a.prototype.getClassName=function(a){return angular.isUndefined(a)&&(a="fg"),a+"-folder"+(this.destinationCalendar||this.c_folder||this.pid)},a.prototype.addAttendee=function(b){var c,d,e=this;b&&(b.$isList()&&1!==b.isGroup?(d=a.$Card.$find(b.container,b.c_name),d.$id().then(function(b){_.forEach(d.refs,function(b){c={name:b.c_cn,email:b.$preferredEmail(),role:"req-participant",status:"needs-action",uid:b.c_uid},_.find(e.attendees,function(a){return a.email==c.email})||(c.image=a.$gravatar(c.email,32),e.attendees?e.attendees.push(c):e.attendees=[c],e.updateFreeBusyAttendee(c))})})):(c={name:b.c_cn,email:b.$preferredEmail(),role:"req-participant",status:"needs-action",uid:b.c_uid},_.find(this.attendees,function(a){return a.email==c.email})||(c.image=a.$gravatar(c.email,32),this.attendees?this.attendees.push(c):this.attendees=[c],this.updateFreeBusyAttendee(c))))},a.prototype.hasAttendee=function(a){var b=_.find(this.attendees,function(b){return _.find(a.emails,function(a){return a.value==b.email})});return angular.isDefined(b)},a.prototype.deleteAttendee=function(a){var b=_.findIndex(this.attendees,function(b){return b.email==a.email});this.attendees.splice(b,1)},a.prototype.canRemindAttendeesByEmail=function(){return"email"==this.alarm.action&&!this.isReadOnly&&this.attendees&&this.attendees.length>0},a.prototype.addAttachUrl=function(a){if(angular.isUndefined(this.attachUrls))this.attachUrls=[{value:a}];else{for(var b=0;b-1&&this.attachUrls.length>a&&this.attachUrls.splice(a,1)},a.prototype.$addDueDate=function(){this.due=new Date,this.due.setMinutes(15*Math.round(this.due.getMinutes()/15)),this.dueDate=this.due.toISOString()},a.prototype.$deleteDueDate=function(){delete this.due,delete this.dueDate},a.prototype.$addStartDate=function(){this.start=new Date,this.start.setMinutes(15*Math.round(this.start.getMinutes()/15))},a.prototype.$deleteStartDate=function(){delete this.start,delete this.startDate},a.prototype.$reset=function(){var a=this;angular.forEach(this,function(b,c){"constructor"!=c&&"$"!=c[0]&&delete a[c]}),this.init(this.$shadowData),this.$shadowData=this.$omit()},a.prototype.$reply=function(){var b,c=this,d=[this.pid,this.id];return this.occurrenceId&&d.push(this.occurrenceId),b={reply:this.reply,delegatedTo:this.delegatedTo,alarm:this.$hasAlarm?this.alarm:{}},a.$$resource.save(d.join("/"),b,{action:"rsvpAppointment"}).then(function(a){return c.$shadowData=c.$omit(),a})},a.prototype.$adjust=function(b){var c=[this.pid,this.id];return _.every(_.values(b),function(a){return 0===a})?a.$q.when():(this.occurrenceId&&c.push(this.occurrenceId),a.$log.debug("adjust "+c.join("/")+" "+JSON.stringify(b)),a.$$resource.save(c.join("/"),b,{action:"adjust"}))},a.prototype.$save=function(){function b(a){var b=a.getHours();10>b&&(b="0"+b);var c=a.getMinutes();return 10>c&&(c="0"+c),b+":"+c}function c(a){var b=a.getYear();1e3>b&&(b+=1900);var c=""+(a.getMonth()+1);1==c.length&&(c="0"+c);var d=""+a.getDate();return 1==d.length&&(d="0"+d),b+"-"+c+"-"+d}var d,e,f,g=this;return f=this.$omit(),f.startDate=f.start?c(f.start):"",f.startTime=f.start?b(f.start):"",f.endDate=f.end?c(f.end):"",f.endTime=f.end?b(f.end):"",f.dueDate=f.due?c(f.due):"",f.dueTime=f.due?b(f.due):"",this.$hasCustomRepeat?"monthly"==this.repeat.frequency&&this.repeat.month.type&&"byday"==this.repeat.month.type||"yearly"==this.repeat.frequency&&this.repeat.year.byday?(delete f.repeat.monthdays,f.repeat.days=[{day:this.repeat.month.day,occurrence:this.repeat.month.occurrence.toString()}]):this.repeat.month.type&&delete f.repeat.days:this.repeat.frequency&&(f.repeat={frequency:this.repeat.frequency}),this.repeat.frequency?"until"==this.repeat.end&&this.repeat.until?f.repeat.until=this.repeat.until.stringWithSeparator("-"):"count"==this.repeat.end&&this.repeat.count?f.repeat.count=this.repeat.count:(delete f.repeat.until,delete f.repeat.count):delete f.repeat,this.$hasAlarm?!this.alarm.action||"email"!=this.alarm.action||this.attendees&&this.attendees.length>0||(f.alarm.attendees=0,f.alarm.organizer=1):f.alarm={},e=[this.pid,this.id],this.isNew&&(d={action:"saveAs"+this.type.capitalize()}),this.occurrenceId&&e.push(this.occurrenceId),a.$$resource.save(e.join("/"),f,d).then(function(a){return g.$shadowData=g.$omit(),a})},a.prototype.remove=function(b){var c=[this.pid,this.id];return b&&this.occurrenceId&&c.push(this.occurrenceId),a.$$resource.remove(c.join("/"))},a.prototype.$unwrap=function(b){var c=this;this.$futureComponentData=b,this.$futureComponentData.then(function(a){c.init(a),c.$shadowData=c.$omit()},function(b){angular.extend(c,b),c.isError=!0,a.$log.error(c.error)})},a.prototype.$omit=function(){var a={};return angular.forEach(this,function(b,c){"constructor"!=c&&"$"!=c[0]&&"blocks"!=c&&(a[c]=angular.copy(b))}),a},a.prototype.repeatDescription=function(){var a=null;return this.repeat&&(a=l("repeat_"+this.repeat.frequency.toUpperCase())),a},a.prototype.alarmDescription=function(){var a,b=null;return this.alarm&&(a=["reminder"+this.alarm.quantity,this.alarm.unit,this.alarm.reference].join("_"),b=l(a),a===b&&(b=[this.alarm.quantity,l("reminder_"+this.alarm.unit),l("reminder_"+this.alarm.reference)].join(" "))),b},a.prototype.toString=function(){return"[Component "+this.id+"]"}}(); +(function(){"use strict";function Calendar(futureCalendarData){this.init(futureCalendarData);if(this.name&&!this.id){var newCalendarData=Calendar.$$resource.create("createFolder",this.name);this.$unwrap(newCalendarData)}if(this.id){this.$acl=new Calendar.$$Acl("Calendar/"+this.id)}}Calendar.$factory=["$q","$timeout","$log","sgSettings","Resource","Preferences","Component","Acl",function($q,$timeout,$log,Settings,Resource,Preferences,Component,Acl){angular.extend(Calendar,{$q:$q,$timeout:$timeout,$log:$log,$$resource:new Resource(Settings.activeUser("folderURL")+"Calendar",Settings.activeUser()),$Preferences:Preferences,$Component:Component,$$Acl:Acl,activeUser:Settings.activeUser(),$view:null});return Calendar}];try{angular.module("SOGo.SchedulerUI")}catch(e){angular.module("SOGo.SchedulerUI",["SOGo.Common"])}angular.module("SOGo.SchedulerUI").value("CalendarSettings",{EventDragDayLength:24*4,EventDragHorizontalOffset:3}).factory("Calendar",Calendar.$factory);Calendar.$defaultCalendar=function(){var defaultCalendar=Calendar.$Preferences.defaults.SOGoDefaultCalendar,calendar;if(defaultCalendar=="first"){calendar=_.find(Calendar.$findAll(null,true),function(calendar){return calendar.active});if(calendar)return calendar.id}return"personal"};Calendar.$add=function(calendar){var list,sibling,i;if(calendar.isWebCalendar)list=this.$webcalendars;else if(calendar.isSubscription)list=this.$subscriptions;else list=this.$calendars;sibling=_.find(list,function(o){return o.id!="personal"&&o.name.localeCompare(calendar.name)===1});i=sibling?_.indexOf(_.pluck(list,"id"),sibling.id):1;list.splice(i,0,calendar)};Calendar.$findAll=function(data,writable){var _this=this;if(data){this.$calendars=[];this.$subscriptions=[];this.$webcalendars=[];angular.forEach(data,function(o,i){var calendar=new Calendar(o);if(calendar.isWebCalendar)_this.$webcalendars.push(calendar);else if(calendar.isSubscription)_this.$subscriptions.push(calendar);else _this.$calendars.push(calendar)})}if(writable){return _.union(this.$calendars,_.filter(this.$subscriptions,function(calendar){return calendar.acls.objectCreator}))}return _.union(this.$calendars,this.$subscriptions,this.$webcalendars)};Calendar.$get=function(id){var calendar;calendar=_.find(Calendar.$calendars,function(o){return o.id==id});if(!calendar)calendar=_.find(Calendar.$subscriptions,function(o){return o.id==id});if(!calendar)calendar=_.find(Calendar.$webcalendars,function(o){return o.id==id});return calendar};Calendar.$getIndex=function(id){var i;i=_.indexOf(_.pluck(Calendar.$calendars,"id"),id);if(i<0)i=_.indexOf(_.pluck(Calendar.$subscriptions,"id"),id);if(i<0)i=_.indexOf(_.pluck(Calendar.$webcalendars,"id"),id);return i};Calendar.$subscribe=function(uid,path){var _this=this;return Calendar.$$resource.userResource(uid).fetch(path,"subscribe").then(function(calendarData){var calendar=new Calendar(calendarData);if(!_.find(_this.$subscriptions,function(o){return o.id==calendarData.id})){Calendar.$add(calendar)}return calendar})};Calendar.$addWebCalendar=function(url){var _this=this,d=Calendar.$q.defer();if(_.find(_this.$webcalendars,function(o){return o.urls.webCalendarURL==url})){d.reject()}else{Calendar.$$resource.post(null,"addWebCalendar",{url:url}).then(function(calendarData){angular.extend(calendarData,{isWebCalendar:true,isEditable:true,isRemote:false,owner:Calendar.activeUser.login,urls:{webCalendarURL:url}});var calendar=new Calendar(calendarData);Calendar.$add(calendar);Calendar.$$resource.fetch(calendar.id,"reload").then(function(data){Calendar.$log.debug(JSON.stringify(data,undefined,2))});d.resolve()},function(){d.reject()})}return d.promise};Calendar.$deleteComponents=function(components){var calendars={},_this=this;_.forEach(components,function(component){if(!angular.isDefined(calendars[component.c_folder]))calendars[component.c_folder]=[];calendars[component.c_folder].push(component.c_name)});_.forEach(calendars,function(uids,c_folder){Calendar.$$resource.post(c_folder,"batchDelete",{uids:uids})});_this.$Component.$events=_.difference(_this.$Component.$events,components);_this.$Component.$tasks=_.difference(_this.$Component.$tasks,components)};Calendar.prototype.init=function(data){this.color=this.color||"#AAAAAA";angular.extend(this,data);this.isOwned=Calendar.activeUser.isSuperUser||this.owner==Calendar.activeUser.login;this.isSubscription=!this.isRemote&&this.owner!=Calendar.activeUser.login;if(angular.isUndefined(this.$shadowData)){this.$shadowData=this.$omit()}};Calendar.prototype.$id=function(){if(this.id){return Calendar.$q.when(this.id)}else{return this.$futureCalendarData.then(function(calendar){return calendar.id})}};Calendar.prototype.getClassName=function(base){if(angular.isUndefined(base))base="fg";return base+"-folder"+this.id};Calendar.prototype.$rename=function(){var _this=this,i,calendars;if(this.name==this.$shadowData.name){return Calendar.$q.when()}if(this.isWebCalendar)calendars=Calendar.$webcalendars;else if(this.isSubscription)calendars=Calendar.$subscriptions;else calendars=Calendar.$calendars;i=_.indexOf(_.pluck(calendars,"id"),this.id);if(i>-1){return this.$save().then(function(){calendars.splice(i,1);Calendar.$add(_this)})}else{return Calendar.$q.reject()}};Calendar.prototype.$delete=function(){var _this=this,list,promise;if(this.isSubscription){promise=Calendar.$$resource.fetch(this.id,"unsubscribe");list=Calendar.$subscriptions}else{promise=Calendar.$$resource.remove(this.id);if(this.isWebCalendar)list=Calendar.$webcalendars;else list=Calendar.$calendars}return promise.then(function(){var i=_.indexOf(_.pluck(list,"id"),_this.id);list.splice(i,1)})};Calendar.prototype.$reset=function(){var _this=this;angular.forEach(this,function(value,key){if(key!="constructor"&&key[0]!="$"){delete _this[key]}});angular.extend(this,this.$shadowData);this.$shadowData=this.$omit()};Calendar.prototype.$save=function(){var _this=this;return Calendar.$$resource.save(this.id,this.$omit()).then(function(data){_this.$shadowData=_this.$omit();return data},function(data){Calendar.$log.error(JSON.stringify(data,undefined,2));_this.$reset();return data})};Calendar.prototype.$setActivation=function(){return Calendar.$$resource.fetch(this.id,(this.active?"":"de")+"activateFolder")};Calendar.prototype.$getComponent=function(componentId,recurrenceId){return Calendar.$Component.$find(this.id,componentId,recurrenceId)};Calendar.prototype.$unwrap=function(futureCalendarData){var _this=this;this.$futureCalendarData=futureCalendarData.then(function(data){return Calendar.$timeout(function(){_this.init(data);return _this})},function(data){_this.isError=true;if(angular.isObject(data)){Calendar.$timeout(function(){angular.extend(_this,data)})}})};Calendar.prototype.$omit=function(){var calendar={};angular.forEach(this,function(value,key){if(key!="constructor"&&key[0]!="$"){calendar[key]=value}});return calendar}})();(function(){"use strict";function Component(futureComponentData){if(typeof futureComponentData.then!=="function"){this.init(futureComponentData);if(this.pid&&!this.id){var newComponentData=Component.$$resource.newguid(this.pid);this.$unwrap(newComponentData);this.isNew=true}}else{this.$unwrap(futureComponentData)}}Component.$factory=["$q","$timeout","$log","sgSettings","Preferences","Card","Gravatar","Resource",function($q,$timeout,$log,Settings,Preferences,Card,Gravatar,Resource){angular.extend(Component,{$q:$q,$timeout:$timeout,$log:$log,$Preferences:Preferences,$Card:Card,$gravatar:Gravatar,$$resource:new Resource(Settings.baseURL(),Settings.activeUser()),timeFormat:"%H:%M",$query:{value:"",search:"title_Category_Location"},$queryEvents:{sort:"start",asc:1,filterpopup:"view_next7"},$queryTasks:{sort:"status",asc:1,filterpopup:"view_incomplete"},$refreshTimeout:null,$ghost:{}});Preferences.ready().then(function(){if(Preferences.settings.Calendar.EventsFilterState)Component.$queryEvents.filterpopup=Preferences.settings.Calendar.EventsFilterState;if(Preferences.settings.Calendar.TasksFilterState)Component.$queryTasks.filterpopup=Preferences.settings.Calendar.TasksFilterState;if(Preferences.settings.Calendar.EventsSortingState){Component.$queryEvents.sort=Preferences.settings.Calendar.EventsSortingState[0];Component.$queryEvents.asc=parseInt(Preferences.settings.Calendar.EventsSortingState[1])}if(Preferences.settings.Calendar.TasksSortingState){Component.$queryTasks.sort=Preferences.settings.Calendar.TasksSortingState[0];Component.$queryTasks.asc=parseInt(Preferences.settings.Calendar.TasksSortingState[1])}Component.$queryTasks.show_completed=parseInt(Preferences.settings.ShowCompletedTasks);Component.$categories=Preferences.defaults.SOGoCalendarCategoriesColors;if(Preferences.defaults.SOGoTimeFormat){Component.timeFormat=Preferences.defaults.SOGoTimeFormat}});return Component}];try{angular.module("SOGo.SchedulerUI")}catch(e){angular.module("SOGo.SchedulerUI",["SOGo.Common"])}angular.module("SOGo.SchedulerUI").factory("Component",Component.$factory);Component.$selectedCount=function(){var count;count=0;if(Component.$events){count+=_.filter(Component.$events,function(event){return event.selected}).length}if(Component.$tasks){count+=_.filter(Component.$tasks,function(task){return task.selected}).length}return count};Component.$startRefreshTimeout=function(type){var _this=this;if(Component.$refreshTimeout)Component.$timeout.cancel(Component.$refreshTimeout);Component.$Preferences.ready().then(function(){var refreshViewCheck=Component.$Preferences.defaults.SOGoRefreshViewCheck;if(refreshViewCheck&&refreshViewCheck!="manually"){var f=angular.bind(_this,Component.$filter,type);Component.$refreshTimeout=Component.$timeout(f,refreshViewCheck.timeInterval()*1e3)}})};Component.$filter=function(type,options){var _this=this,now=new Date,day=now.getDate(),month=now.getMonth()+1,year=now.getFullYear(),queryKey="$query"+type.capitalize(),params={day:""+year+(month<10?"0":"")+month+(day<10?"0":"")+day};Component.$startRefreshTimeout(type);return this.$Preferences.ready().then(function(){var futureComponentData,dirty=false,otherType;angular.extend(_this.$query,params);if(options){_.each(_.keys(options),function(key){dirty|=_this.$query[key]&&options[key]!=Component.$query[key];if(key=="reload"&&options[key])dirty=true;else if(angular.isDefined(_this.$query[key]))_this.$query[key]=options[key];else _this[queryKey][key]=options[key]})}futureComponentData=_this.$$resource.fetch(null,type+"list",angular.extend(_this[queryKey],_this.$query));otherType=type=="tasks"?"$events":"$tasks";if(dirty){delete Component[otherType];Component.$log.debug("force reload of "+otherType)}return _this.$unwrapCollection(type,futureComponentData)})};Component.$find=function(calendarId,componentId,occurrenceId){var futureComponentData,path=[calendarId,componentId];if(occurrenceId)path.push(occurrenceId);futureComponentData=this.$$resource.fetch(path.join("/"),"view");return new Component(futureComponentData)};Component.filterCategories=function(query){var re=new RegExp(query,"i");return _.filter(_.keys(Component.$categories),function(category){return category.search(re)!=-1})};Component.saveSelectedList=function(componentType){return this.$$resource.post(null,"saveSelectedList",{list:componentType+"ListView"})};Component.$eventsBlocksForView=function(view,date){var viewAction,startDate,endDate,params;if(view=="day"){viewAction="dayView";startDate=endDate=date}else if(view=="multicolumnday"){viewAction="multicolumndayView";startDate=endDate=date}else if(view=="week"){viewAction="weekView";startDate=date.beginOfWeek();endDate=new Date;endDate.setTime(startDate.getTime());endDate.addDays(6)}else if(view=="month"){viewAction="monthView";startDate=date;startDate.setDate(1);startDate=startDate.beginOfWeek();endDate=new Date;endDate.setTime(startDate.getTime());endDate.setMonth(endDate.getMonth()+1);endDate.addDays(-1);endDate=endDate.endOfWeek()}return this.$eventsBlocks(viewAction,startDate,endDate)};Component.$eventsBlocks=function(view,startDate,endDate){var params,futureComponentData,i,j,dates=[],deferred=Component.$q.defer();params={view:view.toLowerCase(),sd:startDate.getDayString(),ed:endDate.getDayString()};Component.$log.debug("eventsblocks "+JSON.stringify(params,undefined,2));futureComponentData=this.$$resource.fetch(null,"eventsblocks",params);futureComponentData.then(function(views){var reduceComponent,associateComponent;reduceComponent=function(objects,eventData,i){var componentData=_.object(this.eventsFields,eventData),start=new Date(componentData.c_startdate*1e3);componentData.hour=start.getHourString();componentData.blocks=[];objects.push(new Component(componentData));return objects};associateComponent=function(block){this[block.nbr].blocks.push(block);block.component=this[block.nbr]};Component.$views=[];Component.$timeout(function(){_.forEach(views,function(data){var components=[],blocks={},allDayBlocks={},viewData;data.eventsFields.splice(_.indexOf(data.eventsFields,"c_folder"),1,"pid");data.eventsFields.splice(_.indexOf(data.eventsFields,"c_name"),1,"id");data.eventsFields.splice(_.indexOf(data.eventsFields,"c_recurrence_id"),1,"occurrenceId");data.eventsFields.splice(_.indexOf(data.eventsFields,"c_title"),1,"summary");_.reduce(data.events,reduceComponent,components,data);_.forEach(_.flatten(data.blocks),associateComponent,components);_.each(_.flatten(data.allDayBlocks),associateComponent,components);if(dates.length===0)for(i=0;i1||this.repeat.days&&this.repeat.days.length>0||this.repeat.monthdays&&this.repeat.monthdays.length>0||this.repeat.months&&this.repeat.months.length>0);return b};Component.prototype.isEditable=function(){return!this.occurrenceId&&!this.isReadOnly};Component.prototype.isEditableOccurrence=function(){return this.occurrenceId&&!this.isReadOnly};Component.prototype.isInvitation=function(){return!this.occurrenceId&&this.userHasRSVP};Component.prototype.isInvitationOccurrence=function(){return this.occurrenceId&&this.userHasRSVP};Component.prototype.isReadOnly=function(){return this.isReadOnly&&!this.userHasRSVP};Component.prototype.enablePercentComplete=function(){return this.type=="task"&&this.status!="not-specified"&&this.status!="cancelled"};Component.prototype.coversFreeBusy=function(day,hour,quarter){var b=angular.isDefined(this.freebusy[day])&&angular.isDefined(this.freebusy[day][hour])&&this.freebusy[day][hour][quarter]==1;return b};Component.prototype.updateFreeBusyCoverage=function(){var _this=this,freebusy={};if(this.start&&this.end){var roundedStart=new Date(this.start.getTime()),roundedEnd=new Date(this.end.getTime()),startQuarter=parseInt(roundedStart.getMinutes()/15+.5),endQuarter=parseInt(roundedEnd.getMinutes()/15+.5);roundedStart.setMinutes(15*startQuarter);roundedEnd.setMinutes(15*endQuarter);_.each(roundedStart.daysUpTo(roundedEnd),function(date,index){var currentDay=date.getDate(),dayKey=date.getDayString(),hourKey;if(dayKey==_this.start.getDayString()){hourKey=date.getHours().toString();freebusy[dayKey]={};freebusy[dayKey][hourKey]=[];while(startQuarter>0){freebusy[dayKey][hourKey].push(0);startQuarter--}}else{date=date.beginOfDay();freebusy[dayKey]={}}while(date.getTime()<_this.end.getTime()&&date.getDate()==currentDay){hourKey=date.getHours().toString();if(angular.isUndefined(freebusy[dayKey][hourKey]))freebusy[dayKey][hourKey]=[];freebusy[dayKey][hourKey].push(1);date.addMinutes(15)}});return freebusy}};Component.prototype.updateFreeBusy=function(){var _this=this;this.freebusy=this.updateFreeBusyCoverage();if(this.attendees){_.each(this.attendees,function(attendee){attendee.image=Component.$gravatar(attendee.email,32);_this.updateFreeBusyAttendee(attendee)})}};Component.prototype.setDelta=function(delta){this.delta=delta;this.end=new Date(this.start.getTime());this.end.setMinutes(Math.round(this.end.getMinutes()/15)*15);this.end.addMinutes(this.delta)};Component.prototype.updateFreeBusyAttendee=function(attendee){var params,url,days;if(attendee.uid){params={sday:this.start.getDayString(),eday:this.end.getDayString()};url=["..","..",attendee.uid,"freebusy.ifb"];days=_.map(this.start.daysUpTo(this.end),function(day){return day.getDayString()});if(angular.isUndefined(attendee.freebusy))attendee.freebusy={};Component.$$resource.fetch(url.join("/"),"ajaxRead",params).then(function(data){_.each(days,function(day){var hour;if(angular.isUndefined(attendee.freebusy[day]))attendee.freebusy[day]={};if(angular.isUndefined(data[day]))data[day]={};for(var i=0;i<=23;i++){hour=i.toString();if(data[day][hour])attendee.freebusy[day][hour]=[data[day][hour]["0"],data[day][hour]["15"],data[day][hour]["30"],data[day][hour]["45"]];else attendee.freebusy[day][hour]=[0,0,0,0]}})})}};Component.prototype.getClassName=function(base){if(angular.isUndefined(base))base="fg";return base+"-folder"+(this.destinationCalendar||this.c_folder||this.pid)};Component.prototype.addAttendee=function(card){var _this=this,attendee,list,url,params;if(card){if(card.$isList()&&card.isGroup!==1){list=Component.$Card.$find(card.container,card.c_name);list.$id().then(function(listId){_.forEach(list.refs,function(ref){attendee={name:ref.c_cn,email:ref.$preferredEmail(),role:"req-participant",status:"needs-action",uid:ref.c_uid};if(!_.find(_this.attendees,function(o){return o.email==attendee.email})){attendee.image=Component.$gravatar(attendee.email,32);if(_this.attendees)_this.attendees.push(attendee);else _this.attendees=[attendee];_this.updateFreeBusyAttendee(attendee)}})})}else{attendee={name:card.c_cn,email:card.$preferredEmail(),role:"req-participant",status:"needs-action",uid:card.c_uid};if(!_.find(this.attendees,function(o){return o.email==attendee.email})){attendee.image=Component.$gravatar(attendee.email,32);if(this.attendees)this.attendees.push(attendee);else this.attendees=[attendee];this.updateFreeBusyAttendee(attendee)}}}};Component.prototype.hasAttendee=function(card){var attendee=_.find(this.attendees,function(attendee){return _.find(card.emails,function(email){return email.value==attendee.email})});return angular.isDefined(attendee)};Component.prototype.deleteAttendee=function(attendee){var index=_.findIndex(this.attendees,function(currentAttendee){return currentAttendee.email==attendee.email});this.attendees.splice(index,1)};Component.prototype.canRemindAttendeesByEmail=function(){return this.alarm.action=="email"&&!this.isReadOnly&&this.attendees&&this.attendees.length>0};Component.prototype.addAttachUrl=function(attachUrl){if(angular.isUndefined(this.attachUrls)){this.attachUrls=[{value:attachUrl}]}else{for(var i=0;i-1&&this.attachUrls.length>index){this.attachUrls.splice(index,1)}};Component.prototype.$addDueDate=function(){this.due=new Date;this.due.setMinutes(Math.round(this.due.getMinutes()/15)*15);this.dueDate=this.due.toISOString()};Component.prototype.$deleteDueDate=function(){delete this.due;delete this.dueDate};Component.prototype.$addStartDate=function(){this.start=new Date;this.start.setMinutes(Math.round(this.start.getMinutes()/15)*15)};Component.prototype.$deleteStartDate=function(){delete this.start;delete this.startDate};Component.prototype.$reset=function(){var _this=this;angular.forEach(this,function(value,key){if(key!="constructor"&&key[0]!="$"){delete _this[key]}});this.init(this.$shadowData);this.$shadowData=this.$omit()};Component.prototype.$reply=function(){var _this=this,data,path=[this.pid,this.id];if(this.occurrenceId)path.push(this.occurrenceId);data={reply:this.reply,delegatedTo:this.delegatedTo,alarm:this.$hasAlarm?this.alarm:{}};return Component.$$resource.save(path.join("/"),data,{action:"rsvpAppointment"}).then(function(data){_this.$shadowData=_this.$omit();return data})};Component.prototype.$adjust=function(params){var path=[this.pid,this.id];if(_.every(_.values(params),function(v){return v===0}))return Component.$q.when();if(this.occurrenceId)path.push(this.occurrenceId);Component.$log.debug("adjust "+path.join("/")+" "+JSON.stringify(params));return Component.$$resource.save(path.join("/"),params,{action:"adjust"})};Component.prototype.$save=function(){var _this=this,options,path,component,date;component=this.$omit();component.startDate=component.start?formatDate(component.start):"";component.startTime=component.start?formatTime(component.start):"";component.endDate=component.end?formatDate(component.end):"";component.endTime=component.end?formatTime(component.end):"";component.dueDate=component.due?formatDate(component.due):"";component.dueTime=component.due?formatTime(component.due):"";if(this.$hasCustomRepeat){if(this.repeat.frequency=="monthly"&&this.repeat.month.type&&this.repeat.month.type=="byday"||this.repeat.frequency=="yearly"&&this.repeat.year.byday){delete component.repeat.monthdays;component.repeat.days=[{day:this.repeat.month.day,occurrence:this.repeat.month.occurrence.toString()}]}else if(this.repeat.month.type){delete component.repeat.days}}else if(this.repeat.frequency){component.repeat={frequency:this.repeat.frequency}}if(this.repeat.frequency){if(this.repeat.end=="until"&&this.repeat.until)component.repeat.until=this.repeat.until.stringWithSeparator("-");else if(this.repeat.end=="count"&&this.repeat.count)component.repeat.count=this.repeat.count;else{delete component.repeat.until;delete component.repeat.count}}else{delete component.repeat}if(this.$hasAlarm){if(this.alarm.action&&this.alarm.action=="email"&&!(this.attendees&&this.attendees.length>0)){component.alarm.attendees=0;component.alarm.organizer=1}}else{component.alarm={}}path=[this.pid,this.id];if(this.isNew)options={action:"saveAs"+this.type.capitalize()};if(this.occurrenceId)path.push(this.occurrenceId);return Component.$$resource.save(path.join("/"),component,options).then(function(data){_this.$shadowData=_this.$omit();return data});function formatTime(date){var hours=date.getHours();if(hours<10)hours="0"+hours;var minutes=date.getMinutes();if(minutes<10)minutes="0"+minutes;return hours+":"+minutes}function formatDate(date){var year=date.getYear();if(year<1e3)year+=1900;var month=""+(date.getMonth()+1);if(month.length==1)month="0"+month;var day=""+date.getDate();if(day.length==1)day="0"+day;return year+"-"+month+"-"+day}};Component.prototype.remove=function(occurrenceOnly){var _this=this,path=[this.pid,this.id];if(occurrenceOnly&&this.occurrenceId)path.push(this.occurrenceId);return Component.$$resource.remove(path.join("/"))};Component.prototype.$unwrap=function(futureComponentData){var _this=this;this.$futureComponentData=futureComponentData;this.$futureComponentData.then(function(data){_this.init(data);_this.$shadowData=_this.$omit()},function(data){angular.extend(_this,data);_this.isError=true;Component.$log.error(_this.error)})};Component.prototype.$omit=function(){var component={};angular.forEach(this,function(value,key){if(key!="constructor"&&key[0]!="$"&&key!="blocks"){component[key]=angular.copy(value)}});return component};Component.prototype.repeatDescription=function(){var localizedString=null;if(this.repeat)localizedString=l("repeat_"+this.repeat.frequency.toUpperCase());return localizedString};Component.prototype.alarmDescription=function(){var key,localizedString=null;if(this.alarm){key=["reminder"+this.alarm.quantity,this.alarm.unit,this.alarm.reference].join("_");localizedString=l(key);if(key===localizedString)localizedString=[this.alarm.quantity,l("reminder_"+this.alarm.unit),l("reminder_"+this.alarm.reference)].join(" ")}return localizedString};Component.prototype.toString=function(){return"[Component "+this.id+"]"}})(); //# sourceMappingURL=Scheduler.services.js.map \ No newline at end of file