sogo/UI/WebServerResources/js/Scheduler.services.js

3 lines
62 KiB
JavaScript
Raw Normal View History

2016-06-03 08:05:30 +02:00
!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)}}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(b){var c,d,e;c=b.isWebCalendar?this.$webcalendars:b.isSubscription?this.$subscriptions:this.$calendars,d=_.find(c,function(a){return"personal"==b.id||"personal"!=a.id&&1===a.name.localeCompare(b.name)}),e=d?_.indexOf(_.map(c,"id"),d.id):1,c.splice(e,0,b),this.$Preferences.ready().then(function(){a.$Preferences.settings.Calendar.FoldersOrder&&a.saveFoldersOrder(_.flatMap(a.$findAll(),"id"))})},a.$findAll=function(b,c){var d=this;if(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)});else if(angular.isUndefined(this.$calendars))return this.$calendars=[],this.$subscriptions=[],this.$webcalendars=[],a.$$resource.fetch("calendarslist").then(function(b){return a.$findAll(b.calendars,c)});return c?_.union(this.$calendars,_.filter(this.$subscriptions,function(a){return a.isOwned||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(_.map(a.$calendars,"id"),b),0>c&&(c=_.indexOf(_.map(a.$subscriptions,"id"),b)),0>c&&(c=_.indexOf(_.map(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(angular.extend({active:1},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.$$resource.fetch(e.id,"reload").then(function(b){a.$log.debug(JSON.stringify(b,void 0,2)),a.$add(e),d.resolve()},function(a){401==a.status?d.resolve(e):d.reject()})},d.reject),d.promise},a.reloadWebCalendars=function(){var b=[];return _.forEach(this.$webcalendars,function(c){var d=a.$$resource.fetch(c.id,"reload");d.then(function(a){c.$error=!1},function(a){c.$error=l(a.statusText)}),b.push(d)}),a.$q.all(b)},a.$deleteComponents=function(b){var c={},d=[];return _.forEach(b,function(a){angular.isDefined(c[a.pid])||(c[a.pid]=[]),c[a.pid].push(a.id)}),_.forEach(c,function(b,c){d.push(a.$$resource.post(c,"batchDelete",{uids:b}))}),a.$q.all(d)},a.saveFoldersOrder=function(b){return this.$$resource.post(null,"saveFoldersOrder",{folders:b}).then(function(){return a.$Preferences.settings.Calendar.FoldersOrder=b,b?void 0:a.$$resource.fetch("calendarslist").then(function(b){return a.$findAll(b.calendars)})})},a.prototype.init=function(b){this.color=this.color||"#AAAAAA",this.active=1,angular.extend(this,b),this.id&&(this.$acl=new a.$$Acl("Calendar/"+this.id)),this.isOwned=a.activeUser.isSuperUser||this.owner==a.activeUser.login,this.isSubscription=!this.isRemote&&this.owner!=a.activeUser.login,an
2016-06-06 22:08:01 +02:00
f.show(f.simple().content(h).position("top right").hideDelay(3e3))},onErrorItem:function(a,b,c,d){f.show({template:["<md-toast>",' <div class="md-toast-content">',' <md-icon class="md-warn md-hue-1">error_outline</md-icon>'," <span>"+l("An error occurred while importing calendar.")+"</span>"," </div>","</md-toast>"].join(""),position:"top right",hideDelay:3e3})}}),h.close=function(){c.hide()}}d.show({parent:angular.element(document.body),targetEvent:b,clickOutsideToClose:!0,escapeToClose:!0,templateUrl:"UIxCalendarImportDialog",controller:e,controllerAs:"$CalendarImportDialogController",locals:{folder:c}}),e.$inject=["scope","$mdDialog","folder"]}function x(a){_.forEach(m.$findAll(),function(b){a.id==b.id?b.active=1:b.active=0})}function y(){_.forEach(m.$findAll(),function(a){a.active=1})}function z(a){function b(a,b){function c(){a.hide()}var d=this;d.calendar=b,d.close=c}d.show({parent:angular.element(document.body),clickOutsideToClose:!0,escapeToClose:!0,templateUrl:a.id+"/links",controller:b,controllerAs:"links",locals:{calendar:a}}),b.$inject=["$mdDialog","calendar"]}function A(a){function b(a,b,c){function d(){f.calendar.$save(),c.init(f.calendar.$omit()),b.hide()}function e(){b.cancel()}var f=this;f.calendar=new m(c.$omit()),f.saveProperties=d,f.close=e,a.$watch("properties.calendar.color",function(){c.color=f.calendar.color})}var c=a.color;d.show({templateUrl:a.id+"/properties",controller:b,controllerAs:"properties",clickOutsideToClose:!0,escapeToClose:!0,locals:{srcCalendar:a}})["catch"](function(){a.color=c}),b.$inject=["$scope","$mdDialog","srcCalendar"]}function B(a){H.calendarName=a.name,H.editMode=a.id,h("calendarName_"+a.id)}function C(a){a.$reset(),H.editMode=!1}function D(a){a.$rename().then(function(a){H.editMode=!1})}function E(a){a.$acl.$users().then(function(){d.show({templateUrl:a.id+"/UIxAclEditor",controller:"AclController",controllerAs:"acl",clickOutsideToClose:!0,escapeToClose:!0,locals:{usersWithACL:a.$acl.users,User:n,folder:a}})})}function F(a){e.debug("subscribeToFolder "+a.owner+a.name),m.$subscribe(a.owner,a.name).then(function(a){f.show(f.simple().content(l("Successfully subscribed to calendar")).position("top right").hideDelay(3e3))})}function G(){var a=c.location.hash.split("/"),b=a[1],d=a[2],e=new Date,f=["#",b,d,e.getDayString()];c.location=f.join("/")}var H=this;H.activeUser=j.activeUser,H.service=m,H.newCalendar=t,H.addWebCalendar=u,H.confirmDelete=v,H.editFolder=B,H.revertEditing=C,H.renameFolder=D,H.share=E,H.importCalendar=w,H.showOnly=x,H.showAll=y,H.showLinks=z,H.showProperties=A,H.subscribeToFolder=F,H.today=G,H.filter={name:""},H.toggleSortableMode=r,H.resetSort=s,H.sortableCalendars={disabled:!0,animation:150,draggable:"md-list-item",handle:".md-menu",ghostClass:"sg-sortable-ghost",chosenClass:"sg-sortable-chosen",setData:p,onEnd:q},H.sortableSubscriptions=angular.copy(H.sortableCalendars),H.sortableWebCalendars=angular.copy(H.sortableCalendars),k.ready().then(function(){H.categories=_.map(k.defaults.SOGoCalendarCategories,function(a){return{id:a.asCSSIdentifier(),name:a,color:k.defaults.SOGoCalendarCategoriesColors[a]}})}),b.$watch(function(){return _.union(_.map(m.$calendars,function(a){return _.pick(a,["id","active","color"])}),_.map(m.$subscriptions,function(a){return _.pick(a,["id","active","color"])}),_.map(m.$webcalendars,function(a){return _.pick(a,["id","active","color"])}))},function(b,c){var d,f,g;d=_.intersectionBy(b,c,"id"),f=_.map(_.filter(d,function(a){var b=_.find(c,{id:a.id});return!_.isEqual(a,b)}),"id"),g=[],f.length>0&&(e.debug(f.join(", ")+" changed"),_.forEach(f,function(a){var b=m.$get(a);g.push(b.$setActivation())})),(g.length>0||d.length!=b.length||d.length!=c.length)&&m.$q.all(g).then(function(){a.$emit("calendars:list")})},!0)}a.$inject=["$rootScope","$scope","$window","$mdDialog","$log","$mdToast","FileUploader","sgFocus","Dialog","sgSettings","Preferences","Calendar","User","stateCalendars"],angular.module("SOGo.SchedulerUI").controller("CalendarsController",a)}(),function(){"use strict";function a(a,b,c,d,e,f,g,h){function i(){b.hide()}
//# sourceMappingURL=Scheduler.services.js.map