3 lines
58 KiB
JavaScript
3 lines
58 KiB
JavaScript
!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.$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.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",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"),b=a.$subscriptions):(c=a.$$resource.remove(this.id),b=this.isWebCalendar?a.$webcalendars:a.$calendars),c.then(function(){var a=_.indexOf(_.map(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["export"]=function(){return a.$$resource.download(this.id+".ics","export",null,{type:"application/octet-stream"})},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.activeUser("folderURL")+"Calendar",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&&_.forEach(_.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(b,c){var d=this;return a.$Preferences.ready().then(function(e){var f,g,h,i;return f=a.$Preferences.defaults.SOGoFirstDayOfWeek,"day"==b?(g="dayView",h=i=c):"multicolumnday"==b?(g="multicolumndayView",h=i=c):"week"==b?(g="weekView",h=c.beginOfWeek(f),i=new Date,i.setTime(h.getTime()),i.addDays(6)):"month"==b&&(g="monthView",h=c,h.setDate(1),h=h.beginOfWeek(f),i=new Date,i.setTime(h.getTime()),i.setMonth(i.getMonth()+1),i.addDays(-1),i=i.endOfWeek(f)),d.$eventsBlocks(g,h,i)})},a.$eventsBlocks=function(b,c,d){var e,f,g,h,i=[],j=[],k=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 c,d;c=function(b,c,d){var e=_.zipObject(this.eventsFields,c),f=new Date(1e3*e.c_startdate);return e.hour=f.getHourString(),e.blocks=[],b.push(new a(e)),b},d=function(a){this[a.nbr].blocks.push(a),a.component=this[a.nbr]},a.$views=[],a.$timeout(function(){_.forEach(b,function(b,e){var f,k=[],l={},m={};for(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,_.bind(c,b),k),_.forEach(_.flatten(b.blocks),_.bind(d,k)),_.forEach(_.flatten(b.allDayBlocks),_.bind(d,k)),0===i.length&&(i=_.flatMap(b.days,"date"),j=_.flatMap(b.days,"number")),g=0;g<b.blocks.length;g++){for(h=0;h<b.blocks[g].length;h++)b.blocks[g][h].dayIndex=g+e*b.blocks.length,b.blocks[g][h].dayNumber=j[g];l[i[g]]=b.blocks[g]}for(g=0;g<b.allDayBlocks.length;g++){for(h=0;h<b.allDayBlocks[g].length;h++)b.allDayBlocks[g][h].dayIndex=g+e*b.allDayBlocks.length,b.allDayBlocks[g][h].dayNumber=j[g];m[i[g]]=b.allDayBlocks[g]}a.$log.debug("blocks ready ("+_.flatten(b.blocks).length+")"),a.$log.debug("all day blocks ready ("+_.flatten(b.allDayBlocks).length+")"),f={blocks:l,allDayBlocks:m},b.id&&b.calendarName&&(f.id=b.id,f.calendarName=b.calendarName),a.$views.push(f)}),k.resolve(a.$views)})},k.reject),k.promise},a.$unwrapCollection=function(b,c){var d=[];return c.then(function(c){return a.$timeout(function(){var e=_.invokeMap(c.fields,"toLowerCase");return e.splice(_.indexOf(e,"c_folder"),1,"pid"),e.splice(_.indexOf(e,"c_name"),1,"id"),e.splice(_.indexOf(e,"c_recurrence_id"),1,"occurrenceId"),_.reduce(c[b],function(b,c,d){var f=_.zipObject(e,c);return b.push(new a(f)),b},d),a.$log.debug("list of "+b+" ready ("+d.length+")"),a["$"+b]=d,d})})},a.$resetGhost=function(){this.$ghost.pointerHandler=null,this.$ghost.component=null,this.$ghost.startHour=null,this.$ghost.endHour=null},a.$parseDate=function(a,b){var c,d;return c=a.substring(0,10).split("-"),b&&b.no_time?new Date(parseInt(c[0]),parseInt(c[1])-1,parseInt(c[2])):(d=a.substring(11,16).split(":"),new Date(parseInt(c[0]),parseInt(c[1])-1,parseInt(c[2]),parseInt(d[0]),parseInt(d[1]),0,0))},a.prototype.init=function(b){var c=this;if(this.categories=[],this.repeat={},this.alarm={action:"display",quantity:5,unit:"MINUTES",reference:"BEFORE",relation:"START"},this.status="not-specified",this.delta=60,angular.extend(this,b),a.$Preferences.ready().then(function(){var b="appointment"==c.type?"Events":"Tasks";c.classification=c.classification||a.$Preferences.defaults["SOGoCalendar"+b+"DefaultClassification"].toLowerCase()}),"vevent"==this.component?this.type="appointment":"vtodo"==this.component&&(this.type="task"),this.startDate?angular.isString(this.startDate)?this.start=a.$parseDate(this.startDate):this.start=this.startDate:"appointment"==this.type&&(this.start=new Date,this.start.setMinutes(15*Math.round(this.start.getMinutes()/15))),this.endDate?(this.end=a.$parseDate(this.endDate),this.delta=this.start.minutesTo(this.end)):"appointment"==this.type&&this.setDelta(this.delta),this.dueDate&&(this.due=a.$parseDate(this.dueDate)),this.completedDate?this.completed=a.$parseDate(this.completedDate):"task"==this.type&&(this.completed=new Date),this.c_category&&(this.categories=_.invokeMap(this.c_category,"asCSSIdentifier")),this.$isRecurrent=angular.isDefined(b.repeat),this.repeat.days){var d=_.find(this.repeat.days,function(a){return angular.isDefined(a.occurrence)});d&&("yearly"==this.repeat.frequency&&(this.repeat.year={byday:!0}),this.repeat.month={type:"byday",occurrence:d.occurrence.toString(),day:d.day})}else this.repeat.days=[];angular.isUndefined(this.repeat.frequency)&&(this.repeat.frequency="never"),angular.isUndefined(this.repeat.interval)&&(this.repeat.interval=1),angular.isUndefined(this.repeat.month)&&(this.repeat.month={occurrence:"1",day:"SU",type:"bymonthday"}),angular.isUndefined(this.repeat.monthdays)&&(this.repeat.monthdays=[]),angular.isUndefined(this.repeat.months)&&(this.repeat.months=[]),angular.isUndefined(this.repeat.year)&&(this.repeat.year={}),this.repeat.count?this.repeat.end="count":this.repeat.until?(this.repeat.end="until",this.repeat.until=a.$parseDate(this.repeat.until,{no_time:!0})):this.repeat.end="never",this.$hasCustomRepeat=this.hasCustomRepeat(),this.isNew?a.$Preferences.ready().then(function(){var b={M:"MINUTES",H:"HOURS",D:"DAYS",W:"WEEKS"},d=/-PT?([0-9]+)([MHDW])/.exec(a.$Preferences.defaults.SOGoCalendarDefaultReminder);d&&(c.$hasAlarm=!0,c.alarm.quantity=parseInt(d[1]),c.alarm.unit=b[d[2]])}):this.$hasAlarm=angular.isDefined(b.alarm),this.destinationCalendar=this.pid,this.updateFreeBusy(),this.selected=!1},a.prototype.hasCustomRepeat=function(){var a=angular.isDefined(this.repeat)&&(this.repeat.interval>1||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),_.forEach(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()<a.end.getTime()&&c.getDate()==g;)f=c.getHours().toString(),angular.isUndefined(b[h][f])&&(b[h][f]=[]),b[h][f].push(1),c.addMinutes(15)}),b}},a.prototype.updateFreeBusy=function(){var b=this;this.freebusy=this.updateFreeBusyCoverage(),this.attendees&&_.forEach(this.attendees,function(c){c.image=a.$gravatar(c.email,32),b.updateFreeBusyAttendee(c)})},a.prototype.setDelta=function(a){this.delta=a,this.end=new Date(this.start.getTime()),this.end.setMinutes(15*Math.round(this.end.getMinutes()/15)),this.end.addMinutes(this.delta)},a.prototype.updateFreeBusyAttendee=function(b){var c,d,e;b.uid&&(c={sday:this.start.getDayString(),eday:this.end.getDayString()},d=["..","..",b.uid,"freebusy.ifb"],e=_.map(this.start.daysUpTo(this.end),function(a){return a.getDayString()}),angular.isUndefined(b.freebusy)&&(b.freebusy={}),a.$$resource.fetch(d.join("/"),"ajaxRead",c).then(function(a){_.forEach(e,function(c){var d;angular.isUndefined(b.freebusy[c])&&(b.freebusy[c]={}),angular.isUndefined(a[c])&&(a[c]={});for(var e=0;23>=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<this.attachUrls.length&&this.attachUrls[b].value!=a;b++);b==this.attachUrls.length&&this.attachUrls.push({value:a})}return this.attachUrls.length-1},a.prototype.deleteAttachUrl=function(a){a>-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(b){var c,d,e,f,g=this;return e=this.$omit(),f=a.$Preferences.$mdDateLocaleProvider,e.startDate=e.start?e.start.format(f,"%Y-%m-%d"):"",e.startTime=e.start?e.start.format(f,"%H:%M"):"",e.endDate=e.end?e.end.format(f,"%Y-%m-%d"):"",e.endTime=e.end?e.end.format(f,"%H:%M"):"",e.dueDate=e.due?e.due.format(f,"%Y-%m-%d"):"",e.dueTime=e.due?e.due.format(f,"%H:%M"):"",e.completedDate=e.completed?e.completed.format(f,"%Y-%m-%d"):"",this.$hasCustomRepeat?"monthly"==this.repeat.frequency&&this.repeat.month.type&&"byday"==this.repeat.month.type||"yearly"==this.repeat.frequency&&this.repeat.year.byday?(delete e.repeat.monthdays,e.repeat.days=[{day:this.repeat.month.day,occurrence:this.repeat.month.occurrence.toString()}]):"monthly"!=this.repeat.frequency&&"yearly"!=this.repeat.frequency||!this.repeat.month.type||delete e.repeat.days:this.repeat.frequency&&"never"!=this.repeat.frequency&&(e.repeat={frequency:this.repeat.frequency}),this.repeat.frequency?"until"==this.repeat.end&&this.repeat.until?e.repeat.until=this.repeat.until.stringWithSeparator("-"):"count"==this.repeat.end&&this.repeat.count?e.repeat.count=this.repeat.count:(delete e.repeat.until,delete e.repeat.count):delete e.repeat,"not-specified"==this.status?delete e.status:"completed"!=this.status&&delete e.completedDate,this.$hasAlarm?!this.alarm.action||"email"!=this.alarm.action||this.attendees&&this.attendees.length>0||(e.alarm.attendees=0,e.alarm.organizer=1):e.alarm={},d=[this.pid,this.id],this.isNew&&(c={action:"saveAs"+this.type.capitalize()}),this.occurrenceId&&d.push(this.occurrenceId),angular.extend(e,b),a.$$resource.save(d.join("/"),e,c).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.copyTo=function(b){return a.$$resource.post(this.pid+"/"+this.id,"copy",{destination:b})},a.prototype.moveTo=function(b){return a.$$resource.post(this.pid+"/"+this.id,"move",{destination:b})},a.prototype.toString=function(){return"[Component "+this.id+"]"}}(),function(){"use strict";function a(b,c,d,e,f,g,h){function i(){a.expandedAllDays=!a.expandedAllDays,n.expandedAllDays=a.expandedAllDays}function j(){g.$eventsBlocksForView(e.view,e.day.asDate()).then(function(a){n.views=a,_.forEach(n.views,function(a){a.id&&(a.calendar=new f({id:a.id,name:a.calendarName}))})})}function k(a){var b=angular.element(a.currentTarget).attr("date");d.go("calendars.view",{day:b})}function l(a){d.go("calendars.view",{view:a})}var m,n=this;angular.isUndefined(a.expandedAllDays)&&(a.expandedAllDays=!1),n.expandedAllDays=a.expandedAllDays,n.toggleAllDays=i,n.views=h,n.changeDate=k,n.changeView=l,m=c.$on("calendars:list",j),b.$on("$destroy",m)}a.$inject=["$scope","$rootScope","$state","$stateParams","Calendar","Component","stateEventsBlocks"],angular.module("SOGo.SchedulerUI").controller("CalendarController",a)}(),function(){"use strict";function a(a,b,c,d,e,f,g,h){function i(a,b){(b&&b.reload||A.componentType!=a)&&(angular.isUndefined(h["$"+a])&&h.$filter(a),A.unselectComponents(),A.componentType=a,h.saveSelectedList(a))}function j(){_.forEach(h["$"+A.componentType],function(a){a.selected=!1}),A.mode.multiple=0}function k(){_.forEach(h["$"+A.componentType],function(a){a.selected=!0}),A.mode.multiple=h["$"+A.componentType].length}function m(a,b){b.selected=!b.selected,A.mode.multiple+=b.selected?1:-1,a.preventDefault(),a.stopPropagation()}function n(){e.confirm(l("Warning"),l("Are you sure you want to delete the selected components?"),{ok:l("Delete")}).then(function(){var b=_.filter(h["$"+A.componentType],function(a){return a.selected});g.$deleteComponents(b).then(function(){a.$emit("calendars:list")})})}function o(a,b){q(a,b,"appointment")}function p(a,b){q(a,b,"task")}function q(a,b,c){if(b.viewable){var e="UIx"+c.capitalize()+"ViewTemplate";d.show({parent:angular.element(document.body),targetEvent:a,clickOutsideToClose:!0,escapeToClose:!0,templateUrl:e,controller:"ComponentController",controllerAs:"editor",locals:{stateComponent:b}})}}function r(a,b){var c,e="appointment";b?(c=b,e=b.type):("tasks"==A.componentType&&(e="task"),c=new h({pid:g.$defaultCalendar(),type:e}));var f="UIx"+e.capitalize()+"EditorTemplate";return d.show({parent:angular.element(document.body),targetEvent:a,clickOutsideToClose:!0,escapeToClose:!0,templateUrl:f,controller:"ComponentEditorController",controllerAs:"editor",locals:{stateComponent:c}})}function s(c){function e(a,b,c,d){a.updateThisOccurrence=function(){c.$adjust(d).then(b.hide,function(a){b.cancel().then(function(){f(a,c,d)})})},a.updateAllOccurrences=function(){delete c.occurrenceId,c.$adjust(d).then(b.hide,function(a){b.cancel().then(function(){f(a,c,d)})})}}function f(b,c,e){403==b.status&&b.data&&b.data.message&&angular.isObject(b.data.message)&&d.show({parent:angular.element(document.body),clickOutsideToClose:!1,escapeToClose:!1,templateUrl:"UIxAttendeeConflictDialog",controller:i,controllerAs:"$AttendeeConflictDialogController",locals:{component:c,params:e,conflictError:b.data.message}}).then(function(){a.$emit("calendars:list")})}function i(a,b,c,d,e){function f(){c.$adjust(angular.extend({ignoreConflicts:!0},d)).then(b.hide)}var g=this;g.conflictError=e,g.cancel=b.cancel,g.save=f}var j,k,m,n,o,p,q;j=h.$ghost.component,k=h.$ghost.pointerHandler,j.isNew?(m=k.currentEventCoordinates,j.summary="",j.isAllDay&&(m.duration-=96),j.setDelta(15*m.duration),r(null,j)["finally"](function(){b(function(){h.$resetGhost()})})):(n=k.currentEventCoordinates.getDelta(k.originalEventCoordinates),o={days:n.dayNumber,start:15*n.start,duration:15*n.duration},k.originalCalendar&&0!==n.dayNumber&&(p=k.currentEventCoordinates.dayNumber,q=_.filter(g.$findAll(),{active:1}),o.destination=q[p].id,o.days=0),j.isException||!j.occurrenceId?j.$adjust(o).then(function(){a.$emit("calendars:list")},function(a){f(a,j,o)})["finally"](function(){b(function(){h.$resetGhost()})}):j.occurrenceId&&d.show({clickOutsideToClose:!0,escapeToClose:!0,locals:{component:j,params:o},template:['<md-dialog flex="50" sm-flex="80" xs-flex="90">',' <md-dialog-content class="md-dialog-content">'," <p>"+l("editRepeatingItem")+"</p>"," </md-dialog-content>"," <md-dialog-actions>",' <md-button ng-click="updateThisOccurrence()">'+l("button_thisOccurrenceOnly")+"</md-button>",' <md-button ng-click="updateAllOccurrences()">'+l("button_allOccurrences")+"</md-button>"," </md-dialog-actions>","</md-dialog>"].join(""),controller:e}).then(function(){a.$emit("calendars:list")})["finally"](function(){b(function(){h.$resetGhost()})})),e.$inject=["$scope","$mdDialog","component","params"],i.$inject=["$scope","$mdDialog","component","params","conflictError"]}function t(){return h["$query"+A.componentType.capitalize()].filterpopup}function u(a){h.$filter(A.componentType,{filterpopup:a})}function v(a){return h["$query"+A.componentType.capitalize()].filterpopup==a}function w(a){h.$filter(A.componentType,{sort:a})}function x(a){return h["$query"+A.componentType.capitalize()].sort==a}function y(){a.$emit("calendars:list")}function z(){A.mode.search=!1,h.$filter(A.componentType,{value:""})}var A=this;A.component=h,A.componentType="events",A.selectedList=0,A.selectComponentType=i,A.unselectComponents=j,A.selectAll=k,A.toggleComponentSelection=m,A.confirmDeleteSelectedComponents=n,A.openEvent=o,A.openTask=p,A.newComponent=r,A.filterpopup=t,A.filter=u,A.filteredBy=v,A.sort=w,A.sortedBy=x,A.reload=y,A.cancelSearch=z,A.mode={search:!1,multiple:0},f.ready().then(function(){var a="events";"tasksListView"==f.settings.Calendar.SelectedList&&(A.selectedList=1,a="tasks"),i(a,{reload:!0})}),a.$on("calendars:list",function(){h.$filter(A.componentType,{reload:!0})}),a.$on("calendar:dragend",s)}a.$inject=["$rootScope","$timeout","$state","$mdDialog","Dialog","Preferences","Calendar","Component"],angular.module("SOGo.SchedulerUI").controller("CalendarListController",a)}(),function(){"use strict";function a(a,b,c,d,e,f,g,h,i,j,k,m,n,o){function p(a,b){a.clearData()}function q(){m.saveFoldersOrder(_.flatMap(m.$findAll(),"id"))}function r(){H.sortableCalendars.disabled=!H.sortableCalendars.disabled,H.sortableSubscriptions.disabled=!H.sortableSubscriptions.disabled,H.sortableWebCalendars.disabled=!H.sortableWebCalendars.disabled,H.filter.name=""}function s(){m.saveFoldersOrder()}function t(a){i.prompt(l("New calendar"),l("Name of the Calendar")).then(function(a){var b=new m({name:a,isEditable:!0,isRemote:!1,owner:UserLogin});b.$id().then(function(){m.$add(b)})})}function u(){i.prompt(l("Subscribe to a web calendar..."),l("URL of the Calendar"),{inputType:"url"}).then(function(a){m.$addWebCalendar(a)})}function v(a){a.isSubscription?a.$delete()["catch"](function(b,c){i.alert(l('An error occured while deleting the calendar "%{0}".',a.name),l(b.error))}):i.confirm(l("Warning"),l('Are you sure you want to delete the calendar "%{0}"?',a.name),{ok:l("Delete")}).then(function(){a.$delete()["catch"](function(b,c){i.alert(l('An error occured while deleting the calendar "%{0}".',a.name),l(b.error))})})}function w(b,c){function e(b,c,d){function e(a){var b=0===a.type.indexOf("text")||/\.(ics)$/.test(a.name);return b||f.show({template:["<md-toast>",' <div class="md-toast-content">',' <md-icon class="md-warn md-hue-1">error_outline</md-icon>'," <span>"+l("Select an iCalendar file (.ics).")+"</span>"," </div>","</md-toast>"].join(""),position:"top right",hideDelay:3e3}),b}var h=this;h.uploader=new g({url:ApplicationBaseURL+[d.id,"import"].join("/"),autoUpload:!0,queueLimit:1,filters:[{name:e,fn:e}],onSuccessItem:function(b,d,e,g){var h;c.hide(),0===d.imported?h=l("No event was imported."):(h=l("A total of %{0} events were imported in the calendar.",d.imported),a.$emit("calendars:list")),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){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.searchText=""):K.component.addAttendee(a)}function s(a){K.component.deleteAttendee(a),0===K.component.attendees.length&&(K.showAttendeesEditor=!1)}function t(){return K.component&&K.component.priority?K.component.priority>5?l("low"):K.component.priority>4?l("normal"):l("high"):void 0}function u(b,c){b.$valid&&K.component.$save(c).then(function(b){a.$emit("calendars:list"),e.hide(),k.getAlarms()},function(a){403==a.status&&a.data&&a.data.message&&angular.isObject(a.data.message)&&(K.attendeeConflictError=a.data.message)})}function v(){K.component.$reset(),K.component.isNew&&(K.component=null),e.cancel()}function w(){var a=[];return K.component.start&&K.component.end&&(a=K.component.start.daysUpTo(K.component.end)),_.map(a,function(a){return{stringWithSeparator:a.stringWithSeparator(),getDayString:a.getDayString()}})}function x(){for(var a=[],b=0;23>=b;b++)a.push(b.toString());return a}function y(){K.component.$addStartDate(),H=new Date(K.component.start.getTime())}function z(){K.component.$addDueDate(),J=new Date(K.component.due.getTime())}function A(){K.component.start.addMinutes(60*H.getHours()+H.getMinutes()),B()}function B(){var a;a=H.valueOf()-K.component.start.valueOf(),0!==a&&(H=new Date(K.component.start.getTime()),"appointment"===K.component.type&&(K.component.end=new Date(K.component.start.getTime()),K.component.end.addMinutes(K.component.delta),I=new Date(K.component.end.getTime())),G())}function C(){K.component.end.addMinutes(60*I.getHours()+I.getMinutes()),D()}function D(){var a=I.valueOf()-K.component.end.valueOf();0!==a&&(a=K.component.start.minutesTo(K.component.end),0>a?K.component.end=new Date(I.getTime()):(K.component.delta=a,I=new Date(K.component.end.getTime())),G())}function E(){K.component.due.addMinutes(60*J.getHours()+J.getMinutes()),F()}function F(){J=new Date(K.component.due.getTime())}function G(){K.attendeesEditor.days=w(),K.component.updateFreeBusy()}var H,I,J,K=this;K.service=g,K.component=m,K.categories={},K.showRecurrenceEditor=K.component.$hasCustomRepeat,K.toggleRecurrenceEditor=o,K.showAttendeesEditor=angular.isDefined(K.component.attendees),K.toggleAttendeesEditor=p,K.cardFilter=q,K.addAttendee=r,K.removeAttendee=s,K.addAttachUrl=n,K.priorityLevel=t,K.cancel=v,K.save=u,K.attendeeConflictError=!1,K.attendeesEditor={days:w(),hours:x()},K.addStartDate=y,K.addDueDate=z,K.updateStartTime=A,K.adjustStartTime=B,K.updateEndTime=C,K.adjustEndTime=D,K.updateDueTime=E,K.adjustDueTime=F,K.component.start&&(H=new Date(K.component.start.getTime())),K.component.end&&(I=new Date(K.component.end.getTime())),K.component.due&&(J=new Date(K.component.due.getTime()))}a.$inject=["$rootScope","$mdDialog","Calendar","Component","AddressBook","Alarm","stateComponent"],b.$inject=["$rootScope","$scope","$log","$timeout","$mdDialog","User","Calendar","Component","AddressBook","Card","Alarm","stateComponent"],angular.module("SOGo.SchedulerUI").controller("ComponentController",a).controller("ComponentEditorController",b)}(),function(){"use strict";function a(){return{restrict:"E",scope:{day:"@sgDay",dayNumber:"@sgDayNumber",dayString:"@sgDayString",calendar:"@sgCalendar"},controller:b}}function b(a,b){this.day=a.day,this.dayNumber=a.dayNumber,this.dayString=a.dayString,this.calendarData=function(){var c,d,e;return a.calendar?(c=a.calendar,e=_.filter(b.$findAll(),{active:1}),d=_.findIndex(e,function(a){return a.id==c}),{pid:c,index:d}):null}}b.$inject=["$scope","Calendar"],angular.module("SOGo.SchedulerUI").directive("sgCalendarDay",a)}(),function(){"use strict";function a(a){function b(a,b){var c=_.has(b,"sgCalendarGhost")?"":"::";return['<div class="sg-event"'," ng-class=\"{'sg-event--dragging': block.dragging}\">",' <div class="eventInside"',' ng-click="clickBlock({clickEvent: $event, clickComponent: block.component})">',' <div class="sg-category" ng-repeat="category in '+c+'block.component.categories"'," ng-class=\"'bg-category' + category\""," ng-style=\"{ right: ($index * 3) + 'px' }\"></div>",' <div class="text">',' <span ng-show="'+c+'block.component.c_priority" class="sg-priority">{{'+c+"block.component.c_priority}}</span>"," {{ "+c+"block.component.summary }}",' <span class="icons">',' <md-icon ng-if="'+c+'block.component.occurrenceId" class="material-icons icon-repeat"></md-icon>',' <md-icon ng-if="'+c+'block.component.c_nextalarm" class="material-icons icon-alarm"></md-icon>',' <md-icon ng-if="'+c+'block.component.c_classification == 1" class="material-icons icon-visibility-off"></md-icon>',' <md-icon ng-if="'+c+'block.component.c_classification == 2" class="material-icons icon-vpn-key"></md-icon>'," </span>",' <div class="secondary" ng-if="'+c+'block.component.c_location">'," <md-icon>place</md-icon> {{"+c+"block.component.c_location}}"," </div>"," </div>"," </div>",' <div class="ghostStartHour" ng-if="block.startHour">{{ block.startHour }}</div>',' <div class="ghostEndHour" ng-if="block.endHour">{{ block.endHour }}</div>',"</div>"].join("")}function c(a,b,c){var d,e,f;_.has(c,"sgCalendarGhost")||(d=100/a.block.siblings,e=a.block.position*d,f=100-(a.block.position+1)*d,100>d&&(e>0&&(e-=2),f>0&&(f-=2)),0===e&&(e=2),0===f&&(f=2),b.css("left",e+"%"),b.css("right",f+"%"),a.block.component&&a.block.component.c_isallday||(b.addClass("starts"+a.block.start),b.addClass("lasts"+a.block.length)),a.block.userState&&b.addClass("sg-event--"+a.block.userState),a.block.component&&(b.addClass("bg-folder"+a.block.component.pid),b.addClass("contrast-bdr-folder"+a.block.component.pid),0===a.block.component.c_isopaque&&b.addClass("sg-event--transparent")))}return{restrict:"E",scope:{block:"=sgBlock",clickBlock:"&sgClick"},replace:!0,template:b,link:c}}a.$inject=["CalendarSettings"],angular.module("SOGo.SchedulerUI").directive("sgCalendarDayBlock",a)}(),function(){"use strict";function a(){return{restrict:"E",scope:{blocks:"=sgBlocks",day:"@sgDay",clickBlock:"&sgClick"},template:["<sg-calendar-day-block",' class="sg-draggable-calendar-block"',' ng-repeat="block in blocks[day]"',' sg-block="block"',' sg-click="clickBlock({event: clickEvent, component: clickComponent})"/>'].join("")}}angular.module("SOGo.SchedulerUI").directive("sgCalendarDayTable",a)}(),function(){"use strict";function a(a,b,c,d,e){function f(f,g,h,i){function j(){var a,b,c;f.block=e.$ghost,b=q.calendarData(),b&&(s=b.index,a=b.pid,t=f.block.pointerHandler.originalCalendar.index),a||(a=f.block.component.pid),c=f.block.component.blocks[0].userState,c&&g.addClass("sg-event--"+c),g.addClass("bg-folder"+a)}function k(){_.forEachRight(p.classList,function(a){/^bg-folder/.test(a)&&g.removeClass(a)}),g.addClass("ng-hide")}function l(){var a,e,h,i,j,k,l,m,p;if(a=!1,p=function(){g.removeClass("sg-event--notransition")},d.$view&&d.$view.type==r.type){if(e="multiday-allday"===r.type,h=f.block.pointerHandler.currentEventCoordinates.dayNumber,j=f.block.pointerHandler.currentEventCoordinates.start,l=f.block.pointerHandler.currentEventCoordinates.duration,m=c.EventDragDayLength-j,angular.isUndefined(l))return;for(k=l,k>m&&(k=m),h>-1&&(0>s&&h==q.dayNumber||h==s&&(t==s||!f.block.component.isException))&&(a=!0,e||(f.block.startHour=n(j),i=0===parseInt(g.css("top")),i&&g.addClass("sg-event--notransition"),d.$view.quarterHeight?(g.css("top",j*d.$view.quarterHeight+"px"),g.css("height",k*d.$view.quarterHeight+"px")):g.css("top",d.$view.topOffset+"px"),i&&b(p)),g.removeClass("fg-folder"+f.block.component.pid),g.removeClass("sg-event--ghost--last"),g.addClass("sg-event--ghost--first")),l-=k,h++;!a&&l&&h<=q.dayNumber;)k=l,k>c.EventDragDayLength&&(k=c.EventDragDayLength),h>-1&&h==q.dayNumber&&(a=!0,e||(i=0!==parseInt(g.css("top")),i&&g.addClass("sg-event--notransition"),g.css("top",d.$view.topOffset+"px"),d.$view.quarterHeight&&g.css("height",k*d.$view.quarterHeight+"px"),i&&b(p)),g.removeClass("sg-event--ghost--first"),g.removeClass("sg-event--ghost--last"),g.addClass("fg-folder"+f.block.component.pid)),l-=k,h++,j=0;l||(e?g.addClass("sg-event--ghost--last"):f.block.endHour=o(j,k))}a?g.removeClass("ng-hide"):g.addClass("ng-hide")}function m(a){var b,c,d;return b=15*a,c=Math.floor(b/60),10>c&&(c="0"+c),d=b%60,10>d&&(d="0"+d),""+c+":"+d}function n(a){return m(a)}function o(a,b){var d=(a+b)%c.EventDragDayLength;return m(d)}var p,q,r,s,t;p=g[0],q=i[0],r=i[1],s=-1,g.addClass("sg-event--ghost md-whiteframe-3dp ng-hide");var u=a.$on("calendar:dragstart",j),v=a.$on("calendar:drag",l),w=a.$on("calendar:dragend",k);f.$on("$destroy",function(){u(),v(),w()})}return{restrict:"A",require:["^sgCalendarDay","^sgCalendarScrollView"],link:f}}a.$inject=["$rootScope","$timeout","CalendarSettings","Calendar","Component"],angular.module("SOGo.SchedulerUI").directive("sgCalendarGhost",a)}(),function(){"use strict";function a(){return{restrict:"E",scope:{blocks:"=sgBlocks",day:"@sgDay",clickBlock:"&sgClick"},template:["<sg-calendar-month-event",' class="sg-draggable-calendar-block"',' ng-repeat="block in blocks[day]"',' sg-block="block"',' sg-click="clickBlock({event: clickEvent, component: clickComponent})"/>'].join("")}}angular.module("SOGo.SchedulerUI").directive("sgCalendarMonthDay",a)}(),function(){"use strict";function a(){function a(a,b){var c=_.has(b,"sgCalendarGhost")?"":"::";return['<div class="sg-event"'," ng-class=\"{'sg-event--dragging': block.dragging}\"",' ng-click="clickBlock({clickEvent: $event, clickComponent: block.component})">',' <span class="secondary" ng-if="'+c+'!block.component.c_isallday">{{ '+c+"block.starthour }}</span>",' <span ng-show="'+c+'block.component.c_priority" class="sg-priority">{{'+c+"block.component.c_priority}}</span>"," {{ "+c+"block.component.summary }}",' <span class="icons">',' <md-icon ng-if="'+c+'block.component.occurrenceId" class="material-icons icon-repeat"></md-icon>',' <md-icon ng-if="'+c+'block.component.c_nextalarm" class="material-icons icon-alarm"></md-icon>',' <md-icon ng-if="'+c+'block.component.c_classification == 1" class="material-icons icon-visibility-off"></md-icon>',' <md-icon ng-if="'+c+'block.component.c_classification == 2" class="material-icons icon-vpn-key"></md-icon>'," </span>","</div>"].join("")}function b(a,b,c){_.has(c,"sgCalendarGhost")||(a.block.userState&&b.addClass("sg-event--"+a.block.userState),a.block.component&&(b.addClass("bg-folder"+a.block.component.pid),0===a.block.component.c_isopaque&&b.addClass("sg-event--transparent")))}return{restrict:"E",scope:{block:"=sgBlock",clickBlock:"&sgClick"},replace:!0,template:a,link:b}}angular.module("SOGo.SchedulerUI").directive("sgCalendarMonthEvent",a)}(),function(){"use strict";function a(a,c,d,e,f,g,h,i,j){return{restrict:"A",scope:{type:"@sgCalendarScrollView"},controller:b,link:function(b,d,e,g){function k(){var a;a=l(),t={type:v,quarterHeight:a,scrollStep:6*a,dayNumbers:n(),maxX:o(),element:u},angular.element(c).on("resize",p),p(),"monthly"!=v&&j.ready().then(function(){var b,c,d;j.defaults.SOGoDayStartTime&&(b=j.defaults.SOGoDayStartTime.split(":"),c=document.getElementById("hour"+parseInt(b[0])),d=parseInt(b[1])*a,u.scrollTop=c.offsetTop+d)})}function l(){var a,b,c=null;return a=document.getElementById("hour0"),b=document.getElementById("hour23"),a&&b&&(c=(b.offsetTop-a.offsetTop)/92),c}function m(a){var b,c,d,e,f,g,h;return c=b=d=e=0,f=u.getElementsByClassName("day"),f.length>0&&(g=f[0].getBoundingClientRect(),c=g.height,b=g.width,d=g.left-a,h=f[0].getElementsByClassName("sg-calendar-tile-header"),h.length>0&&(e=h[0].clientHeight)),{height:c,width:b,offset:{left:d,top:e}}}function n(){var a,b,c=null;return u.attributes["sg-view"]&&(c=u.attributes["sg-view"].value),a="multicolumndayview"==c,b=u.getElementsByTagName("sg-calendar-day"),_.map(b,function(b,c){return a?c:parseInt(b.attributes["sg-day-number"].value)})}function o(){var a,b=0;return"monthly"==v?(a=u.getElementsByTagName("md-grid-list")[0],b=parseInt(a.attributes["md-cols"].value)-1):b=u.getElementsByClassName("day").length-1,b}function p(){var a,b;a=u.getBoundingClientRect(),b=m(a.left),angular.extend(t,{coordinates:{x:a.left,y:a.top},dayHeight:b.height,dayWidth:b.width,daysOffset:b.offset.left,topOffset:b.offset.top})}function q(){d.on("mouseover",s),s()}function r(){d.off("mouseover",s),h.$view=null}function s(){var a,b,c,d,e,f,g;b=i.$ghost.pointerHandler,t&&b&&(a=t.scrollStep,c=b.getContainerBasedCoordinates(t),c&&(h.$view=t,d=(new Date).getTime(),(!w||d>w+100)&&(w=d,e=c.y-a,0>e?(f=-u.scrollTop,f>e&&(e=f),u.scrollTop+=e):(e=c.y+a,g=e-u.clientHeight,g>0&&(u.scrollTop+=g)))))}var t,u,v,w,x,y,z;t=null,u=d[0],v=b.type,w=0,x=null,y=a.$on("calendar:dragstart",q),z=a.$on("calendar:dragend",r),f(k),b.$on("$destroy",function(){y(),z(),d.off("mouseover",s),angular.element(c).off("resize",p)})}}}function b(a){this.type=a.type}a.$inject=["$rootScope","$window","$document","$q","$timeout","$mdGesture","Calendar","Component","Preferences"],b.$inject=["$scope"],angular.module("SOGo.SchedulerUI").directive("sgCalendarScrollView",a)}(),function(){"use strict";function a(a,b,c,d,e,f,g){function h(h,i,j,k){function m(){var a,b,c,d,e,f,g,j,k,l;a=h.block.component,b=h.block.dayIndex,c=_.findIndex(a.blocks,["dayIndex",b]),d=0===c,e=c===a.blocks.length-1,f=angular.element('<div class="dragGrip"></div>'),f.addClass("bdr-folder"+a.pid),a.c_isallday||"SG-CALENDAR-MONTH-DAY"===i[0].parentNode.tagName?(d&&(g=angular.element('<div class="dragGrip-left"></div>').append(f),i.append(g)),e&&(j=angular.element('<div class="dragGrip-right"></div>').append(f.clone()),i.append(j))):(d&&(k=angular.element('<div class="dragGrip-top"></div>').append(f),i.append(k)),e&&(l=angular.element('<div class="dragGrip-bottom"></div>').append(f.clone()),i.append(l)))}function n(a){var b,c;a.stopPropagation(),b="move-event",h.block&&h.block.component?"dragGrip-top"==a.target.className||"dragGrip-left"==a.target.className?b="change-start":"dragGrip-bottom"!=a.target.className&&"dragGrip-right"!=a.target.className||(b="change-end"):b="change-end",c=new t(b),c.initFromEvent(a),g.$ghost.pointerHandler=c,angular.element(document).one("mouseup",q),angular.element(document).on("mousemove",p)}function o(b){var f,j,m,n,o,p,q,r,s;m=i.hasClass("clickableHourCell"),n="SG-CALENDAR-MONTH-DAY"==i[0].parentNode.tagName||i.hasClass("clickableDayCell"),s=k.calendarData(),h.block&&h.block.component?f=h.block:(o=k.dayString.parseDate(d.$mdDateLocaleProvider,"%Y-%m-%e"),p={type:"appointment",pid:s?s.pid:e.$defaultCalendar(),summary:l("New Event"),startDate:o,isAllDay:m?0:1},q=new g(p),f={component:q,dayNumber:k.dayNumber,length:0},f.component.blocks=[f]),j="multiday",n?j="monthly":f.component.c_isallday&&(j="multiday-allday"),_.forEach(f.component.blocks,function(a){a.dragging=!0}),r=g.$ghost.pointerHandler,r.prepareWithEventType(j),r.initFromBlock(f),s&&r.initFromCalendar(s),g.$ghost.component=f.component,c.debug("emit calendar:dragstart "+j),a.$emit("calendar:dragstart")}function p(a){var c=g.$ghost.pointerHandler;b(function(){c.updateFromEvent(a)})}function q(b){var c,d;c=h.block,d=g.$ghost.pointerHandler,angular.element(document).off("mousemove",p),d.dragHasStarted&&(a.$emit("calendar:dragend"),d.dragHasStarted=!1),c&&c.component&&_.forEach(c.component.blocks,function(a){a.dragging=!1})}function r(){}function s(a){this.setEventType(a)}function t(a){this.dragMode=a}if(h.block){if(!h.block.component.editable)return void i.removeClass("sg-draggable-calendar-block");m()}i.on("mousedown",n),h.$on("$destroy",function(){i.off("mousedown",n),i.off("mousemove",p)}),r.prototype={x:-1,y:-1,getDelta:function(a){var b=new r;return b.x=this.x-a.x,b.y=this.y-a.y,e.$view&&(b.days=e.$view.dayNumbers[this.x]-e.$view.dayNumbers[a.x]),b},getDistance:function(a){var b=this.getDelta(a);return Math.sqrt(b.x*b.x+b.y*b.y)},clone:function(){var a=new r;return a.x=this.x,a.y=this.y,a}},s.prototype={dayNumber:-1,weekDay:-1,start:-1,duration:-1,eventType:null,setEventType:function(a){this.eventType=a},initFromBlock:function(a){var b=-1;"monthly"===this.eventType?(this.start=0,this.duration=a.component.blocks.length*f.EventDragDayLength):(this.start=a.component.blocks[0].start,this.duration=_.sumBy(a.component.blocks,function(a){var c,d;return d=a.dayNumber,c=0>b?0:d-b-1,b=d,a.length+c*f.EventDragDayLength}))},initFromCalendar:function(a){this.dayNumber=a},getDelta:function(a){var b=new s;return b.dayNumber=this.dayNumber-a.dayNumber,b.start=this.start-a.start,b.duration=this.duration-a.duration,b},_quartersToHM:function(a){var b=15*a,c=Math.floor(b/60);10>c&&(c="0"+c);var d=b%60;return 10>d&&(d="0"+d),""+c+":"+d},getStartTime:function(){return this._quartersToHM(this.start)},getEndTime:function(){var a=(this.start+this.duration)%f.EventDragDayLength;return this._quartersToHM(a)},clone:function(){var a=new s;return a.dayNumber=this.dayNumber,a.start=this.start,a.duration=this.duration,a}},t.prototype={originalCoordinates:null,currentCoordinates:null,originalViewCoordinates:null,currentViewCoordinates:null,originalEventCoordinates:null,currentEventCoordinates:null,originalCalendar:null,dragHasStarted:!1,getEventViewCoordinates:null,initFromBlock:function(a){this.currentEventCoordinates=new s(this.eventType),this.originalEventCoordinates=new s(this.eventType),this.originalEventCoordinates.initFromBlock(a)},initFromEvent:function(a){this.currentCoordinates=new r,this.updateFromEvent(a),this.originalCoordinates=this.currentCoordinates.clone()},initFromCalendar:function(a){this.originalCalendar=a,this.currentEventCoordinates.initFromCalendar(a.index),this.originalEventCoordinates.initFromCalendar(a.index)},updateFromEvent:function(a){if(this.currentCoordinates.x=a.pageX,this.currentCoordinates.y=a.pageY,this.dragHasStarted&&e.$view){var b=this.getEventViewCoordinates(e.$view);this.originalViewCoordinates||(this.originalViewCoordinates=this.getEventViewCoordinates(e.$view,this.originalCoordinates),g.$ghost.component.isNew&&(this.setTimeFromQuarters(g.$ghost.component.start,this.originalViewCoordinates.y),c.debug("new event start date "+g.$ghost.component.start))),this.currentViewCoordinates&&b&&b.x==this.currentViewCoordinates.x&&b.y==this.currentViewCoordinates.y||(this.currentViewCoordinates=b,this.originalViewCoordinates&&(b||(this.currentViewCoordinates=this.originalViewCoordinates.clone()),this.updateEventCoordinates()))}else if(this.originalCoordinates&&this.currentCoordinates&&!this.dragHasStarted){var d=this.getDistance();d>3&&(this.dragHasStarted=!0,o(a))}},updateEventCoordinates:function(){var b,d=this.currentViewCoordinates.getDelta(this.originalViewCoordinates),g=d.days*f.EventDragDayLength+d.y;c.debug("quarters delta "+g),angular.isUndefined(this.originalEventCoordinates.start)?(this.originalEventCoordinates.dayNumber=e.$view.dayNumbers[this.originalViewCoordinates.x],this.originalEventCoordinates.start=this.originalViewCoordinates.y):this.originalEventCoordinates.dayNumber<0&&(this.originalEventCoordinates.dayNumber=e.$view.dayNumbers[h.block.component.blocks[0].dayIndex]),this.currentEventCoordinates.dayNumber=this.originalEventCoordinates.dayNumber,"move-event"==this.dragMode?(this.currentEventCoordinates.start=this.originalEventCoordinates.start+g,this.currentEventCoordinates.duration=this.originalEventCoordinates.duration):"change-start"==this.dragMode?(b=this.originalEventCoordinates.duration-g,b>0?(this.currentEventCoordinates.start=this.originalEventCoordinates.start+g,this.currentEventCoordinates.duration=b):0>b&&(this.currentEventCoordinates.start=this.originalEventCoordinates.start+this.originalEventCoordinates.duration,this.currentEventCoordinates.duration=-b)):"change-end"==this.dragMode&&(b=this.originalEventCoordinates.duration+g,b>0?(this.currentEventCoordinates.start=this.originalEventCoordinates.start,this.currentEventCoordinates.duration=b):0>b&&(this.currentEventCoordinates.start=this.originalEventCoordinates.start+b,this.currentEventCoordinates.duration=-b));var i;this.currentEventCoordinates.start<0?(i=Math.ceil(-this.currentEventCoordinates.start/f.EventDragDayLength),this.currentEventCoordinates.start+=i*f.EventDragDayLength,this.currentEventCoordinates.dayNumber-=i):this.currentEventCoordinates.start>=f.EventDragDayLength&&(i=Math.floor(this.currentEventCoordinates.start/f.EventDragDayLength),this.currentEventCoordinates.start-=i*f.EventDragDayLength,this.currentEventCoordinates.dayNumber+=i),c.debug("event coordinates "+JSON.stringify(this.currentEventCoordinates)),a.$emit("calendar:drag")},getContainerBasedCoordinates:function(a,b){var c=b||this.currentCoordinates,d=c.getDelta(a.coordinates),e=a.element;return(d.x<a.daysOffset||d.x>e.clientWidth||d.y<0||d.y>e.clientHeight)&&(d=null),d},prepareWithEventType:function(a){var b={multiday:this.getEventMultiDayViewCoordinates,"multiday-allday":this.getEventMultiDayAllDayViewCoordinates,monthly:this.getEventMonthlyViewCoordinates,unknown:null},c=b[a];this.eventType=a,this.getEventViewCoordinates=c},getEventMultiDayViewCoordinates:function(a,b){var c=this.getEventMultiDayAllDayViewCoordinates(a,b);if(c){var d=a.quarterHeight,e=this.getContainerBasedCoordinates(a,b);e.y+=a.element.scrollTop,c.y=Math.floor((e.y-f.EventDragHorizontalOffset)/d);var g=f.EventDragDayLength-1;c.y<0?c.y=0:c.y>g&&(c.y=g)}return c},getEventMultiDayAllDayViewCoordinates:function(a,b){var c,d=this.getContainerBasedCoordinates(a,b);if(d){c=new r;var f=a.dayWidth,g=a.daysOffset;c.x=Math.floor((d.x-g)/f);var h=0,i=e.$view.maxX;if("move-event"!=this.dragMode){var j=k.calendarData();j&&(h=i=j.index)}c.x<h?c.x=h:c.x>i&&(c.x=i),c.y=0}else c=null;return c},getEventMonthlyViewCoordinates:function(a,b){var c,d=this.getContainerBasedCoordinates(a,b);if(d){c=new r;var e=a.maxX,f=0,g=a.dayWidth,h=a.daysOffset,i=a.dayHeight,j=Math.floor((d.y-f)/i);0>j&&(j=0),c.x=Math.floor((d.x-h)/g),c.x<0?c.x=0:c.x>e&&(c.x=e),c.x+=(e+1)*j,c.y=0}else c=null;return c},getDistance:function(){return this.currentCoordinates.getDistance(this.originalCoordinates)},setTimeFromQuarters:function(a,b){var c,d;c=Math.floor(b/4),d=b%4*15,a.setHours(c,d)}}}return{restrict:"CA",require:"^sgCalendarDay",link:h}}a.$inject=["$rootScope","$timeout","$log","Preferences","Calendar","CalendarSettings","Component"],angular.module("SOGo.SchedulerUI").directive("sgDraggableCalendarBlock",a)}();
|
|
//# sourceMappingURL=Scheduler.services.js.map
|