(js) Export calendar subscriptions

Fixes #4560
pull/243/head
Francis Lachapelle 2018-10-09 13:59:25 -04:00
parent 93bb95d256
commit e4f6be243e
4 changed files with 18 additions and 5 deletions

1
NEWS
View File

@ -6,6 +6,7 @@ Enhancements
- [web] new button to mark a task as completed (#4531)
- [web] new button to reset Calendar categories to defaults
- [web] moved the unseen messages count to the beginning of the window's title (#4553)
- [web] allow export of calendars subscriptions (#4560)
Bug fixes
- [web] include mail account name in form validation (#4532)

View File

@ -226,7 +226,7 @@
SOGoAppointmentFolderICS = {
methods = {
export = {
protectedBy = "View";
protectedBy = "Access Contents Information";
actionClass = "UIxCalFolderActions";
actionName = "export";
};

View File

@ -487,7 +487,7 @@
ng-show="list.component.$isLoading()">
<md-progress-circular class="md-accent"
md-mode="indeterminate"
md-diameter="32"><!-- mailbox loading progress --></md-progress-circular>
md-diameter="32"><!-- components loading progress --></md-progress-circular>
</div>
</div>
@ -572,7 +572,7 @@
<var:string label:value="Import"/>
</md-button>
</md-menu-item>
<md-menu-item ng-hide="::($menuCtrl.calendar.isSubscription || $menuCtrl.calendar.isWebCalendar)">
<md-menu-item ng-hide="::$menuCtrl.calendar.isWebCalendar">
<md-button ng-click="$menuCtrl.calendar.export()">
<var:string label:value="Export"/>
</md-button>

View File

@ -554,14 +554,26 @@
* @returns a promise of the HTTP operation
*/
Calendar.prototype.export = function() {
var options;
var options, resource, ownerPaths, realOwnerId, path, index;
options = {
type: 'application/octet-stream',
filename: this.name + '.ics'
};
return Calendar.$$resource.open(this.id + '.ics', 'export', null, options);
if (this.isSubscription) {
index = this.urls.webDavICSURL.indexOf('/dav/');
ownerPaths = this.urls.webDavICSURL.substring(index + 5).split(/\//);
realOwnerId = ownerPaths[0];
resource = Calendar.$$resource.userResource(realOwnerId);
path = ownerPaths.splice(ownerPaths.length - 2).join('/');
}
else {
resource = Calendar.$$resource;
path = this.id + '.ics';
}
return resource.open(path, 'export', null, options);
};
/**