Bug 5471 - Quotes in tags fail
This patch makes changes to the tag moderation template and JavaScript
to fix handling of tags with double or single quotes. This patch also
moves the tags moderation JavaScript out of the template and into a
separate JS file.
To test you should have multiple tags awaiting moderation, including
tags which contain double and single quotes.
- Go to Tools -> Tags.
- In the list of tags pending approval, test approving and rejecting
tags, including those containing single or double quotes.
- The state of the "Approve" or "Reject" buttons should correctly
change according to the action you chose.
- The label in the status column should update correctly.
- In the "Check lists" form, submitting approved, rejected, and
unclassified terms should result in the correct message.
Signed-off-by: Lee Jamison <ldjamison@marywood.edu>
Works correctly based on test plan. Tested using single- and
double-quoted tags. Passes QA Tools.
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit ee6f8e186b)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
7f06120527
commit
9dcaeba3e0
|
|
@ -6,6 +6,23 @@
|
|||
[% INCLUDE 'datatables.inc' %]
|
||||
[% INCLUDE 'calendar.inc' %]
|
||||
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
|
||||
<script type="text/javascript" src="[% interface %]/[% theme %]/js/pages/tags-review.js"></script>
|
||||
<script type="text/javascript">
|
||||
var MSG_AJAX_APPROVE_FAILED = _("AJAX failed to approve tag: %s");
|
||||
var MSG_AJAX_REJECTION_FAILED = _("AJAX failed to reject tag: %s");
|
||||
var MSG_AJAX_TAG_PERMITTED = _("%s is permitted!");
|
||||
var MSG_AJAX_TAG_PROHIBITED = _("%s is prohibited!");
|
||||
var MSG_AJAX_TAG_UNCLASSIFIED = _("%s is neither permitted nor prohibited!");
|
||||
var MSG_AJAX_ERROR = _("AJAX error (%s alert)");
|
||||
var LABEL_SELECT_ALL = _("Select all");
|
||||
var LABEL_CLEAR_ALL = _("Clear all");
|
||||
var LABEL_SELECT_ALL_PENDING = _("Select all pending");
|
||||
var LABEL_APPROVE = _("Approve");
|
||||
var LABEL_APPROVED = _("Approved");
|
||||
var LABEL_REJECT = _("Reject");
|
||||
var LABEL_REJECTED = _("Rejected");
|
||||
var LABEL_TESTING = _("Testing...");
|
||||
</script>
|
||||
<style type="text/css">
|
||||
.setlabel {width: 6em; font-family: courier; background-color:#E8E8E8;}
|
||||
.rejected { color: #CC0033; }
|
||||
|
|
@ -13,169 +30,6 @@
|
|||
.pending { color: #CCC; font-style: italic; }
|
||||
tr > td input,td input[type="submit"] { font-size: 85%; padding: 1px; }
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
// [% script_name %]
|
||||
$.ajaxSetup({
|
||||
url: "/cgi-bin/koha/tags/review.pl",
|
||||
type: "POST",
|
||||
dataType: "script"
|
||||
});
|
||||
var ok_count = 0;
|
||||
var nok_count = 0;
|
||||
var rej_count = 0;
|
||||
var alerted = 0;
|
||||
function pull_counts () {
|
||||
ok_count = parseInt(document.getElementById("terms_summary_approved_count" ).innerHTML);
|
||||
nok_count = parseInt(document.getElementById("terms_summary_unapproved_count").innerHTML);
|
||||
rej_count = parseInt(document.getElementById("terms_summary_rejected_count" ).innerHTML);
|
||||
}
|
||||
function count_approve () {
|
||||
pull_counts();
|
||||
if (nok_count > 0) {
|
||||
$("#terms_summary_unapproved_count").html(nok_count -1);
|
||||
$("#terms_summary_approved_count" ).html( ok_count +1);
|
||||
}
|
||||
}
|
||||
function count_reject () {
|
||||
pull_counts();
|
||||
if (nok_count > 0) {
|
||||
$("#terms_summary_unapproved_count").html(nok_count -1);
|
||||
$("#terms_summary_rejected_count" ).html(rej_count +1);
|
||||
}
|
||||
}
|
||||
function warn_once (evt) {
|
||||
if (alerted <= 1 && ($(evt.target).is('.ok') || $(evt.target).is('.rej'))) {
|
||||
alerted += 1;
|
||||
window.alert("this is: " + this + "is '.ok': " + $(evt.target).is('.ok') + " is '.rej': " + $(evt.target).is('.rej'));
|
||||
}
|
||||
}
|
||||
var success_approve = function(tag){
|
||||
// window.alert(_("AJAX approved tag: ") + tag);
|
||||
};
|
||||
var failure_approve = function(tag){
|
||||
window.alert(_("AJAX failed to approve tag: %s").format(tag));
|
||||
};
|
||||
var success_reject = function(tag){
|
||||
// window.alert(_("AJAX rejected tag: ") + tag);
|
||||
};
|
||||
var failure_reject = function(tag){
|
||||
window.alert(_("AJAX failed to reject tag: %s").format(tag));
|
||||
};
|
||||
var success_test = function(tag){
|
||||
$('#verdict').html(_("%s is permitted!").format(tag));
|
||||
};
|
||||
var failure_test = function(tag){
|
||||
$('#verdict').html(_("%s is prohibited!").format(tag));
|
||||
};
|
||||
var indeterminate_test = function(tag){
|
||||
$('#verdict').html(_("%s is neither permitted nor prohibited!").format(tag));
|
||||
};
|
||||
|
||||
var success_test_call = function() {
|
||||
$('#test_button').prop('disabled', false);
|
||||
$('#test_button').html("<i class='fa fa-check-square-o' aria-hidden='true'></i>" +_(" Test"));
|
||||
};
|
||||
$(document).ready(function() {
|
||||
$('.ajax_buttons' ).css({visibility:"visible"});
|
||||
$("p.check").html("<div id=\"searchheader\"><a id=\"CheckAll\" href=\"/cgi-bin/koha/tags/review.pl\"><i class=\"fa fa-check\"><\/i>"+_(" Select all")+"<\/a> | <a id=\"CheckNone\" href=\"/cgi-bin/koha/tags/review.pl\"><i class=\"fa fa-remove\"><\/i>"+_(" Clear all")+"<\/a> | <a id=\"CheckPending\" href=\"/cgi-bin/koha/tags/review.pl\"> "+_("Select all pending")+"<\/a><\/div>");
|
||||
$("#CheckAll").click(function(){
|
||||
$(".checkboxed").checkCheckboxes();
|
||||
return false;
|
||||
});
|
||||
$("#CheckNone").click(function(){
|
||||
$(".checkboxed").unCheckCheckboxes();
|
||||
return false;
|
||||
});
|
||||
$("#CheckPending").click(function(){
|
||||
$(".checkboxed").checkCheckboxes(".pending");
|
||||
return false;
|
||||
});
|
||||
$('body').click(function(event) {
|
||||
pull_counts();
|
||||
// window.alert(_("Click detected on ") + event.target + ": " + $(event.target).html);
|
||||
if ($(event.target).is('.ok')) {
|
||||
$.ajax({
|
||||
data: {ok: $(event.target).attr("title")},
|
||||
success: count_approve // success_approve
|
||||
});
|
||||
$(event.target).next(".rej").prop('disabled', false).css("color","#000");
|
||||
$(event.target).next(".rej").html("<i class='fa fa-remove'></i>" + _(" Reject"));
|
||||
$(event.target).prop('disabled', true).css("color","#666");
|
||||
$(event.target).html("<i class='fa fa-check'></i>" + _(" Approved"));
|
||||
var getelement = $(event.target).attr("title");
|
||||
var gettitle = "span[data-title|=" + getelement + "]";
|
||||
$(gettitle).text(_("Approved"));
|
||||
if ($(gettitle).attr("class") == "pending"){
|
||||
$(gettitle).toggleClass("pending approved");
|
||||
} else {
|
||||
$(gettitle).toggleClass("rejected approved");
|
||||
}
|
||||
return false; // cancel submit
|
||||
}
|
||||
if ($(event.target).is('.rej')) {
|
||||
$.ajax({
|
||||
data: {rej: $(event.target).attr("title")},
|
||||
success: count_reject // success_reject
|
||||
});
|
||||
$(event.target).prev(".ok").prop('disabled', false).css("color","#000");
|
||||
$(event.target).prev(".ok").html("<i class='fa fa-check'></i>" + _(" Approve"));
|
||||
$(event.target).prop('disabled', true).css("color","#666");
|
||||
$(event.target).html("<i class='fa fa-remove'></i>" + _(" Rejected"));
|
||||
var getelement = $(event.target).attr("title");
|
||||
var gettitle = "span[data-title|=" + getelement + "]";
|
||||
$(gettitle).text(_("Rejected"));
|
||||
if ($(gettitle).attr("class") == "pending"){
|
||||
$(gettitle).toggleClass("pending rejected");
|
||||
} else {
|
||||
$(gettitle).toggleClass("approved rejected");
|
||||
}
|
||||
return false; // cancel submit
|
||||
}
|
||||
if ($(event.target).is('#test_button')) {
|
||||
$(event.target).text(_("Testing...")).prop('disabled', true);
|
||||
$.ajax({
|
||||
data: {test: $('#test').attr("value")},
|
||||
success: success_test_call // success_reject
|
||||
});
|
||||
return false; // cancel submit
|
||||
}
|
||||
});
|
||||
$("*").ajaxError(function(evt, request, settings){
|
||||
if ((alerted +=1) <= 1){ window.alert(_("AJAX error (%s alert)").format(alerted)); }
|
||||
});
|
||||
$("#tagst").dataTable($.extend(true, {}, dataTablesDefaults, {
|
||||
"aoColumnDefs": [
|
||||
[% IF ( filter_approved_pending ) %]
|
||||
{ "aTargets": [ 0,1,-2 ], "bSortable": false, "bSearchable": false }
|
||||
[% ELSE %]
|
||||
{ "aTargets": [ 0,1,-3 ], "bSortable": false, "bSearchable": false }
|
||||
[% END %]
|
||||
],
|
||||
"aoColumns": [
|
||||
null,null,null,null,null,null,[% UNLESS ( filter_approved_pending ) %]null,[% END %]{ "sType": "title-string" }
|
||||
],
|
||||
"aaSorting": [[ 4, "desc" ]],
|
||||
"sPaginationType": "four_button"
|
||||
}));
|
||||
var reviewerField = $("#approver");
|
||||
reviewerField.autocomplete({
|
||||
source: "/cgi-bin/koha/circ/ysearch.pl",
|
||||
minLength: 3,
|
||||
select: function( event, ui ) {
|
||||
reviewerField.val( ui.item.borrowernumber );
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.data( "ui-autocomplete" )._renderItem = function( ul, item ) {
|
||||
return $( "<li></li>" )
|
||||
.data( "ui-autocomplete-item", item )
|
||||
.append( "<a>" + item.surname + ", " + item.firstname + " (" + item.cardnumber + ") <small>" + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "</small></a>" )
|
||||
.appendTo( ul );
|
||||
};
|
||||
});
|
||||
//]]>
|
||||
</script>
|
||||
</head>
|
||||
<body id="tags_review" class="tools">
|
||||
[% INCLUDE 'header.inc' %]
|
||||
|
|
@ -239,14 +93,14 @@ tr > td input,td input[type="submit"] { font-size: 85%; padding: 1px; }
|
|||
<table id="tagst">
|
||||
<thead>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
<th class="NoSort"> </th>
|
||||
<th class="NoSort"> </th>
|
||||
<th>Status</th>
|
||||
<th>Term</th>
|
||||
<th>Weight</th>
|
||||
<th>Actions</th>
|
||||
<th class="NoSort">Actions</th>
|
||||
[% UNLESS ( filter_approved_pending ) %]<th>Reviewer</th>[% END %]
|
||||
<th>Date</th>
|
||||
<th class="title-string">Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
|
@ -254,30 +108,30 @@ tr > td input,td input[type="submit"] { font-size: 85%; padding: 1px; }
|
|||
<tr>
|
||||
<td class="count">[% offset + loop.count %]
|
||||
</td>
|
||||
[% IF ( tagloo.approved == 0 ) %]<td><span><input type="checkbox" value="[% tagloo.term %]" name="tags" class="pending" /></span>
|
||||
[% ELSE %]<td><span><input type="checkbox" value="[% tagloo.term %]" name="tags" /></span>[% END %]
|
||||
[% IF ( tagloo.approved == 0 ) %]<td><span><input type="checkbox" value="[% tagloo.term|html %]" name="tags" class="pending" /></span>
|
||||
[% ELSE %]<td><span><input type="checkbox" value="[% tagloo.term|html %]" name="tags" /></span>[% END %]
|
||||
</td>
|
||||
<td>
|
||||
[% IF ( tagloo.approved == -1 ) %]
|
||||
<span class="rejected" data-title="[% tagloo.term %]">Rejected</span>
|
||||
<span class="rejected status[% offset + loop.count %]">Rejected</span>
|
||||
[% ELSIF ( tagloo.approved == 1 ) %]
|
||||
<span class="approved" data-title="[% tagloo.term %]">Approved</span>
|
||||
<span class="approved status[% offset + loop.count %]">Approved</span>
|
||||
[% ELSE %]
|
||||
<span class="pending" data-title="[% tagloo.term %]">Pending</span>
|
||||
<span class="pending status[% offset + loop.count %]">Pending</span>
|
||||
[% END %]
|
||||
</td>
|
||||
<td><a href="/cgi-bin/koha/tags/list.pl?tag=[% tagloo.term|uri %]">[% tagloo.term %]</a>
|
||||
<td><a href="/cgi-bin/koha/tags/list.pl?tag=[% tagloo.term|uri %]">[% tagloo.term|html %]</a>
|
||||
</td>
|
||||
<td>[% tagloo.weight_total %]
|
||||
</td>
|
||||
[% IF ( tagloo.approved ) %]
|
||||
<td class="actions"><span class="ajax_buttons" style="visibility:hidden">
|
||||
[% IF ( tagloo.approved == -1 ) %]
|
||||
<button class="ok btn btn-default btn-xs" type="submit" title="[% tagloo.term %]" value="Approve" name="approve"><i class="fa fa-check"></i> Approve</button>
|
||||
<button class="rej btn btn-default btn-xs" disabled="disabled" type="submit" title="[% tagloo.term %]" value="Rejected" name="reject"><i class="fa fa-remove"></i> Rejected</button>
|
||||
[% IF ( tagloo.approved == -1 ) %]
|
||||
<button data-num="[% offset + loop.count %]" class="approval_btn ok btn btn-default btn-xs" type="submit" title="[% tagloo.term|html %]" value="Approve" name="approve"><i class="fa fa-check"></i> Approve</button>
|
||||
<button data-num="[% offset + loop.count %]" class="approval_btn rej btn btn-default btn-xs" disabled="disabled" type="submit" title="[% tagloo.term|html %]" value="Rejected" name="reject"><i class="fa fa-remove"></i> Rejected</button>
|
||||
[% ELSE %]
|
||||
<button class="ok btn btn-default btn-xs" disabled="disabled" type="submit" title="[% tagloo.term %]" value="Approved" name="approve"><i class="fa fa-check"></i> Approved</button>
|
||||
<button class="rej btn btn-default btn-xs" type="submit" title="[% tagloo.term %]" value="Reject" name="reject"><i class="fa fa-remove"></i> Reject</button>
|
||||
<button data-num="[% offset + loop.count %]" class="approval_btn ok btn btn-default btn-xs" disabled="disabled" type="submit" title="[% tagloo.term|html %]" value="Approved" name="approve"><i class="fa fa-check"></i> Approved</button>
|
||||
<button data-num="[% offset + loop.count %]" class="approval_btn rej btn btn-default btn-xs" type="submit" title="[% tagloo.term|html %]" value="Reject" name="reject"><i class="fa fa-remove"></i> Reject</button>
|
||||
[% END %]
|
||||
</span>
|
||||
</td>
|
||||
|
|
@ -285,8 +139,8 @@ tr > td input,td input[type="submit"] { font-size: 85%; padding: 1px; }
|
|||
</td>
|
||||
[% ELSE %]
|
||||
<td class="actions"><span class="ajax_buttons" style="visibility:hidden">
|
||||
<button class="ok btn btn-default btn-xs" type="submit" title="[% tagloo.term %]" value="Approve" name="approve"><i class="fa fa-check"></i> Approve</button>
|
||||
<button class="rej btn btn-default btn-xs" type="submit" title="[% tagloo.term %]" value="Reject" name="reject"><i class="fa fa-remove"></i> Reject</button>
|
||||
<button data-num="[% offset + loop.count %]" class="approval_btn ok btn btn-default btn-xs" type="submit" title="[% tagloo.term|html %]" value="Approve" name="approve"><i class="fa fa-check"></i> Approve</button>
|
||||
<button data-num="[% offset + loop.count %]" class="approval_btn rej btn btn-default btn-xs" type="submit" title="[% tagloo.term|html %]" value="Reject" name="reject"><i class="fa fa-remove"></i> Reject</button>
|
||||
</span>
|
||||
</td>
|
||||
[% UNLESS ( filter_approved_pending ) %]<td> </td>[% END %]
|
||||
|
|
@ -329,7 +183,7 @@ tr > td input,td input[type="submit"] { font-size: 85%; padding: 1px; }
|
|||
<div class="description">Enter a word or phrase to check against approved/rejected lists: </div>
|
||||
<form method="post" action="/cgi-bin/koha/tags/review.pl">
|
||||
<input type="text" size="14" name="test" id="test" />
|
||||
<fieldset class="action"><button type="submit" value="Test" class="btn btn-default btn-sm" id="test_button" name="op-test"><i class="fa fa-check-square-o" aria-hidden="true"></i> Test</button></fieldset>
|
||||
<fieldset class="action"><button type="submit" value="Test" class="approval_btn btn btn-default btn-sm" id="test_button" name="op-test"><i class="fa fa-check-square-o" aria-hidden="true"></i> Test</button></fieldset>
|
||||
<div id="verdict">
|
||||
[% IF ( test_term ) %]
|
||||
[% IF ( verdict_ok ) %]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,162 @@
|
|||
$.ajaxSetup({
|
||||
url: "/cgi-bin/koha/tags/review.pl",
|
||||
type: "POST",
|
||||
dataType: "script"
|
||||
});
|
||||
|
||||
var ok_count = 0;
|
||||
var nok_count = 0;
|
||||
var rej_count = 0;
|
||||
var alerted = 0;
|
||||
|
||||
function pull_counts () {
|
||||
ok_count = parseInt(document.getElementById("terms_summary_approved_count" ).innerHTML);
|
||||
nok_count = parseInt(document.getElementById("terms_summary_unapproved_count").innerHTML);
|
||||
rej_count = parseInt(document.getElementById("terms_summary_rejected_count" ).innerHTML);
|
||||
}
|
||||
|
||||
function count_approve () {
|
||||
pull_counts();
|
||||
if (nok_count > 0) {
|
||||
$("#terms_summary_unapproved_count").html(nok_count -1);
|
||||
$("#terms_summary_approved_count" ).html( ok_count +1);
|
||||
}
|
||||
}
|
||||
|
||||
function count_reject () {
|
||||
pull_counts();
|
||||
if (nok_count > 0) {
|
||||
$("#terms_summary_unapproved_count").html(nok_count -1);
|
||||
$("#terms_summary_rejected_count" ).html(rej_count +1);
|
||||
}
|
||||
}
|
||||
|
||||
var success_approve = function(tag){
|
||||
// window.alert(_("AJAX approved tag: ") + tag);
|
||||
};
|
||||
var failure_approve = function(tag){
|
||||
window.alert(MSG_AJAX_APPROVE_FAILED.format(decodeURIComponent( tag )));
|
||||
};
|
||||
var success_reject = function(tag){
|
||||
// window.alert(_("AJAX rejected tag: ") + tag);
|
||||
};
|
||||
var failure_reject = function(tag){
|
||||
window.alert(MSG_AJAX_REJECTION_FAILED.format(decodeURIComponent( tag )));
|
||||
};
|
||||
var success_test = function(tag){
|
||||
$('#verdict').html(MSG_AJAX_TAG_PERMITTED.format( decodeURIComponent( tag ) ));
|
||||
};
|
||||
var failure_test = function(tag){
|
||||
$('#verdict').html(MSG_AJAX_TAG_PROHIBITED.format( decodeURIComponent( tag ) ));
|
||||
};
|
||||
var indeterminate_test = function(tag){
|
||||
$('#verdict').html(MSG_AJAX_TAG_UNCLASSIFIED.format( decodeURIComponent( tag ) ));
|
||||
};
|
||||
|
||||
var success_test_call = function() {
|
||||
$('#test_button').prop('disabled', false);
|
||||
$('#test_button').html("<i class='fa fa-check-square-o' aria-hidden='true'></i>" +_(" Test"));
|
||||
};
|
||||
|
||||
$(document).ready(function() {
|
||||
$("#tagst").dataTable($.extend(true, {}, dataTablesDefaults, {
|
||||
"aoColumnDefs": [
|
||||
{ "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
|
||||
{ "sType": "anti-the", "aTargets" : [ "anti-the" ] },
|
||||
{ "sType": "title-string", "aTargets" : [ "title-string" ] }
|
||||
],
|
||||
"aaSorting": [[ 4, "desc" ]],
|
||||
"sPaginationType": "four_button"
|
||||
}));
|
||||
$('.ajax_buttons' ).css({visibility:"visible"});
|
||||
$("p.check").html("<div id=\"searchheader\"><a id=\"CheckAll\" href=\"/cgi-bin/koha/tags/review.pl\"><i class=\"fa fa-check\"><\/i> "+ LABEL_SELECT_ALL +"<\/a> | <a id=\"CheckNone\" href=\"/cgi-bin/koha/tags/review.pl\"><i class=\"fa fa-remove\"><\/i> "+ LABEL_CLEAR_ALL +"<\/a> | <a id=\"CheckPending\" href=\"/cgi-bin/koha/tags/review.pl\"> "+ LABEL_SELECT_ALL_PENDING +"<\/a><\/div>");
|
||||
$("#CheckAll").click(function(){
|
||||
$(".checkboxed").checkCheckboxes();
|
||||
return false;
|
||||
});
|
||||
$("#CheckNone").click(function(){
|
||||
$(".checkboxed").unCheckCheckboxes();
|
||||
return false;
|
||||
});
|
||||
$("#CheckPending").click(function(){
|
||||
$(".checkboxed").checkCheckboxes(".pending");
|
||||
return false;
|
||||
});
|
||||
$(".approval_btn").on('click',function(event) {
|
||||
event.preventDefault();
|
||||
pull_counts();
|
||||
var getelement;
|
||||
var gettitle;
|
||||
// window.alert(_("Click detected on ") + event.target + ": " + $(event.target).html);
|
||||
if ($(event.target).is('.ok')) {
|
||||
$.ajax({
|
||||
data: {
|
||||
ok: $(event.target).attr("title")
|
||||
},
|
||||
success: count_approve // success_approve
|
||||
});
|
||||
$(event.target).next(".rej").prop('disabled', false).css("color","#000");
|
||||
$(event.target).next(".rej").html("<i class='fa fa-remove'></i> " + _("Reject"));
|
||||
$(event.target).prop('disabled', true).css("color","#666");
|
||||
$(event.target).html("<i class='fa fa-check'></i> " + LABEL_APPROVED );
|
||||
getelement = $(event.target).data("num");
|
||||
gettitle = ".status" + getelement;
|
||||
$(gettitle).text( LABEL_APPROVED );
|
||||
if ($(gettitle).hasClass("pending") ){
|
||||
$(gettitle).toggleClass("pending approved");
|
||||
} else {
|
||||
$(gettitle).toggleClass("rejected approved");
|
||||
}
|
||||
}
|
||||
if ($(event.target).is('.rej')) {
|
||||
$.ajax({
|
||||
data: {
|
||||
rej: $(event.target).attr("title")
|
||||
},
|
||||
success: count_reject // success_reject
|
||||
});
|
||||
$(event.target).prev(".ok").prop('disabled', false).css("color","#000");
|
||||
$(event.target).prev(".ok").html("<i class='fa fa-check'></i> " + LABEL_APPROVE );
|
||||
$(event.target).prop('disabled', true).css("color","#666");
|
||||
$(event.target).html("<i class='fa fa-remove'></i> " + LABEL_REJECTED );
|
||||
getelement = $(event.target).data("num");
|
||||
gettitle = ".status" + getelement;
|
||||
$(gettitle).text( LABEL_REJECTED );
|
||||
if ($(gettitle).hasClass("pending") ){
|
||||
$(gettitle).toggleClass("pending rejected");
|
||||
} else {
|
||||
$(gettitle).toggleClass("approved rejected");
|
||||
}
|
||||
return false; // cancel submit
|
||||
}
|
||||
if ($(event.target).is('#test_button')) {
|
||||
$(event.target).text( LABEL_TESTING ).prop('disabled', true);
|
||||
$.ajax({
|
||||
data: {
|
||||
test: $('#test').attr("value")
|
||||
},
|
||||
success: success_test_call // success_reject
|
||||
});
|
||||
return false; // cancel submit
|
||||
}
|
||||
});
|
||||
$("*").ajaxError(function(evt, request, settings){
|
||||
if ((alerted +=1) <= 1){ window.alert(MSG_AJAX_ERROR.format(alerted)); }
|
||||
});
|
||||
|
||||
var reviewerField = $("#approver");
|
||||
reviewerField.autocomplete({
|
||||
source: "/cgi-bin/koha/circ/ysearch.pl",
|
||||
minLength: 3,
|
||||
select: function( event, ui ) {
|
||||
reviewerField.val( ui.item.borrowernumber );
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.data( "ui-autocomplete" )._renderItem = function( ul, item ) {
|
||||
return $( "<li></li>" )
|
||||
.data( "ui-autocomplete-item", item )
|
||||
.append( "<a>" + item.surname + ", " + item.firstname + " (" + item.cardnumber + ") <small>" + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "</small></a>" )
|
||||
.appendTo( ul );
|
||||
};
|
||||
});
|
||||
|
|
@ -25,7 +25,7 @@ use Data::Dumper;
|
|||
use POSIX;
|
||||
use CGI qw ( -utf8 );
|
||||
use CGI::Cookie; # need to check cookies before having CGI parse the POST request
|
||||
|
||||
use URI::Escape;
|
||||
use C4::Auth qw(:DEFAULT check_cookie_auth);
|
||||
use C4::Context;
|
||||
use Koha::DateUtils;
|
||||
|
|
@ -63,14 +63,13 @@ if (is_ajax()) {
|
|||
my ($tag, $js_reply);
|
||||
if ($tag = $input->param('test')) {
|
||||
my $check = is_approved($tag);
|
||||
$js_reply = ( $check >= 1 ? 'success' :
|
||||
$check <= -1 ? 'failure' : 'indeterminate' ) . "_test('$tag');\n";
|
||||
$js_reply = ( $check >= 1 ? 'success' : $check <= -1 ? 'failure' : 'indeterminate' ) . "_test('".uri_escape($tag)."');\n";
|
||||
}
|
||||
if ($tag = $input->param('ok')) {
|
||||
$js_reply = ( whitelist($operator,$tag) ? 'success' : 'failure') . "_approve('$tag');\n";
|
||||
$js_reply = ( whitelist($operator,$tag) ? 'success' : 'failure') . "_approve('".uri_escape($tag)."');\n";
|
||||
}
|
||||
if ($tag = $input->param('rej')) {
|
||||
$js_reply = ( blacklist($operator,$tag) ? 'success' : 'failure') . "_reject('$tag');\n";
|
||||
$js_reply = ( blacklist($operator,$tag) ? 'success' : 'failure') . "_reject('".uri_escape($tag)."');\n";
|
||||
}
|
||||
output_with_http_headers $input, undef, $js_reply, 'js';
|
||||
exit;
|
||||
|
|
|
|||
Loading…
Reference in New Issue