[FIX] web: pdfjs: restore download button in attachment viewer

Due to the following PR: https://github.com/odoo/odoo/pull/70092
the download icon wasn't present in the document viewer.
We had to do this to avoid crash in mobile apps (Android and iOS).

But even if there are multiple other ways to download file, some
of our users are used to use pdf js download button that was previously
hidden.

So in this commit, we restore it on desktop as we can now correctly
handle the error on Android tablets and hide this button on iOS tablets.

Note that pdfjs button is not needed on mobile as we doesnt' have
attachements preview on small screens. Another button is available
when you open the file.

Steps to reproduce:
- Go to Accounting
- Customer Invoices
- After printing it once, the download icon wasn't present in pdfjs preview

closes odoo/odoo#74675

X-original-commit: 036c2475ac5c9ae3a0692486badfceb45de1f52b
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
This commit is contained in:
Adrien Dieudonne
2021-08-03 19:56:29 +00:00
parent 6dd35113b3
commit 9a445afffe
@@ -16,12 +16,12 @@ import config from 'web.config';
export function hidePDFJSButtons(rootElement) {
const cssStyle = document.createElement("style");
cssStyle.rel = "stylesheet";
cssStyle.innerHTML = `button#secondaryDownload.secondaryToolbarButton, button#download.toolbarButton,
button#secondaryOpenFile.secondaryToolbarButton, button#openFile.toolbarButton {
cssStyle.innerHTML = `button#secondaryOpenFile.secondaryToolbarButton, button#openFile.toolbarButton {
display: none !important;
}`;
if (config.device.isMobileDevice) {
cssStyle.innerHTML = `${cssStyle.innerHTML}
button#secondaryDownload.secondaryToolbarButton, button#download.toolbarButton,
button#secondaryPrint.secondaryToolbarButton, button#print.toolbarButton{
display: none !important;
}`;