2 lines
18 KiB
JavaScript
2 lines
18 KiB
JavaScript
|
!function(){"use strict";function Calendar(futureCalendarData){if(this.init(futureCalendarData),this.name&&!this.id){var newCalendarData=Calendar.$$resource.create("createFolder",this.name);angular.extend(this,newCalendarData)}this.id&&(this.$acl=new Calendar.$$Acl("Calendar/"+this.id))}Calendar.$factory=["$q","$timeout","$log","sgSettings","Resource","Component","Acl",function($q,$timeout,$log,Settings,Resource,Component,Acl){return angular.extend(Calendar,{$q:$q,$timeout:$timeout,$log:$log,$$resource:new Resource(Settings.activeUser("folderURL")+"Calendar",Settings.activeUser()),$Component:Component,$$Acl:Acl,activeUser:Settings.activeUser()}),Calendar}];try{angular.module("SOGo.SchedulerUI")}catch(e){angular.module("SOGo.SchedulerUI",["SOGo.Common"])}angular.module("SOGo.SchedulerUI").factory("Calendar",Calendar.$factory),Calendar.$add=function(calendar){var list,sibling,i;list=calendar.isWebCalendar?this.$webcalendars:calendar.isSubscription?this.$subscriptions:this.$calendars,sibling=_.find(list,function(o){return"personal"!=o.id&&1===o.name.localeCompare(calendar.name)}),i=sibling?_.indexOf(_.pluck(list,"id"),sibling.id):1,list.splice(i,0,calendar)},Calendar.$findAll=function(data){var _this=this;return data&&(this.$calendars=[],this.$subscriptions=[],this.$webcalendars=[],angular.forEach(data,function(o,i){var calendar=new Calendar(o);calendar.isWebCalendar?_this.$webcalendars.push(calendar):calendar.isSubscription?_this.$subscriptions.push(calendar):_this.$calendars.push(calendar)})),this.$calendars},Calendar.$get=function(id){var calendar;return calendar=_.find(Calendar.$calendars,function(o){return o.id==id}),calendar||(calendar=_.find(Calendar.$subscriptions,function(o){return o.id==id})),calendar||(calendar=_.find(Calendar.$webcalendars,function(o){return o.id==id})),calendar},Calendar.$subscribe=function(uid,path){var _this=this;return Calendar.$$resource.userResource(uid).fetch(path,"subscribe").then(function(calendarData){var calendar=new Calendar(calendarData);return _.find(_this.$subscriptions,function(o){return o.id==calendarData.id})||Calendar.$add(calendar),calendar})},Calendar.$addWebCalendar=function(url){var _this=this,d=Calendar.$q.defer();return _.find(_this.$webcalendars,function(o){return o.urls.webCalendarURL==url})?d.reject():Calendar.$$resource.post(null,"addWebCalendar",{url:url}).then(function(calendarData){angular.extend(calendarData,{isWebCalendar:!0,isEditable:!0,isRemote:!1,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,void 0,2))}),d.resolve()},function(){d.reject()}),d.promise},Calendar.prototype.init=function(data){angular.extend(this,data),this.isOwned=Calendar.activeUser.isSuperUser||this.owner==Calendar.activeUser.login,this.isSubscription=!this.isRemote&&this.owner!=Calendar.activeUser.login},Calendar.prototype.getClassName=function(base){return angular.isUndefined(base)&&(base="fg"),base+"-folder"+this.id},Calendar.prototype.$rename=function(name){var i=_.indexOf(_.pluck(Calendar.$calendars,"id"),this.id);return this.name=name,Calendar.$calendars.splice(i,1),Calendar.$add(this),this.$save()},Calendar.prototype.$delete=function(){var list,promise,_this=this,d=Calendar.$q.defer();return this.isSubscription?(promise=Calendar.$$resource.fetch(this.id,"unsubscribe"),list=Calendar.$subscriptions):(promise=Calendar.$$resource.remove(this.id),list=this.isWebCalendar?Calendar.$webcalendars:Calendar.$calendars),promise.then(function(){var i=_.indexOf(_.pluck(list,"id"),_this.id);list.splice(i,1),d.resolve()},function(data,status){d.reject(data)}),d.promise},Calendar.prototype.$save=function(){return Calendar.$$resource.save(this.id,this.$omit()).then(function(data){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(t
|
||
|
//# sourceMappingURL=Scheduler.services.js.map
|