Commit e2137ec9 authored by Dumitru Corini's avatar Dumitru Corini Committed by benjaminParisel

fix(fileViewer) Allows IE11 and Edge download (#2763)

- Allows to download none previewable files for IE11 and Edge

Closes[BPO-24](https://bonitasoft.atlassian.net/browse/BPO-24)
parent 16603294
......@@ -41,6 +41,17 @@ function WidgetController($scope, $log, $window, $sce) {
}
};
controller.getDocumentDownloadUrl = function() {
if (isTypeProcessDocument() && controller.document) {
if (isInitializedByAnExternalSystem(controller.document)) {
return controller.document.url;
}
return "../API/" + controller.document.url;
} else {
return $scope.properties.url;
}
};
controller.getTrustedDocumentViewUrl = function() {
return $sce.trustAsResourceUrl(controller.getDocumentViewUrl());
};
......
......@@ -16,10 +16,10 @@
{{ ctrl.fileName || ctrl.getDocumentViewUrl() }}
</a>
<a class="FileViewer-fileName"
title="{{'Download' | uiTranslate}} {{ ctrl.fileName || ctrl.getDocumentViewUrl() }}"
title="{{'Download' | uiTranslate}} {{ ctrl.fileName || ctrl.getDocumentDownloadUrl() }}"
ng-if="!ctrl.isImage() && !ctrl.isPDF()"
ng-href="{{ctrl.getDocumentViewUrl()}}">
{{ ctrl.fileName || ctrl.getDocumentViewUrl() }}
ng-href="{{ctrl.getDocumentDownloadUrl()}}">
{{ ctrl.fileName || ctrl.getDocumentDownloadUrl() }}
</a>
<div ng-if="properties.showPreview && ctrl.isPDF() && !ctrl.isMobileDevice()">
......
......@@ -75,6 +75,38 @@ describe('FileViewer Widget', function() {
expect(element.find('a[box-viewer]').text().trim()).toEqual('pdf-test.pdf');
});
it('should download zip process documents initialized by an external system', function() {
scope.properties.type = 'Process document';
scope.properties.document = {
id: 'unused',
fileName: null,
url: 'http://westgov.org/zip/files/zip-test.zip'
};
scope.$apply();
expect(element.find('a[box-viewer]').length).toBe(0);
expect(element.find('a').attr('href')).toEqual('http://westgov.org/zip/files/zip-test.zip');
expect(element.find('a').attr('title')).toEqual('Download zip-test.zip');
expect(element.find('a').text().trim()).toEqual('zip-test.zip');
expect(element.find('span.FileViewer-previewNotAvailable').length).toBe(1);
expect(element.find('iframe').length).toBe(0);
expect(element.find('img').length).toBe(0);
});
it('should download zip documents with URL type', function() {
scope.properties.type = 'URL';
scope.properties.url = 'http://westgov.org/zip/files/zip-test.zip';
scope.$apply();
expect(element.find('a[box-viewer]').length).toBe(0);
expect(element.find('a').attr('href')).toEqual('http://westgov.org/zip/files/zip-test.zip');
expect(element.find('a').attr('title')).toEqual('Download zip-test.zip');
expect(element.find('a').text().trim()).toEqual('zip-test.zip');
expect(element.find('span.FileViewer-previewNotAvailable').length).toBe(1);
expect(element.find('iframe').length).toBe(0);
expect(element.find('img').length).toBe(0);
});
it('should contain no preview on unsupported document', function() {
scope.properties.document.fileName = 'bonita.docx';
scope.properties.document.id = '321';
......@@ -82,7 +114,7 @@ describe('FileViewer Widget', function() {
scope.properties.type = 'Process document';
scope.$apply();
expect(element.find('a[box-viewer]').length).toBe(0);
expect(element.find('a').attr('href')).toEqual('../API/formsDocumentImage?document=321');
expect(element.find('a').attr('href')).toEqual('../API/documentDownload?fileName=bonita.docx&contentStorageId=321');
expect(element.find('span.FileViewer-previewNotAvailable').length).toBe(1);
expect(element.find('iframe').length).toBe(0);
expect(element.find('img').length).toBe(0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment