From aef4cc49f2c7752477d5d812d8683bde496ee6f9 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Tue, 17 Sep 2019 13:00:25 +0200 Subject: [PATCH] fixes accounting codes setting + improved error handling --- .../javascripts/controllers/admin/invoices.js.erb | 5 ++++- app/assets/javascripts/router.js.erb | 11 ++++++----- app/views/api/settings/bulk_update.json.jbuilder | 2 +- config/locales/app.shared.en.yml | 1 + config/locales/app.shared.es.yml | 1 + config/locales/app.shared.fr.yml | 1 + config/locales/app.shared.pt.yml | 1 + 7 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/controllers/admin/invoices.js.erb b/app/assets/javascripts/controllers/admin/invoices.js.erb index 577d85679..acb651c0c 100644 --- a/app/assets/javascripts/controllers/admin/invoices.js.erb +++ b/app/assets/javascripts/controllers/admin/invoices.js.erb @@ -549,7 +549,10 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I Setting.bulkUpdate( { settings: Object.values($scope.settings) }, function () { growl.success(_t('invoices.codes_customization_success')); }, - function (error) { console.log(error); } + function (error) { + growl.error('unexpected_error_occurred'); + console.error(error); + } ); } diff --git a/app/assets/javascripts/router.js.erb b/app/assets/javascripts/router.js.erb index 9318cd546..ab855ef46 100644 --- a/app/assets/javascripts/router.js.erb +++ b/app/assets/javascripts/router.js.erb @@ -900,11 +900,12 @@ angular.module('application.router', ['ui.router']) settings: ['Setting', function (Setting) { return Setting.query({ names: `['invoice_legals', 'invoice_text', 'invoice_VAT-rate', 'invoice_VAT-active', 'invoice_order-nb', 'invoice_code-value', \ - 'invoice_code-active', 'invoice_reference', 'invoice_logo', 'accounting_journal_code', 'accounting_client_code', \ - 'accounting_client_label', 'accounting_wallet_code', 'accounting_wallet_label', 'accounting_VAT_code', 'accounting_VAT_label', \ - 'accounting_subscription_code', 'accounting_subscription_label', 'accounting_Machine_code', 'accounting_Machine_label', \ - 'accounting_Training_code', 'accounting_Training_label', 'accounting_Event_code', 'accounting_Event_label', \ - 'accounting_Space_code', 'accounting_Space_label', 'accounting_coupon_code', 'accounting_coupon_label']` }).$promise; + 'invoice_code-active', 'invoice_reference', 'invoice_logo', 'accounting_journal_code', 'accounting_card_client_code', \ + 'accounting_card_client_label', 'accounting_site_client_code', 'accounting_site_client_label', 'accounting_wallet_code', \ + 'accounting_wallet_label', 'accounting_VAT_code', 'accounting_VAT_label', 'accounting_subscription_code', \ + 'accounting_subscription_label', 'accounting_Machine_code', 'accounting_Machine_label', 'accounting_Training_code', \ + 'accounting_Training_label', 'accounting_Event_code', 'accounting_Event_label', 'accounting_Space_code', \ + 'accounting_Space_label', 'accounting_coupon_code', 'accounting_coupon_label']` }).$promise; }], invoices: [ 'Invoice', function (Invoice) { return Invoice.list({ diff --git a/app/views/api/settings/bulk_update.json.jbuilder b/app/views/api/settings/bulk_update.json.jbuilder index 3a032b89a..db2ba1972 100644 --- a/app/views/api/settings/bulk_update.json.jbuilder +++ b/app/views/api/settings/bulk_update.json.jbuilder @@ -1,6 +1,6 @@ # frozen_string_literal: true -@settings.each do |setting| +json.settings @settings.each do |setting| if setting[:errors] json.error setting.errors.full_messages json.id setting.id diff --git a/config/locales/app.shared.en.yml b/config/locales/app.shared.en.yml index 80ca87980..a35125a9d 100644 --- a/config/locales/app.shared.en.yml +++ b/config/locales/app.shared.en.yml @@ -101,6 +101,7 @@ en: unlimited: "Unlimited" payment_card_error: "A problem occurred with your payment card:" online_payment_disabled: "Online payment is not available. Please contact the Fablab reception directly." + unexpected_error_occurred: "An unexpected error occurred" messages: you_will_lose_any_unsaved_modification_if_you_quit_this_page: "You will lose any unsaved modification if you quit this page" diff --git a/config/locales/app.shared.es.yml b/config/locales/app.shared.es.yml index 25e9b208d..4b61ef146 100644 --- a/config/locales/app.shared.es.yml +++ b/config/locales/app.shared.es.yml @@ -101,6 +101,7 @@ es: unlimited: "Ilimitado" payment_card_error: "Hubo un problema con su tarjeta:" online_payment_disabled: "El pago en línea no está disponible. Póngase en contacto directamente con la recepción de Fablab." + unexpected_error_occurred: "Ocurrió un error inesperado" messages: you_will_lose_any_unsaved_modification_if_you_quit_this_page: "Si cierra la página se perderán todas las modificaciones que no se hayan guardado" diff --git a/config/locales/app.shared.fr.yml b/config/locales/app.shared.fr.yml index 24bbf383f..f5de76751 100644 --- a/config/locales/app.shared.fr.yml +++ b/config/locales/app.shared.fr.yml @@ -101,6 +101,7 @@ fr: unlimited: "Illimité" payment_card_error: "Un problème est survenu avec votre carte bancaire :" online_payment_disabled: "Le payment par carte bancaire n'est pas disponible. Merci de contacter directement l'accueil du Fablab." + unexpected_error_occurred: "Une erreur inattendue est survenue" messages: you_will_lose_any_unsaved_modification_if_you_quit_this_page: "Vous perdrez les modifications non enregistrées si vous quittez cette page" diff --git a/config/locales/app.shared.pt.yml b/config/locales/app.shared.pt.yml index c82c8d90f..fd38215bd 100755 --- a/config/locales/app.shared.pt.yml +++ b/config/locales/app.shared.pt.yml @@ -101,6 +101,7 @@ pt: unlimited: "Ilimitado" payment_card_error: "A problem occurred with your payment card:" # translation_missing online_payment_disabled: "El pago en línea no está disponible. Póngase en contacto directamente con la recepción de Fablab." + unexpected_error_occurred: "Um erro inesperado ocorreu" messages: you_will_lose_any_unsaved_modification_if_you_quit_this_page: "Você irá perder todas as modificações não salvas se sair desta página"