Skip to content

Commit ad1df1c

Browse files
authored
Merge pull request #1879 from DXCanas/pdf-message-update
Adding custom compatibility error message in pdfRender
2 parents 3c97b42 + a14c8c7 commit ad1df1c

File tree

1 file changed

+32
-9
lines changed
  • kolibri/plugins/document_pdf_render/assets/src/views

1 file changed

+32
-9
lines changed

kolibri/plugins/document_pdf_render/assets/src/views/index.vue

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,26 @@
44
ref="container"
55
class="container"
66
:class="{ 'container-mimic-fullscreen': mimicFullscreen }">
7+
78
<k-button
8-
class="btn"
99
v-if="supportsPDFs"
10+
class="btn"
1011
:text="isFullscreen ? $tr('exitFullscreen') : $tr('enterFullscreen')"
11-
@click="toggleFullScreen"
12-
:primary="true"/>
12+
:primary="true"
13+
@click="toggleFullscreen"
14+
/>
15+
16+
<template v-else>
17+
<p role="alert">
18+
{{ $tr('pdfCompatibilityError') }}
19+
</p>
20+
<a :href="pdfURL">
21+
{{ $tr('pdfDownloadLink')}}
22+
</a>
23+
</template>
24+
1325
<div ref="pdfcontainer" class="pdfcontainer"></div>
26+
1427
</div>
1528

1629
</template>
@@ -21,7 +34,19 @@
2134
import PDFobject from 'pdfobject';
2235
import ScreenFull from 'screenfull';
2336
import kButton from 'kolibri.coreVue.components.kButton';
37+
38+
const pdfObjectOptions = {
39+
fallbackLink: false,
40+
};
41+
2442
export default {
43+
$trs: {
44+
pdfCompatibilityError: 'Unable to display the document',
45+
pdfDownloadLink: 'Download the PDF file',
46+
exitFullscreen: 'Exit fullscreen',
47+
enterFullscreen: 'Enter fullscreen',
48+
},
49+
name: 'pdfRender',
2550
components: { kButton },
2651
props: ['defaultFile'],
2752
data: () => ({
@@ -33,6 +58,9 @@
3358
fullscreenAllowed() {
3459
return ScreenFull.enabled;
3560
},
61+
pdfURL() {
62+
return this.defaultFile.storage_url;
63+
},
3664
mimicFullscreen() {
3765
return !this.fullscreenAllowed && this.isFullscreen;
3866
},
@@ -53,7 +81,7 @@
5381
},
5482
},
5583
mounted() {
56-
PDFobject.embed(this.defaultFile.storage_url, this.$refs.pdfcontainer);
84+
PDFobject.embed(this.pdfURL, this.$refs.pdfcontainer, pdfObjectOptions);
5785
this.$emit('startTracking');
5886
const self = this;
5987
this.timeout = setTimeout(() => {
@@ -66,11 +94,6 @@
6694
}
6795
this.$emit('stopTracking');
6896
},
69-
name: 'pdfRenderer',
70-
$trs: {
71-
exitFullscreen: 'Exit fullscreen',
72-
enterFullscreen: 'Enter fullscreen',
73-
},
7497
};
7598
7699
</script>

0 commit comments

Comments
 (0)