1 /* global mana_comment_close */
3 function mana_increment(mana_id, resource, fieldvalue, stepvalue ) {
4 $("#mana_comment_progress").show();
5 if( !stepvalue ){ stepvalue = 1; }
8 url: "/cgi-bin/koha/svc/mana/increment",
9 data: {id: mana_id, resource: resource, field: fieldvalue, step: stepvalue},
13 $(".mana_comment_status").hide();
14 $("#mana_comment_success").show();
16 .fail(function( error ) {
17 $(".mana_comment_status").hide();
18 $("#mana_comment_errortext").html( error.status + " " + error.statusText );
19 $("#mana_comment_failed").show();
26 function mana_comment( target_id, manamsg, resource_type ) {
27 $("#mana_comment_progress").show();
30 url: "/cgi-bin/koha/svc/mana/share",
31 data: { message: manamsg, resource: resource_type, resource_id: target_id },
34 .done(function( data ) {
35 $(".mana_comment_status").hide();
36 if (data.code == "201" || data.code == "200") {
37 $("#mana_comment_success").show();
39 $("#mana_comment_failed").show();
43 $("#selected_id").val("");
44 $("#mana-resource-id").val("");
45 $("#mana-comment").val("");
50 $(document).ready(function() {
52 $("body").on("submit", "#mana_comment_form", function( e ) {
54 var resource_type = $('#mana-resource').val();
55 var resource_id = $('#mana-resource-id').val();
56 var comment = $("#mana-comment").val();
57 mana_comment(resource_id, comment, resource_type);
60 $("body").on("click", '#mana-comment-close', function( e ) {
65 $("body").on("click", ".mana-actions a", function( e ) {
67 $(".mana_comment_status").hide();
68 var commentid = $(this).data("commentid");
69 var resourceid = $(this).data("resourceid");
70 $("#mana-resource-id").val( resourceid );
71 if ( commentid == "other") {
72 if( $("#new_mana_comment").length ){
73 $("#selected_id").val( commentid );
74 $("#mana_results, #new_mana_comment").toggle();
76 $("#mana-comment-box").modal("show");
79 mana_increment( commentid, "resource_comment", "nb");