From f5a20ff59e9d8ab38d166a42acd1d8e27c0f4412 Mon Sep 17 00:00:00 2001 From: Alex Arnaud Date: Fri, 10 Nov 2017 14:46:02 +0000 Subject: [PATCH] Bug 17047 - Move ability to comment mana entities from search results table to report/subscription detail page + code refactoring Rebased-by: Alex Arnaud (2018-07-04) Signed-off-by: Michal Denar Signed-off-by: Michal Denar --- C4/Reports/Guided.pm | 1 + C4/Serials.pm | 6 ++ Koha/SharedContent.pm | 12 +++- koha-tmpl/intranet-tmpl/prog/en/includes/mana.inc | 44 +++++++++++++++ .../en/includes/mana/mana-report-search-result.inc | 27 +-------- .../mana/mana-subscription-search-result.inc | 13 +---- .../prog/en/includes/reports-toolbar.inc | 66 ++++++++++++---------- .../prog/en/includes/serials-toolbar.inc | 35 ++++++++++++ .../en/modules/reports/guided_reports_start.tt | 20 ------- .../intranet-tmpl/prog/js/subscription-add.js | 45 --------------- reports/guided_reports.pl | 4 ++ serials/subscription-detail.pl | 1 + svc/mana/share | 2 +- 13 files changed, 138 insertions(+), 138 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/mana.inc diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm index f8d98e6..c4d783f 100644 --- a/C4/Reports/Guided.pm +++ b/C4/Reports/Guided.pm @@ -33,6 +33,7 @@ use C4::Log; use Koha::AuthorisedValues; use Koha::Patron::Categories; +use Koha::SharedContent; BEGIN { require Exporter; diff --git a/C4/Serials.pm b/C4/Serials.pm index f300c12..24c1eca 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -280,6 +280,12 @@ sub GetSubscription { }); $subscription->{additional_fields} = $additional_field_values->{$subscriptionid}; + if ( my $mana_id = $subscription->{mana_id} ) { + my $mana_subscription = Koha::SharedContent::manaGetRequestWithId( + 'subscription', $mana_id, {usecomments => 1}); + $subscription->{comments} = $mana_subscription->{data}->{comments}; + } + return $subscription; } diff --git a/Koha/SharedContent.pm b/Koha/SharedContent.pm index c54a8e1..ca484c1 100644 --- a/Koha/SharedContent.pm +++ b/Koha/SharedContent.pm @@ -78,9 +78,11 @@ sub manaIncrementRequest { =cut sub manaPostRequest { - my ($lang, $loggedinuser, $resourceid, $resourcetype) = @_; + my ($lang, $loggedinuser, $resourceid, $resourcetype, $content) = @_; - my $content = prepareSharedData($lang, $loggedinuser, $resourceid, $resourcetype); + unless ( $content ) { + $content = prepareSharedData($lang, $loggedinuser, $resourceid, $resourcetype); + } my $result = manaRequest(buildRequest('post', $resourcetype, $content)); @@ -161,8 +163,12 @@ sub buildRequest { if ( $type eq 'getwithid' ) { my $id = shift; + my $params = shift; + $params = join '&', + map { defined $params->{$_} ? $_ . "=" . $params->{$_} : () } + keys %$params; - my $url = "$MANA_IP/$resource/$id.json"; + my $url = "$MANA_IP/$resource/$id.json?$params"; return HTTP::Request->new( GET => $url ); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/mana.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/mana.inc new file mode 100644 index 0000000..d57290c --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/mana.inc @@ -0,0 +1,44 @@ + \ No newline at end of file diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-report-search-result.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-report-search-result.inc index 312af44..b95600c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-report-search-result.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-report-search-result.inc @@ -24,6 +24,7 @@ $(document).ready(function() { }); //]]> +[% INCLUDE 'mana.inc' %] [% IF statuscode == "200" AND reports %] @@ -68,14 +69,6 @@ $(document).ready(function() { [% UNLESS search_only %] [% END %] @@ -86,21 +79,3 @@ $(document).ready(function() { [% ELSE %]

[% msg %] statuscode: [% statuscode %]

[% END %] - - diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-subscription-search-result.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-subscription-search-result.inc index 30e10ca..34c3f42 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-subscription-search-result.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-subscription-search-result.inc @@ -2,7 +2,7 @@ [% USE Koha %] [% USE AuthorisedValues %] [% USE Branches %] - +[% INCLUDE 'mana.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc index 9ba4cc3..bfb1e0f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc @@ -1,4 +1,5 @@ [% INCLUDE 'blocking_errors.inc' %] +[% INCLUDE 'mana.inc' %]
[% IF ( CAN_user_reports_create_reports ) %]
@@ -50,6 +51,40 @@
[% END %] + [% IF ( mana_id && Koha.Preference('Mana') == 1 ) %] +
+ + +
+ + + [% END %] + [% IF ( execute ) %] [% BLOCK params %] [%- FOREACH param IN sql_params %]&sql_params=[% param | uri %][% END %] @@ -110,21 +145,6 @@ }); }); - $('#search_form').on( "submit", function(event) { - event.preventDefault(); - mana_search($(this).children("#mana_search_field").val()); - }); - - function mana_increment(mana_id, resourcename, fieldvalue, stepvalue = 1){ - $.ajax( { - type: "POST", - url: "/cgi-bin/koha/svc/mana/increment", - data: {id: mana_id, field: fieldvalue, resource: resourcename, step: stepvalue}, - datatype: "json", - }).done( function() { - }).fail( function(){ alert("") }); - } - function mana_use( mana_id ){ $.ajax( { type:"POST", @@ -172,13 +192,6 @@ $( "select[class='actionreport1']" ).show(); $( "button[class='actionreport2']" ).hide(); - $("#CommentButton").on("click", function(){ - var resource_type = "report"; - var target_id = $("#selected_id").val(); - var manamsg = $("#manamsg").val(); - mana_comment(target_id, manamsg, resource_type); - $("#comment_box").modal("hide"); - }); $(".showbutton").on("click", function(){ $(this).parent().hide(); @@ -208,13 +221,4 @@ }).fail( function( result ){ }); } - - function mana_comment( target_id, manamsg, resource_type ){ - $.ajax( { - type: "POST", - url: "/cgi-bin/koha/svc/mana/share", - data: {message: manamsg, resource: resource_type , resource_id: target_id}, - datatype: "json", - }) - } diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc index 3661008..cb34f1b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc @@ -1,4 +1,5 @@ [% INCLUDE 'blocking_errors.inc' %] +[% INCLUDE 'mana.inc' %]
- -