(js) Fix download of exported folders under iOS

Whenever possible, we no longer rely on the FileSaver.js library to
download zip archives. Instead, we do a simple GET on the resource by
changing the window location.
This commit is contained in:
Francis Lachapelle committed 2018-05-16 16:46:29 -04:00
1 parent 0c5b5446dd
commit c966ad60e7
5 files changed
+23 -6

No files matched your search

@@ -11,10 +11,11 @@
* @param {String} path - the base path of the external resource
* @param {Object} options - extra attributes to be associated to the object
*/
function Resource($http, $q, path, activeUser, options) {
function Resource($http, $q, $window, path, activeUser, options) {
angular.extend(this, {
_http: $http,
_q: $q,
_window: $window,
_path: path,
_activeUser: activeUser
});
@@ -28,9 +29,9 @@
* @desc The factory we'll use to register with Angular.
* @return a new Resource object
*/
Resource.$factory = ['$http', '$q', function($http, $q) {
Resource.$factory = ['$http', '$q', '$window', function($http, $q, $window) {
return function(path, activeUser, options) {
return new Resource($http, $q, path, activeUser, options);
return new Resource($http, $q, $window, path, activeUser, options);
};
}];
@@ -232,6 +233,15 @@
});
};
Resource.prototype.open = function(id, action) {
var path = [this._path];
if (id) path.push(id);
if (action) path.push(action);
path = _.compact(_.flatten(path)).join('/');
this._window.location.href = path;
};
/**
* @function remove
* @memberof Resource.prototype
@@ -723,7 +723,12 @@
data = { uids: _.map(selectedCards, 'id') };
}
return AddressBook.$$resource.download(this.id, 'export', data, options);
if (data) {
return AddressBook.$$resource.download(this.id, 'export', data, options);
}
else {
return AddressBook.$$resource.open(this.id, 'export', data, options);
}
};
/**
@@ -683,7 +683,7 @@
options = { filename: this.name + '.zip' };
return Mailbox.$$resource.download(this.id, 'exportFolder', null, options);
return Mailbox.$$resource.open(this.id, 'exportFolder', null, options);
};
/**
@@ -554,7 +554,7 @@
filename: this.name + '.ics'
};
return Calendar.$$resource.download(this.id + '.ics', 'export', null, options);
return Calendar.$$resource.open(this.id + '.ics', 'export', null, options);
};
/**