From e9f0a6e586bf972a5b3fa1b4751b5e1e7816ef8a Mon Sep 17 00:00:00 2001 From: yelinz Date: Tue, 20 Feb 2024 18:32:26 +0100 Subject: [PATCH] feat: add button to convert to pdf Integrates backend endpoint to convert docx, odt to pdf --- README.md | 7 ++++ addon/components/document-view.hbs | 7 ++-- addon/components/document-view.js | 2 +- addon/components/documents-side-panel.hbs | 5 ++- addon/components/single-document-details.hbs | 15 +++++++- addon/components/single-document-details.js | 35 +++++++++++++++++-- addon/models/file.js | 3 +- addon/services/alexandria-config.js | 6 ++++ tests/dummy/app/services/alexandria-config.js | 2 ++ .../single-document-details-test.js | 24 +++++++++++++ translations/de.yaml | 3 ++ translations/en.yaml | 3 ++ 12 files changed, 104 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 075ed166..e6818a3a 100644 --- a/README.md +++ b/README.md @@ -199,6 +199,13 @@ module.exports = function () { }; ``` +### Others + +- `enablePDFConversion`: Set to `true` to enable docx/odt to pdf conversion. Make sure the backend is enabled aswell. +- `namespace`: Set to API namespace +- `zipDownloadHost`: Set if the ZIP download is different +- `zipDownloadNamespace`: Set if the ZIP download is namespaced + ## Contributing See the [Contributing](CONTRIBUTING.md) guide for details. diff --git a/addon/components/document-view.hbs b/addon/components/document-view.hbs index 077cde6a..b7a2be1c 100644 --- a/addon/components/document-view.hbs +++ b/addon/components/document-view.hbs @@ -8,7 +8,7 @@
@@ -86,7 +86,10 @@ {{/if}}
- +
{{#if (eq @selectedDocuments.length 1)}} - + {{else}}
-
+
+ {{#if this.displayConvertButton}} +
+ + {{t "alexandria.document-details.convert"}} + +
+ {{/if}} +
`, + ); + + assert.dom("[data-test-convert-button]").doesNotExist(); + + this.selectedDocument = { + latestFile: { + value: { mimeType: "application/vnd.oasis.opendocument.text" }, + }, + }; + + await render( + hbs``, + ); + + assert.dom("[data-test-convert-button]").exists(); + }); }); diff --git a/translations/de.yaml b/translations/de.yaml index 1eebecb9..3e761031 100644 --- a/translations/de.yaml +++ b/translations/de.yaml @@ -20,6 +20,7 @@ alexandria: update: "Änderungen konnten nicht gespeichert werden. Versuchen Sie es erneut." no-permission: "Sie haben keine Berechtigung, diese Aktion auszuführen." move-document: "Beim Verschieben {count, plural, one {des Dokumentes} other {von # Dokumenten}} ist ein Fehler aufgetreten" + convert-pdf: "Während dem Umwandeln ist ein Fehler aufgetreten." success: delete-document: "Das Dokument wurde erfolgreich gelöscht." @@ -30,6 +31,7 @@ alexandria: } erfolgreich hochgeladen. update: "Änderungen wurden gespeichert." move-document: "{count, plural, one {Das Dokument wurde} other {# Dokumente wurden}} erfolgreich verschoben" + convert-pdf: "Dokument wurde erfolgreich umgewandelt." category-nav: all-files: "Alle Dokumente" @@ -70,6 +72,7 @@ alexandria: created-by-user: "Erstellt von Benutzer" created-by-group: "Erstellt von Gruppe" replace: "Ersetzen" + convert: "Zu PDF" tags: title: "Tags" add: "Hinzufügen" diff --git a/translations/en.yaml b/translations/en.yaml index 04db3897..4ea38857 100644 --- a/translations/en.yaml +++ b/translations/en.yaml @@ -20,6 +20,7 @@ alexandria: update: "Your changes chould'nt be saved. Please try again." no-permission: "You don't have permission to perform this action." move-document: "While moving {count, plural, one {the document} other {# documents}}, an error occured. Please try again." + convert-pdf: "While converting, an error occured. Please try again." success: delete-document: "Document deleted successfully" @@ -30,6 +31,7 @@ alexandria: } uploaded successfully. update: "Changes saved." move-document: "{count, plural, one {Document} other {# documents}} moved successfully" + convert-pdf: "Document converted successfully." category-nav: all-files: "All documents" @@ -70,6 +72,7 @@ alexandria: created-by-user: "Created by user" created-by-group: "Created by group" replace: "Replace" + convert: "To PDF" tags: title: "Tags" add: "Add"