-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
4143: feat(reports): add file type detection r=jniles a=jniles Adds file type detection to the reports archive page so that we are not proposing to the user to print reports that are not printable (xlsx for example). It also adds features to provide the correct font awesome icon depending on the extension to help a user determine which kind of file they will be downloading. **Example** ![RZoqUH5TAk](https://user-images.githubusercontent.com/896472/73257918-e899a400-41c4-11ea-9898-76bb6bd0a333.gif) 4149: fix(inventory): allow deletion from inventory r=jniles a=jniles This commit removes the foreign key constraints from the inventory_log to allow deletion from the inventory. It also fixes the http headers sent twice error in the error handler. Closes #4147. Co-authored-by: Jonathan Niles <jonathanwniles@gmail.com>
- Loading branch information
Showing
7 changed files
with
157 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* global inject, expect */ | ||
/* eslint no-unused-expressions:off */ | ||
describe('BaseReportService', () => { | ||
// shared services | ||
let SavedReports; | ||
|
||
// load bhima.services | ||
beforeEach(module( | ||
'pascalprecht.translate', | ||
'tmh.dynamicLocale', | ||
'ngStorage', | ||
'angularMoment', | ||
'ui.bootstrap', | ||
'bhima.services', | ||
)); | ||
|
||
|
||
let parseExtension; | ||
let parseIcon; | ||
beforeEach(inject((_BaseReportService_) => { | ||
SavedReports = _BaseReportService_; | ||
parseExtension = SavedReports.parseFileUrlToExtension; | ||
parseIcon = SavedReports.parseFileUrlToIcon; | ||
})); | ||
|
||
describe('#parseUrlToExtension()', () => { | ||
it('correctly parses simple paths', () => { | ||
expect(parseExtension('image.jpg')).to.equal('jpg'); | ||
expect(parseExtension('image.svg')).to.equal('svg'); | ||
expect(parseExtension('doc.docx')).to.equal('docx'); | ||
|
||
expect(parseExtension('/this/is/some/path.pdf')).to.equal('pdf'); | ||
expect(parseExtension('https://github.com/cool.gif')).to.equal('gif'); | ||
|
||
}); | ||
|
||
it('handles error cases', () => { | ||
expect(parseExtension('')).to.equal(''); | ||
expect(parseExtension()).to.equal(''); | ||
}); | ||
|
||
it('correctly parses complex paths', () => { | ||
expect(parseExtension('a.file.with.decimals.pdf')).to.equal('pdf'); | ||
expect(parseExtension('/more/complex/file.with/decimals.gz')).to.equal('gz'); | ||
}); | ||
}); | ||
|
||
describe('#parseUrlToIcon()', () => { | ||
it('correctly parses paths to guess their icons', () => { | ||
expect(parseIcon('icon.png')).to.equal('fa-file-image-o'); | ||
expect(parseIcon('icon.svg')).to.equal('fa-file-image-o'); | ||
|
||
expect(parseIcon('document.doc')).to.equal('fa-file-word-o'); | ||
expect(parseIcon('document.docx')).to.equal('fa-file-word-o'); | ||
|
||
expect(parseIcon('msexcel.xls')).to.equal('fa-file-excel-o'); | ||
expect(parseIcon('msexcel.xlsx')).to.equal('fa-file-excel-o'); | ||
|
||
expect(parseIcon('unknown.what')).to.equal('fa-file-o'); | ||
|
||
|
||
expect(parseIcon('report.pdf')).to.equal('fa-file-pdf-o'); | ||
}); | ||
}); | ||
|
||
}); |