Browse Source
This patch makes many changes to templates and JavaScript related to the integration of Mana with serials reports: - Many incorrect uses of the raw filter with html - Corrections to Bootstrap modal markup - Untranslatable strings moved out of JavaScript - Removed markup and JavaScript related to reports comments, a feature which doesn't exist in this version. New include file: mana/mana-comment-status.inc This file contains hidden-by-default messages which are shown during the process of submitting a comment on a subscription. New include file: mana/mana-share-report.inc This file contains the "Share report" modal markup formerly in guided_reports_start.tt New JavaScript file: mana.js Previously mana.inc, an include file containing only JavaScript which didn't include any template processing. Changed: mana/mana-report-search-result.inc This include file is now a full template so that jQuery's load() function can be used to pull its contents into the reports search modal. Changed: svc/mana/search This script was returning json-encoded HTML. Now it returns regular HTML. To test you must have Mana configured and enabled. Apply the patch and go to Reports -> Saved reports. - Choose New report -> New SQL from Mana. A "Mana search" modal should appear. - Perform a search which will return results, e.g. "circulation." - A "Loading" indicator should appear while the results are being retrieved. It should disappear when results appear. - Results should appear in the DataTable with sorting, paging, and search options. - In the "Notes" column, notes longer than 200 characters should be truncated with a "Show more" link. Clicking it should expand the comment and reveal a "Show less" link in its place. - Click the "Import" button (previously "Use"). The button icon should change to a loading indicator. - When the import is complete you should be redirected to a view of your new report. Go to Serials and click the "Search on Mana" link in the sidebar. - Perform a search for a serial - Results should appear in a DataTable with sorting, paging, and search options. - Sorting by title should ignore articles "a," "an," and "the." Create a new subscription or edit an existing subscription which will match a record in Mana. - On the second step of adding/editing the subscription a message should appear at the top of the form, "Searching for subscription in Mana Knowledge Base," with a loading icon. - When searching has completed a "Show Mana results" link should appear. - Clicking the link should trigger a modal showing search results which match your subscription, displayed in a DataTable with sorting, paging, and search options. - The last column of the table should contain "Import" and "Report" buttons. - Clicking the "Report" button should trigger a menu. Any existing comments will be listed as well as a "New comment" item. - Clicking an existing comment should cause the menu to close and a "Submitting comment" message to appear. It should be shortly replaced with a "Your comment has been submitted" message. - Clicking "New comment" should reveal a comment form. - It should not be possible to submit an empty comment. - Clicking the "cancel" link should redisplay the search results. - Submitting a new comment should trigger a "Submitting comment" message followed by a "Your comment has been submitted" message. - In the table of search results, click the "Import" button (previously "Use"). The button icon should change to a loading indicator. - The modal should close and the data from Mana should be loaded into the subscription entry form. View the detail page of a subscription which has saved with Mana data. - There should be a "Report mistake" button in the toolbar. Clicking it should reveal a menu of comments like the one you saw previously. - Clicking an existing comment should cause the menu to close and a "Submitting comment" message to appear. It should be shortly replaced with a "Your comment has been submitted" message. - Clicking "New comment" should reveal a comment form modal. - It should not be possible to submit an empty comment. - Clicking the "cancel" link should hide the modal. - Submitting a new comment should trigger a "Submitting comment" message followed by a "Your comment has been submitted" message. Signed-off-by: Michal Denar <black23@gmail.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>19.05.x
16 changed files with 747 additions and 574 deletions
@ -1,44 +0,0 @@ |
|||
<script> |
|||
//<![CDATA[ |
|||
$(document).ready(function() { |
|||
function mana_increment(mana_id, resource, fieldvalue, stepvalue = 1) { |
|||
$.ajax( { |
|||
type: "POST", |
|||
url: "/cgi-bin/koha/svc/mana/increment", |
|||
data: {id: mana_id, resource: resource, field: fieldvalue, step: stepvalue}, |
|||
datatype: "json", |
|||
}) |
|||
} |
|||
|
|||
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", |
|||
}) |
|||
} |
|||
|
|||
$(document).on('click', 'ul li.mana-comment', function() { |
|||
id = $(this).attr('data-id'); |
|||
mana_increment(id, 'resource_comment', 'nb'); |
|||
}); |
|||
|
|||
$(document).on('click', 'ul li.mana-other-comment', function() { |
|||
$('#mana-comment-box').modal('show'); |
|||
}); |
|||
|
|||
$(document).on('click', '#mana-send-comment', function() { |
|||
var resource_type = $('#mana-resource').val(); |
|||
var resource_id = $('#mana-resource-id').val(); |
|||
var comment = $("#mana-comment").val(); |
|||
mana_comment(resource_id, comment, resource_type); |
|||
$("#mana-comment-box").modal("hide"); |
|||
}); |
|||
|
|||
$(document).on('click', '#mana-comment-close', function() { |
|||
$("#mana-comment-box").modal("hide"); |
|||
}); |
|||
}); |
|||
//]]> |
|||
</script> |
@ -0,0 +1,10 @@ |
|||
<div id="mana_comment_progress" class="dialog message mana_comment_status" style="display:none"> |
|||
<div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Submitting comment </div> |
|||
</div> |
|||
<div id="mana_comment_success" class="dialog message mana_comment_status" style="display:none"> |
|||
Your comment has been submitted |
|||
</div> |
|||
<div id="mana_comment_failed" class="dialog alert mana_comment_status" style="display:none"> |
|||
Your comment could not be submitted. Please try again later. |
|||
<div id="mana_comment_errortext"></div> |
|||
</div> |
@ -1,82 +1,128 @@ |
|||
[% USE Asset %] |
|||
[% USE KohaDates %] |
|||
[% USE Koha %] |
|||
[% USE AuthorisedValues %] |
|||
[% USE Branches %] |
|||
[% USE raw %] |
|||
|
|||
<script> |
|||
//<![CDATA[ |
|||
$(document).ready(function() { |
|||
$(document).on('click', 'button.mana-use', function() { |
|||
id = $(this).attr('id'); |
|||
mana_use(id.substr(9)); |
|||
}); |
|||
[% INCLUDE 'doc-head-open.inc' %] |
|||
<title>Koha › Reports › Mana Knowledge Base reports search</title> |
|||
[% INCLUDE 'doc-head-close.inc' %] |
|||
[% Asset.css("css/reports.css") | $raw %] |
|||
[% Asset.css("css/datatables.css") | $raw %] |
|||
</head> |
|||
|
|||
$(document).on('change', 'select.mana-actions', function() { |
|||
report_id = $(this).attr('id').substr(13); |
|||
if ($(this).val() == 'other') { |
|||
$('input#selected_id').val(report_id); |
|||
$('#comment_box').modal('show'); |
|||
} else { |
|||
comment_id = $(this).val(); |
|||
mana_increment(comment_id, 'resource_comment', 'nb'); |
|||
} |
|||
}); |
|||
}); |
|||
//]]> |
|||
</script> |
|||
[% INCLUDE 'mana.inc' %] |
|||
<body id="rep_mana_search" class="rep"> |
|||
[% INCLUDE 'header.inc' %] |
|||
[% INCLUDE 'circ-search.inc' %] |
|||
|
|||
[% IF statuscode == "200" AND reports %] |
|||
<table id="mana_results_datatable" width=100%> |
|||
<thead> |
|||
<tr> |
|||
<th>Report Name</th> |
|||
<th class="anti-the" width=35%>Notes</th> |
|||
<th>Type</th> |
|||
<th title="number of libraries using this pattern"># of users</th> |
|||
<th class="title-string" title="last time a library used this pattern">Last import</th> |
|||
<th> Comments </th> |
|||
[% UNLESS search_only %] |
|||
<th class="NoSort">Actions</th> |
|||
[% END %] |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
[% FOREACH report IN reports %] |
|||
[% UNLESS report.cannotdisplay %] |
|||
[% IF report.nbofcomment > highWarned %] |
|||
<tr id="row[% report.id | $raw %]" class = "high-warned-row"> |
|||
[% ELSIF report.nbofcomment > warned %] |
|||
<tr id="row[% report.id | $raw %]" class = "warned-row"> |
|||
[% ELSIF report.nbofcomment > lowWarned %] |
|||
<tr id="row[% report.id | $raw %]" class = "highlighted-row"> |
|||
[% END %] |
|||
<input hidden class="rowid" value="[% report.id | $raw %]"> |
|||
<td>[% IF ( report.report_name ) %][% report.report_name | html %][% END %]</td> |
|||
<td title="[% report.savedsql | html %]"><div> |
|||
[% IF report.notes.length > 200 %] |
|||
[% report.notes.substr(0,200) | html %]<a class="showbutton">Show More</a></div><div hidden> |
|||
[% END %] |
|||
[% report.notes | html %] |
|||
[% IF report.notes.length > 200 %] |
|||
<a class="hidebutton">Show Less</a></div> </td> |
|||
[% END %] |
|||
<td> [% report.type | html %] </td> |
|||
<td>[% IF ( report.nbofusers ) %][% report.nbofusers | $raw %][% END %]</td> |
|||
<td><span title="[% report.lastimport | $KohaDates %]">[% report.lastimport | $KohaDates %]</span></td> |
|||
<td>[% FOREACH comment IN report.comments %][% comment.message | html %] ([% comment.nb | $raw %]) <br>[% END %]</td> |
|||
<div id="breadcrumbs"> |
|||
<a href="/cgi-bin/koha/mainpage.pl">Home</a> |
|||
› <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a> |
|||
› <a href="/cgi-bin/koha/reports/guided_reports.pl">Guided reports wizard</a> |
|||
› Mana Knowledge Base report search results |
|||
</div> |
|||
|
|||
<div class="main container-fluid"> |
|||
<div class="row"> |
|||
<div class="col-sm-10 col-sm-push-2"> |
|||
<main> |
|||
<h2>Mana Knowledge Base report search results</h2> |
|||
|
|||
<div id="mana_results"> |
|||
[% IF statuscode == "200" AND reports %] |
|||
|
|||
<table id="mana_results_datatable"> |
|||
<thead> |
|||
<tr> |
|||
<th>Report name</th> |
|||
<th class="anti-the">Notes</th> |
|||
<th>Type</th> |
|||
<th title="Number of libraries using this pattern"># of users</th> |
|||
<th class="title-string" title="Last time a library used this pattern">Last import</th> |
|||
<th> Comments </th> |
|||
[% UNLESS search_only %] |
|||
<th class="NoSort">Actions</th> |
|||
[% END %] |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
[% FOREACH report IN reports %] |
|||
[% UNLESS report.cannotdisplay %] |
|||
[% IF report.nbofcomment > highWarned %] |
|||
<tr id="row[% report.id | html %]" class="high-warned-row"> |
|||
[% ELSIF report.nbofcomment > warned %] |
|||
<tr id="row[% report.id | html %]" class="warned-row"> |
|||
[% ELSIF report.nbofcomment > lowWarned %] |
|||
<tr id="row[% report.id | html %]" class="highlighted-row"> |
|||
[% ELSE %] |
|||
<tr id="row[% report.id | html %]"> |
|||
[% END %] |
|||
<td> |
|||
<input type="hidden" class="rowid" value="[% report.id | $raw %]" /> |
|||
[% IF ( report.report_name ) %] |
|||
[% report.report_name | html %] |
|||
[% END %] |
|||
</td> |
|||
<td title="[% report.savedsql | html %]"> |
|||
[% IF report.notes.length > 200 %] |
|||
<div> |
|||
[% report.notes.substr(0,200) | html %]... <a href="#" class="btn btn-link btn-sm showbutton"><i class="fa fa-plus-square-o"></i> Show more</a> |
|||
</div> |
|||
<div style="display:none"> |
|||
[% report.notes | html %] |
|||
<a href="#" class="btn btn-link btn-sm hidebutton"><i class="fa fa-minus-square-o"></i> Show less</a> |
|||
</div> |
|||
[% ELSE %] |
|||
[% report.notes | html %] |
|||
[% END %] |
|||
</td> |
|||
<td> [% report.type | html %] </td> |
|||
<td> |
|||
[% IF ( report.nbofusers ) %] |
|||
[% report.nbofusers | html %] |
|||
[% END %] |
|||
</td> |
|||
<td> |
|||
<span title="[% report.lastimport | html %]"> |
|||
[% report.lastimport | $KohaDates %] |
|||
</span> |
|||
</td> |
|||
<td> |
|||
[% FOREACH comment IN report.comments %] |
|||
[% comment.message | html %] ([% comment.nb | html %])<br> |
|||
[% END %] |
|||
</td> |
|||
|
|||
[% UNLESS search_only %] |
|||
<td> |
|||
<button class="mana-use" id="mana-use-[% report.id | $raw %]"><i class="fa fa-inbox"></i> Use</button> |
|||
</td> |
|||
[% UNLESS search_only %] |
|||
<td> |
|||
<button type="button" class="btn btn-default btn-xs mana-use" id="mana-use-[% report.id | html %]" data-report_id="[% report.id | html %]"><i class="fa fa-download"></i> Import</button> |
|||
</td> |
|||
[% END %] |
|||
</tr> |
|||
[% END %] |
|||
[% END %] |
|||
</tbody> |
|||
</table> |
|||
[% ELSE %] |
|||
<h4> |
|||
[% IF ( msg ) %] |
|||
[% msg | html %] (Statuscode: [% statuscode | html %]) |
|||
[% ELSE %] |
|||
No results found |
|||
[% END %] |
|||
</h4> |
|||
[% END %] |
|||
</tr> |
|||
[% END %] |
|||
[% END %] |
|||
</tbody> |
|||
</table> |
|||
[% ELSE %] |
|||
<h4> [% msg | html %] statuscode: [% statuscode | $raw %]</h4> |
|||
[% END %] |
|||
</div> |
|||
|
|||
</main> |
|||
</div> <!-- /.col-sm-10.col-sm-push-2 --> |
|||
|
|||
<div class="col-sm-2 col-sm-pull-10"> |
|||
<aside> |
|||
[% INCLUDE 'guided-reports-view.inc' %] |
|||
</aside> |
|||
</div> <!-- /.col-sm-2.col-sm-pull-10 --> |
|||
</div> <!-- /.row --> |
|||
|
|||
[% INCLUDE 'intranet-bottom.inc' %] |
@ -0,0 +1,95 @@ |
|||
<div id="mana_share_report" class="modal" tabindex="-1" role="dialog" aria-labelledby="mana_share_modal_label"> |
|||
<div class="modal-dialog modal-wide" role="document"> |
|||
<div class="modal-content"> |
|||
<form method="post" id="mana_share_form" action="/cgi-bin/koha/reports/guided_reports.pl"> |
|||
<div class="modal-header"> |
|||
<button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> |
|||
<h3 id="mana_share_modal_label">Share with Mana</h3> |
|||
</div> |
|||
<div class="modal-body"> |
|||
[% IF (mana_id) %] |
|||
<div class="dialog alert"> |
|||
<p>Your report is already linked with a Mana report. Share it if you have made modifications, otherwise it will do nothing.</p> |
|||
</div> |
|||
[% END %] |
|||
<div id="note-error" class="dialog alert" role="alert"> |
|||
Please enter a report name and descriptive note before sharing (minimum 20 characters) |
|||
</div> |
|||
<div class="shared_infos rows"> |
|||
<ul> |
|||
<li><span class="label">Id: </span><div id="shared_id"></div></li> |
|||
<li><span class="label">Name: </span><div id="shared_name"></div></li> |
|||
<li><span class="label">SQL: </span><div id="shared_sql"></div></li> |
|||
<li><span class="label">Group: </span><div id="shared_group"></div></li> |
|||
<li><span class="label">Type: </span><div id="shared_type"></div></li> |
|||
<li><span class="label">Notes: </span><div id="shared_notes"></div></li> |
|||
[% IF (languages_loop) %] |
|||
<li> |
|||
<input type="hidden" name="phase" value="Share"> |
|||
<label for="mana_language">Language:</label> |
|||
<select id="mana_language" name="mana_language"> |
|||
[% FOREACH languages_loo IN languages_loop %] |
|||
[% IF ( languages_loo.group_enabled ) %] |
|||
[% IF ( languages_loo.plural ) %] |
|||
[% FOREACH sublanguages_loo IN languages_loo.sublanguages_loop %] |
|||
[% IF ( sublanguages_loo.enabled ) %] |
|||
[% IF ( sublanguages_loo.sublanguage_current ) %] |
|||
<option value="[% languages_loo.rfc4646_subtag | html %]" selected="selected"> |
|||
[% sublanguages_loo.native_description | html %] |
|||
[% sublanguages_loo.script_description | html %] |
|||
[% sublanguages_loo.region_description | html %] |
|||
|
|||
[% sublanguages_loo.variant_description | html %] |
|||
([% sublanguages_loo.rfc4646_subtag | html %]) |
|||
</option> |
|||
[% ELSE %] |
|||
<option value="[% languages_loo.rfc4646_subtag | html %]"> |
|||
[% sublanguages_loo.native_description | html %] |
|||
[% sublanguages_loo.script_description | html %] |
|||
[% sublanguages_loo.region_description | html %] |
|||
[% sublanguages_loo.variant_description | html %] |
|||
([% sublanguages_loo.rfc4646_subtag | html %]) |
|||
</option> |
|||
[% END %] |
|||
[% END %] |
|||
[% END %] |
|||
[% ELSE %] |
|||
[% IF ( languages_loo.group_enabled ) %] |
|||
[% IF ( languages_loo.current ) %] |
|||
<option value="[% languages_loo.rfc4646_subtag | html %]" selected="selected"> |
|||
[% IF ( languages_loo.native_description ) %] |
|||
[% languages_loo.native_description | html %] |
|||
[% ELSE %] |
|||
[% languages_loo.rfc4646_subtag | html %] |
|||
[% END %] |
|||
</option> |
|||
[% ELSE %] |
|||
<option value="[% languages_loo.rfc4646_subtag | html %]"> |
|||
[% IF ( languages_loo.native_description ) %] |
|||
[% languages_loo.native_description | html %] |
|||
[% ELSE %] |
|||
[% languages_loo.rfc4646_subtag | html %] |
|||
[% END %] |
|||
</option> |
|||
[% END %] |
|||
[% END %] |
|||
[% END %] |
|||
[% END %] |
|||
[% END %] |
|||
</select> |
|||
</li> |
|||
[% ELSE %] |
|||
<input type="hidden" name="mana_language" value="[% lang | html %]" /> |
|||
[% END %] |
|||
</ul> |
|||
</div> <!-- /.shared_infos rows --> |
|||
</div> <!-- /.modal-body --> |
|||
<div class="modal-footer"> |
|||
<input type="hidden" id="reportid" name="reportid"/> |
|||
<button id="ManaShareButton" type="submit" class="btn btn-default shared_infos">Share</button> |
|||
<button class="btn btn-default" id="ManaCloseButton" data-dismiss="modal" aria-hidden="true">Cancel</button> |
|||
</div> |
|||
</form> <!-- /#mana_share_form --> |
|||
</div> <!-- /.modal-content --> |
|||
</div> <!-- /.modal-dialog --> |
|||
</div> <!-- /#mana_share_report --> |
@ -1 +1 @@ |
|||
[% INCLUDE 'mana/mana-report-search-result.inc' %] |
|||
[% INCLUDE 'mana/mana-report-search-result.inc' %] |
@ -1 +1 @@ |
|||
[% INCLUDE 'mana/mana-subscription-search-result.inc' %] |
|||
[% INCLUDE 'mana/mana-subscription-search-result.inc' %] |
@ -0,0 +1,83 @@ |
|||
/* global mana_comment_close */ |
|||
|
|||
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(); |
|||
}) |
|||
.fail(function( error ) { |
|||
$(".mana_comment_status").hide(); |
|||
$("#mana_comment_errortext").html( error.status + " " + error.statusText ); |
|||
$("#mana_comment_failed").show(); |
|||
}) |
|||
.always(function() { |
|||
mana_comment_close(); |
|||
}); |
|||
} |
|||
|
|||
function mana_comment( target_id, manamsg, resource_type ) { |
|||
$("#mana_comment_progress").show(); |
|||
$.ajax( { |
|||
type: "POST", |
|||
url: "/cgi-bin/koha/svc/mana/share", |
|||
data: { message: manamsg, resource: resource_type, resource_id: target_id }, |
|||
datatype: "json", |
|||
}) |
|||
.done(function() { |
|||
$(".mana_comment_status").hide(); |
|||
$("#mana_comment_success").show(); |
|||
}) |
|||
.fail(function( error ) { |
|||
$(".mana_comment_status").hide(); |
|||
$("#mana_comment_errortext").html( error.status + " " + error.statusText ); |
|||
$("#mana_comment_failed").show(); |
|||
}) |
|||
.always(function() { |
|||
$("#selected_id").val(""); |
|||
$("#mana-resource-id").val(""); |
|||
$("#mana-comment").val(""); |
|||
mana_comment_close(); |
|||
}); |
|||
} |
|||
|
|||
$(document).ready(function() { |
|||
|
|||
$("body").on("submit", "#mana_comment_form", function( e ) { |
|||
e.preventDefault(); |
|||
var resource_type = $('#mana-resource').val(); |
|||
var resource_id = $('#mana-resource-id').val(); |
|||
var comment = $("#mana-comment").val(); |
|||
mana_comment(resource_id, comment, resource_type); |
|||
}); |
|||
|
|||
$("body").on("click", '#mana-comment-close', function( e ) { |
|||
e.preventDefault(); |
|||
mana_comment_close(); |
|||
}); |
|||
|
|||
$("body").on("click", ".mana-actions a", function( e ) { |
|||
e.preventDefault(); |
|||
$(".mana_comment_status").hide(); |
|||
var commentid = $(this).data("commentid"); |
|||
var resourceid = $(this).data("resourceid"); |
|||
$("#mana-resource-id").val( resourceid ); |
|||
if ( commentid == "other") { |
|||
if( $("#new_mana_comment").length ){ |
|||
$("#selected_id").val( commentid ); |
|||
$("#mana_results, #new_mana_comment").toggle(); |
|||
} else { |
|||
$("#mana-comment-box").modal("show"); |
|||
} |
|||
} else { |
|||
mana_increment( commentid, "resource_comment", "nb"); |
|||
} |
|||
}); |
|||
}); |