Bug 15477: (follow-up) Bug 14100: Better errors handling
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 6 Jan 2016 11:17:00 +0000 (11:17 +0000)
committerBrendan Gallagher <brendan@bywatersolutions.com>
Tue, 12 Jan 2016 16:13:41 +0000 (16:13 +0000)
On bug 14100, the patch "Better errors handling" introduced an ...
error.
The user always get "An error occurred when updating this translation"
although it has been updated in DB.

Test plan:
Edit translations for an item type: you should not get an error when
everything went fine.

Tested on top of 15487, error message does no longer appear.
Signed-off-by: Marc VĂ©ron <veron@veron.ch>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com

koha-tmpl/intranet-tmpl/prog/en/modules/admin/localization.tt
svc/localization

index 2730a08..2d6e5b4 100644 (file)
             type: 'PUT',
             url: '/cgi-bin/koha/svc/localization',
             success: function (data) {
-                if ( data.is_changed ) {
+                if ( data.error ) {
+                    $(cell).css('background-color', '#FF0000');
+                    show_message({ type: 'error_on_update', data: data });
+                } else if ( data.is_changed == 1 ) {
                     $(cell).css('background-color', '#00FF00');
                     show_message({ type: 'success_on_update', data: data });
-                } else {
-                    show_message({ type: 'error_on_update', data: data });
                 }
+
                 if ( $(cell).hasClass('lang') ) {
                     $(cell).text(data.lang)
                 } else if ( $(cell).hasClass('translation') ) {
index 1f10f67..e0f362d 100755 (executable)
@@ -37,7 +37,9 @@ sub update_translation {
         $localization->translation( $translation )
     }
     my %params;
+    my $is_changed;
     if ( $localization->is_changed ) {
+        $is_changed = 1;
         unless ( Koha::Localizations->search( { entity => $localization->entity, code => $localization->code, lang => $lang, localization_id => { '!=' => $localization->localization_id }, } )->count ) {
             $localization->store;
         } else {
@@ -52,6 +54,7 @@ sub update_translation {
         code        => $localization->code,
         lang        => $localization->lang,
         translation => $localization->translation,
+        is_changed  => $is_changed,
     );
     C4::Service->return_success( $response );
 }