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

3 lines
56 KiB
JavaScript
Raw Normal View History

2016-04-05 20:01:10 +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(a){var b,c,d;b=a.isWebCalendar?this.$webcalendars:a.isSubscription?this.$subscriptions:this.$calendars,c=_.find(b,function(b){return"personal"==a.id||"personal"!=b.id&&1===b.name.localeCompare(a.name)}),d=c?_.indexOf(_.map(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)})):angular.isUndefined(this.$calendars)&&(this.$calendars=[],this.$subscriptions=[],this.$webcalendars=[],a.$$resource.fetch("calendarslist").then(function(b){a.$findAll(b.calendars,c)})),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.$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=[];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.prototype.init=function(b){this.color=this.color||"#AAAAAA",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,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(_.map(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"),
2016-04-21 23:57:08 +02:00
E.newCalendar=p,E.addWebCalendar=q,E.confirmDelete=r,E.editFolder=y,E.revertEditing=z,E.renameFolder=A,E.share=B,E.importCalendar=s,E.exportCalendar=t,E.showOnly=u,E.showAll=v,E.showLinks=w,E.showProperties=x,E.subscribeToFolder=C,E.today=D,k.ready().then(function(){E.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())})),d.length>0&&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){function h(){b.hide()}function i(a){return e.$filterAll(a),e.$cards}function j(){var a="vevent"==u.component.component?"Appointment":"Task";b.hide().then(function(){var c="UIx"+a+"EditorTemplate";b.show({parent:angular.element(document.body),clickOutsideToClose:!0,escapeToClose:!0,templateUrl:c,controller:"ComponentEditorController",controllerAs:"editor",locals:{stateComponent:u.component}})})}function k(){t=c.$get(u.component.pid).$getComponent(u.component.id),t.$futureComponentData.then(function(){u.component=t,j()})}function m(c){var d=c||u.component;d.$reply().then(function(){a.$emit("calendars:list"),b.hide(),f.getAlarms()})}function n(){t=c.$get(u.component.pid).$getComponent(u.component.id),t.$futureComponentData.then(function(){t.reply=u.component.reply,t.delegatedTo=u.component.delegatedTo,t.$hasAlarm=u.component.$hasAlarm,t.alarm=u.component.alarm,m(t)})}function o(){u.component.remove(!0).then(function(){a.$emit("calendars:list"),b.hide()})}function p(){u.component.remove().then(function(){a.$emit("calendars:list"),b.hide()})}function q(a){c.$$resource.post(u.component.pid+"/"+u.component.id,"raw").then(function(c){function d(a,b){a.close=function(){b.hide()}}b.hide(),b.show({parent:angular.element(document.body),targetEvent:a,clickOutsideToClose:!0,escapeToClose:!0,template:['<md-dialog flex="80" flex-xs="100" aria-label="'+l("View Raw Source")+'">',' <md-dialog-content class="md-dialog-content">'," <pre>",c," </pre>"," </md-dialog-content>"," <md-dialog-actions>",' <md-button ng-click="close()">'+l("Close")+"</md-button>"," </md-dialog-actions>","</md-dialog>"].join(""),controller:d}),d.$inject=["scope","$mdDialog"]})}function r(c){u.component.copyTo(c).then(function(){b.hide(),a.$emit("calendars:list")})}function s(c){u.component.moveTo(c).then(function(){b.hide(),a.$emit("calendars:list")})}var t,u=this;u.calendarService=c,u.service=d,u.component=g,u.close=h,u.cardFilter=i,u.edit=j,u.editAllOccurrences=k,u.reply=m,u.replyAllOccurrences=n,u.deleteOccurrence=o,u.deleteAllOccurrences=p,u.toggleRawSource=q,u.copySelectedComponent=r,u.moveSelectedComponent=s,angular.isUndefined(u.component.$futureComponentData)&&(t=c.$get(u.component.pid).$getComponent(u.component.id,u.component.occurrenceId),t.$futureComponentData.then(function(){u.component=t,u.organizer=[u.component.organizer]}))}function b(a,b,c,d,e,f,g,h,i,j,k,m){function n(){var a=K.component.addAttachUrl("");focus("attachUrl_"+a)}function o(){K.showRecurrenceEditor=!K.showRecurrenceEditor,K.component.$hasCustomRepeat=K.showRecurrenceEditor}function p(){K.showAttendeesEditor=!K.showAttendeesEditor}function q(a){return i.$filterAll(a),i.$cards}function r(a){angular.isString(a)?a.isValidEmail()&&(K.component.addAttendee(new j({emails:[{value:a}]})),K.s
//# sourceMappingURL=Scheduler.services.js.map