sogo/UI/WebServerResources/js/Contacts.services.js

2 lines
19 KiB
JavaScript
Raw Normal View History

2021-10-06 06:18:15 +02:00
!function(){"use strict";function l(t){var e;"function"!=typeof t.then?(this.init(t),this.name&&!this.id?(e=l.$$resource.create("createFolder",this.name),this.$unwrap(e),this.acls={objectEditor:1,objectCreator:1,objectEraser:1}):this.id&&(this.$acl=new l.$$Acl("Contacts/"+this.id))):this.$unwrap(t)}l.$factory=["$q","$timeout","$log","sgSettings","sgAddressBook_PRELOAD","Resource","Card","Acl","Preferences",function(t,e,i,r,n,s,o,a,d){return angular.extend(l,{$q:t,$timeout:e,$log:i,PRELOAD:n,$$resource:new s(r.activeUser("folderURL")+"Contacts",r.activeUser()),$Card:o,$$Acl:a,$Preferences:d,$query:{value:"",sort:"c_cn",asc:1},activeUser:r.activeUser(),$addressbooks:[],$subscriptions:[],$remotes:[],selectedFolder:null,$refreshTimeout:null}),d.settings.Contact.SortingState&&(l.$query.sort=d.settings.Contact.SortingState[0],l.$query.asc=parseInt(d.settings.Contact.SortingState[1])),l}];try{angular.module("SOGo.ContactsUI")}catch(t){angular.module("SOGo.ContactsUI",["SOGo.Common","SOGo.PreferencesUI"])}angular.module("SOGo.ContactsUI").constant("sgAddressBook_PRELOAD",{LOOKAHEAD:50,SIZE:100}).factory("AddressBook",l.$factory),l.$filterAll=function(s,o,t,a){var e={search:s};return s?(angular.isUndefined(o)&&(o=[]),angular.extend(e,t),l.$$resource.fetch(null,"allContactSearch",e).then(function(t){for(var e,i=function(t){return this.id==t.id},r=a?_.filter(t.contacts,function(t){return _.isUndefined(_.find(a,_.bind(i,t)))}):t.contacts,n=o.length-1;0<=n;n--)e=o[n],_.isUndefined(_.find(r,_.bind(i,e)))&&o.splice(n,1);return _.forEach(r,function(t,e){_.isUndefined(_.find(o,_.bind(i,t)))&&(t=new l.$Card(_.mapKeys(t,function(t,e){return e.toLowerCase()}),s),o.splice(e,0,t))}),l.$log.debug(o),o})):l.$q.when(o=[])},l.$add=function(e){var t=e.isSubscription?this.$subscriptions:this.$addressbooks,i=_.find(t,function(t){return"personal"==e.id||"personal"!=t.id&&1===t.name.localeCompare(e.name)}),i=i?_.indexOf(_.map(t,"id"),i.id):1;t.splice(i,0,e)},l.$findAll=function(t){var i=this;if(t&&t.length)this.$addressbooks.splice(0,this.$addressbooks.length),this.$subscriptions.splice(0,this.$subscriptions.length),this.$remotes.splice(0,this.$remotes.length),angular.forEach(t,function(t,e){t=new l(t);(t.isRemote?i.$remotes:t.isSubscription?i.$subscriptions:i.$addressbooks).push(t)});else if(angular.isArray(t))return l.$$resource.fetch("addressbooksList").then(function(t){return l.$findAll(t.addressbooks)});return _.union(this.$addressbooks,this.$subscriptions,this.$remotes)},l.$subscribe=function(t,e){var i=this;return l.$$resource.userResource(t).fetch(e,"subscribe").then(function(e){var t=new l(e);return _.isUndefined(_.find(i.$subscriptions,function(t){return t.id==e.id}))&&l.$add(t),t})},l.$reloadAll=function(){var i=this;return l.$$resource.fetch("addressbooksList").then(function(t){_.forEach(t.addressbooks,function(e){var t=e.isRemote?i.$remotes:e.owner!=l.activeUser.login?i.$subscriptions:i.$addressbooks,t=_.find(t,function(t){return t.id==e.id});t&&t.init(e)})})},l.prototype.init=function(t,e){var i=this;this.$$cards||(this.$$cards=[]),this.idsMap={},this.$cards=[],angular.forEach(t,function(t,e){"headers"!=e&&"cards"!=e&&(i[e]=t)}),this.isOwned=l.activeUser.isSuperUser||this.owner==l.activeUser.login,this.isSubscription=!this.isRemote&&this.owner!=l.activeUser.login},l.prototype.$id=function(){return this.id?l.$q.when(this.id):this.$futureAddressBookData.then(function(t){return t?t.id:l.$q.reject()})},l.prototype.getLength=function(){return this.$cards.length},l.prototype.getItemAtIndex=function(t){var e;return!this.$isLoading&&0<=t&&t<this.$cards.length&&(e=this.$cards[t],this.$lastVisibleIndex=Math.max(0,t-3),this.$loadCard(e))?e:null},l.prototype.$loadCard=function(t){var e,i,r,n=t.id,s=this.idsMap[n],o=this.$cards.length,n=!1;if(angular.isUndefined(this.ids)&&t.id)n=!0;else if(angular.isDefined(s)&&s<this.$cards.length&&(t.$loaded!=l.$Card.STATUS.NOT_LOADED&&(n=!0),e=Math.min(s+l.PRELOAD.LOOKAHEAD,o-1),this.$cards[e].$loaded!=l.$Card.STATUS.NOT_LOADED?(r=Math.max(s-l.PRELOAD.LOOKAHEAD,0),this.$cards[r].$loaded!=l.$Card.STATUS.LOADED&&(
//# sourceMappingURL=Contacts.services.js.map