From d1fe280b8a292de0dff1980b110ef75a3b324060 Mon Sep 17 00:00:00 2001 From: Alex Arnaud Date: Fri, 7 Jun 2019 12:33:12 +0200 Subject: [PATCH] Bug 22248: make svc/mana/increment print valid output Test plan: - select an existing comment on a subscription - check the logs, note the error (Can't return outside a subroutine) - apply this patch - select an existing comment again - error should be gone --- koha-tmpl/intranet-tmpl/prog/js/mana.js | 23 +++++++++++------------ svc/mana/increment | 2 +- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/mana.js b/koha-tmpl/intranet-tmpl/prog/js/mana.js index c36faec..d16fbbe 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/mana.js +++ b/koha-tmpl/intranet-tmpl/prog/js/mana.js @@ -3,20 +3,19 @@ function mana_increment(mana_id, resource, fieldvalue, stepvalue ) { $("#mana_comment_progress").show(); if( !stepvalue ){ stepvalue = 1; } - $.ajax({ - type: "POST", - url: "/cgi-bin/koha/svc/mana/increment", - data: {id: mana_id, resource: resource, field: fieldvalue, step: stepvalue}, - datatype: "json", - }) - .done(function() { - $(".mana_comment_status").hide(); - $("#mana_comment_success").show(); + $.ajax({ + type: "POST", + url: "/cgi-bin/koha/svc/mana/increment", + data: {id: mana_id, resource: resource, field: fieldvalue, step: stepvalue}, + dataType: "json", }) - .fail(function( error ) { + .done(function( data ) { $(".mana_comment_status").hide(); - $("#mana_comment_errortext").html( error.status + " " + error.statusText ); - $("#mana_comment_failed").show(); + if ( data.code == "200" ) { + $("#mana_comment_success").show(); + } else { + $("#mana_comment_failed").show(); + } }) .always(function() { mana_comment_close(); diff --git a/svc/mana/increment b/svc/mana/increment index 5b58496..9cb7824 100755 --- a/svc/mana/increment +++ b/svc/mana/increment @@ -45,4 +45,4 @@ my $result = Koha::SharedContent::increment_entity_value( scalar $input->param('step') ); -return $result; +print(to_json($result)); -- 2.7.4