From bcf47ec92bf2807602adde40e1a0c8a2520e77ed Mon Sep 17 00:00:00 2001 From: Philipp Rothmann Date: Fri, 4 Aug 2023 10:56:21 +0200 Subject: [PATCH] feat(messages): add max file size for attachments --- app/javascript/trix-editor-overrides.js | 7 +++++++ config/locales/de.yml | 3 +++ config/locales/en.yml | 3 +++ config/locales/es.yml | 3 +++ config/locales/fr.yml | 3 +++ config/locales/nl.yml | 3 +++ config/locales/tr.yml | 2 ++ 7 files changed, 24 insertions(+) create mode 100644 app/javascript/trix-editor-overrides.js diff --git a/app/javascript/trix-editor-overrides.js b/app/javascript/trix-editor-overrides.js new file mode 100644 index 00000000..64cecbef --- /dev/null +++ b/app/javascript/trix-editor-overrides.js @@ -0,0 +1,7 @@ +// app/javascript/trix-editor-overrides.js +window.addEventListener("trix-file-accept", function(event) { + if (event.file.size > 1024 * 1024 * 512) { + event.preventDefault() + alert(I18n.t('js.trix_editor.file_size_alert')) + } +}) \ No newline at end of file diff --git a/config/locales/de.yml b/config/locales/de.yml index 7fe377ba..b7f77c5d 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -1216,12 +1216,15 @@ de: js: ordering: confirm_change: Änderungen an dieser Bestellung gehen verloren, wenn zu einer anderen Bestellung gewechselt wird. Möchtest Du trotzdem wechseln? + trix_editor: + file_size_alert: Der Dateianhang ist zu groß! Die maximale Größe beträgt 512Mb layouts: email: footer_1_separator: "--" footer_2_foodsoft: 'Foodsoft: %{url}' footer_3_homepage: 'Foodcoop: %{url}' footer_4_help: 'Hilfe: %{url}' + help: 'Hilfe' foodsoft: Foodsoft footer: revision: Revision %{revision} diff --git a/config/locales/en.yml b/config/locales/en.yml index bb00e997..b4f41c5c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1219,12 +1219,15 @@ en: js: ordering: confirm_change: Modifications to this order will be lost when you change the order. Do you want to lose the changes you made and continue? + trix_editor: + file_size_alert: The file is to large! The supported file size is 512Mb! layouts: email: footer_1_separator: "--" footer_2_foodsoft: 'Foodsoft: %{url}' footer_3_homepage: 'Foodcoop: %{url}' footer_4_help: 'Help: %{url}' + help: 'Help' foodsoft: Foodsoft footer: revision: revision %{revision} diff --git a/config/locales/es.yml b/config/locales/es.yml index 2be287bf..6cacb564 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -1080,9 +1080,12 @@ es: js: ordering: confirm_change: Las modificaciones sobre este pedido se perderán cuando cambies el pedido. ¿Quieres perder los cambios que has hecho y continuar? + trix_editor: + file_size_alert: ¡El archivo adjunto es demasiado grande! El tamaño máximo es de 512Mb layouts: email: footer_4_help: 'Ayuda: %{url}' + help: 'Ayuda' footer: revision: revisión %{revision} header: diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 491408dc..cd0971da 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -831,10 +831,13 @@ fr: js: ordering: confirm_change: Les changements apportés à cette commande vont être perdus. Est-ce que tu veux vraiment continuer? + trix_editor: + file_size_alert: Le fichier joint est trop volumineux ! La taille maximale est de 512Mb layouts: email: footer_3_homepage: 'Boufcoop: %{url}' footer_4_help: 'Aide: %{url}' + help: 'Aide' footer: revision: révision %{revision} header: diff --git a/config/locales/nl.yml b/config/locales/nl.yml index e2e8da98..d972c088 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -1189,12 +1189,15 @@ nl: js: ordering: confirm_change: Als je naar een andere bestelling gaat, gaan je aanpassingen in deze bestelling verloren. Wijzigingen vergeten en naar de andere bestelling gaan? + trix_editor: + file_size_alert: De bestandsbijlage is te groot! De maximale grootte is 512Mb! layouts: email: footer_1_separator: "--" footer_2_foodsoft: 'Foodsoft: %{url}' footer_3_homepage: 'Foodcoop: %{url}' footer_4_help: 'Help: %{url}' + help: 'Help' foodsoft: Foodsoft footer: revision: revisie %{revision} diff --git a/config/locales/tr.yml b/config/locales/tr.yml index b66d5c06..76408463 100644 --- a/config/locales/tr.yml +++ b/config/locales/tr.yml @@ -1218,6 +1218,8 @@ tr: js: ordering: confirm_change: Bu siparişe yapılan değişiklikler kaybolacak. Değişikliklerinizi kaybetmek ve devam etmek istiyor musunuz? + trix_editor: + file_size_alert: Dosya eki çok büyük! Maksimum boyut 512Mb layouts: email: footer_1_separator: "--"