|
Lines 467-493
Link Here
|
| 467 |
}); |
467 |
}); |
| 468 |
</script> |
468 |
</script> |
| 469 |
<script> |
469 |
<script> |
| 470 |
$(document).ready(function() { |
470 |
$(document).ready(function () { |
| 471 |
$("#staged-record-matching-rules select").change(function() { |
471 |
$("#staged-record-matching-rules select").change(function () { |
| 472 |
var str = $(this).attr("id"); |
472 |
var str = $(this).attr("id"); |
| 473 |
$("#reset_" + str).parent().show(); |
473 |
$("#reset_" + str) |
|
|
474 |
.parent() |
| 475 |
.show(); |
| 474 |
}); |
476 |
}); |
| 475 |
$("a.reset").click(function() { |
477 |
$("a.reset").click(function () { |
| 476 |
var str = $(this).attr("id"); |
478 |
var str = $(this).attr("id"); |
| 477 |
str = str.replace("reset_", "") |
479 |
str = str.replace("reset_", ""); |
| 478 |
$("#" + str + " option[selected='selected']").attr("selected", "selected"); |
480 |
$("#" + str + " option[selected='selected']").attr("selected", "selected"); |
| 479 |
$(this).parent().hide(); |
481 |
$(this).parent().hide(); |
| 480 |
}); |
482 |
}); |
| 481 |
|
483 |
|
| 482 |
if (import_batch_id){ |
484 |
if (import_batch_id) { |
| 483 |
$("#records-table").kohaTable({ |
485 |
$("#records-table").kohaTable({ |
| 484 |
autoWidth: false, |
486 |
autoWidth: false, |
| 485 |
searching: false, |
487 |
searching: false, |
| 486 |
processing: true, |
488 |
processing: true, |
| 487 |
serverSide: true, |
489 |
serverSide: true, |
| 488 |
ajax: { |
490 |
ajax: { |
| 489 |
url: "batch_records_ajax.pl", |
491 |
url: "batch_records_ajax.pl", |
| 490 |
data: function ( d ) { |
492 |
data: function (d) { |
| 491 |
d.import_batch_id = import_batch_id; |
493 |
d.import_batch_id = import_batch_id; |
| 492 |
return d; |
494 |
return d; |
| 493 |
}, |
495 |
}, |
|
Lines 495-592
Link Here
|
| 495 |
bKohaAjaxSVC: true, |
497 |
bKohaAjaxSVC: true, |
| 496 |
pagingType: "full_numbers", |
498 |
pagingType: "full_numbers", |
| 497 |
dom: '<"top pager"iflp>rt<"bottom pager"flp><"clear">', |
499 |
dom: '<"top pager"iflp>rt<"bottom pager"flp><"clear">', |
| 498 |
columns: [ |
500 |
columns: [{ data: "import_record_id" }, { data: "citation" }, { data: "status" }, { data: "overlay_status" }, { data: null, defaultContent: "" }, { data: null, defaultContent: "" }, { data: "matched" }], |
| 499 |
{ data: "import_record_id" }, |
501 |
rowCallback: function (nRow, aData, iDisplayIndex, iDisplayIndexFull) { |
| 500 |
{ data: "citation" }, |
502 |
var record_details_url = record_type == "auth" ? "/cgi-bin/koha/authorities/detail.pl?authid=" : "/cgi-bin/koha/catalogue/detail.pl?biblionumber="; |
| 501 |
{ data: "status" }, |
503 |
var record_edit_url = record_type == "auth" ? "/cgi-bin/koha/authorities/authorities.pl?authid=" : "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber="; |
| 502 |
{ data: "overlay_status" }, |
|
|
| 503 |
{ data: null, defaultContent: "" }, |
| 504 |
{ data: null, defaultContent: "" }, |
| 505 |
{ data: "matched" } |
| 506 |
], |
| 507 |
rowCallback: function(nRow, aData, iDisplayIndex, iDisplayIndexFull) { |
| 508 |
var record_details_url = record_type == 'auth' ? "/cgi-bin/koha/authorities/detail.pl?authid=":"/cgi-bin/koha/catalogue/detail.pl?biblionumber="; |
| 509 |
var record_edit_url = record_type == 'auth' ? "/cgi-bin/koha/authorities/authorities.pl?authid=":"/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber="; |
| 510 |
|
504 |
|
| 511 |
var additional_details = ""; |
505 |
var additional_details = ""; |
| 512 |
if( aData['author'] ){ |
506 |
if (aData["author"]) { |
| 513 |
additional_details += " " + escape_str(aData['author']) + " "; |
507 |
additional_details += " " + escape_str(aData["author"]) + " "; |
| 514 |
} |
508 |
} |
| 515 |
|
509 |
|
| 516 |
if( aData['isbn'] ){ |
510 |
if (aData["isbn"]) { |
| 517 |
additional_details += " (" + escape_str(aData['isbn']) + ") "; |
511 |
additional_details += " (" + escape_str(aData["isbn"]) + ") "; |
| 518 |
} |
512 |
} |
| 519 |
|
513 |
|
| 520 |
if( aData['issn'] ){ |
514 |
if (aData["issn"]) { |
| 521 |
additional_details += " (" + escape_str(aData['issn']) + ") "; |
515 |
additional_details += " (" + escape_str(aData["issn"]) + ") "; |
| 522 |
} |
516 |
} |
| 523 |
|
517 |
|
| 524 |
$('td:eq(1)', nRow).html( |
518 |
$("td:eq(1)", nRow).html('<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData["import_record_id"] + '&viewas=html" class="previewMARC">' + escape_str(aData["citation"]) + "</a> " + additional_details); |
| 525 |
'<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData['import_record_id'] + '&viewas=html" class="previewMARC">' + escape_str(aData['citation']) + '</a> ' + additional_details |
|
|
| 526 |
); |
| 527 |
|
519 |
|
| 528 |
$('td:eq(2)', nRow).html( |
520 |
$("td:eq(2)", nRow).html( |
| 529 |
aData['status'] == 'imported' ? _("Imported") : |
521 |
aData["status"] == "imported" |
| 530 |
aData['status'] == 'ignored' ? _("Ignored") : |
522 |
? _("Imported") |
| 531 |
aData['status'] == 'reverted' ? _("Reverted") : |
523 |
: aData["status"] == "ignored" |
| 532 |
aData['status'] == 'staged' ? _("Staged") : |
524 |
? _("Ignored") |
| 533 |
aData['status'] == 'error' ? _("Error") : |
525 |
: aData["status"] == "reverted" |
| 534 |
aData['status'] |
526 |
? _("Reverted") |
|
|
527 |
: aData["status"] == "staged" |
| 528 |
? _("Staged") |
| 529 |
: aData["status"] == "error" |
| 530 |
? _("Error") |
| 531 |
: aData["status"] |
| 535 |
); |
532 |
); |
| 536 |
|
533 |
|
| 537 |
$('td:eq(3)', nRow).html( |
534 |
$("td:eq(3)", nRow).html( |
| 538 |
aData['overlay_status'] == 'no_match' ? _("No match") : |
535 |
aData["overlay_status"] == "no_match" ? _("No match") : aData["overlay_status"] == "match_applied" ? _("Match applied") : aData["overlay_status"] == "auto_match" ? _("Match found") : aData["overlay_status"] |
| 539 |
aData['overlay_status'] == 'match_applied' ? _("Match applied") : |
|
|
| 540 |
aData['overlay_status'] == 'auto_match' ? _("Match found") : |
| 541 |
aData['overlay_status'] |
| 542 |
); |
536 |
); |
| 543 |
|
537 |
|
| 544 |
if ( aData['matches'].length > 0 ) { |
538 |
if (aData["matches"].length > 0) { |
| 545 |
|
|
|
| 546 |
var any_checked = 0; |
539 |
var any_checked = 0; |
| 547 |
$('td:eq(4)', nRow).html('<ul class="matches"></ul>'); |
540 |
$("td:eq(4)", nRow).html('<ul class="matches"></ul>'); |
| 548 |
$('td:eq(5)', nRow).html('<ul class="matches"></ul>'); |
541 |
$("td:eq(5)", nRow).html('<ul class="matches"></ul>'); |
| 549 |
var checked = ""; |
542 |
var checked = ""; |
| 550 |
var disabled = ""; |
543 |
var disabled = ""; |
| 551 |
if( aData['status'] == "imported" || aData['status'] == "ignored" ){ |
544 |
if (aData["status"] == "imported" || aData["status"] == "ignored") { |
| 552 |
disabled = ' disabled '; |
545 |
disabled = " disabled "; |
| 553 |
} |
546 |
} |
| 554 |
aData['matches'].forEach(function(item,index){ |
547 |
aData["matches"].forEach(function (item, index) { |
| 555 |
if( item.chosen == 1 ){ |
548 |
if (item.chosen == 1) { |
| 556 |
checked = 'checked="checked"'; |
549 |
checked = 'checked="checked"'; |
| 557 |
any_checked = 1; |
550 |
any_checked = 1; |
| 558 |
} |
551 |
} |
| 559 |
var match_option = ""; |
552 |
var match_option = ""; |
| 560 |
match_option = '<input type="radio" data-import_record_id="'+aData['import_record_id']+'" class="chosen" name="import_record_id_'+aData['import_record_id']+'_match" value="'+item.candidate_match_id+'" ' + checked + disabled + '> '; |
553 |
match_option = |
|
|
554 |
'<input type="radio" data-import_record_id="' + |
| 555 |
aData["import_record_id"] + |
| 556 |
'" class="chosen" name="import_record_id_' + |
| 557 |
aData["import_record_id"] + |
| 558 |
'_match" value="' + |
| 559 |
item.candidate_match_id + |
| 560 |
'" ' + |
| 561 |
checked + |
| 562 |
disabled + |
| 563 |
"> "; |
| 561 |
|
564 |
|
| 562 |
var diff_url = '/cgi-bin/koha/tools/showdiffmarc.pl?batchid=%s&importid=%s&id=%s&type=%s'; |
565 |
var diff_url = "/cgi-bin/koha/tools/showdiffmarc.pl?batchid=%s&importid=%s&id=%s&type=%s"; |
| 563 |
var match_citation = ''; |
566 |
var match_citation = ""; |
| 564 |
var matching_msg = ''; |
567 |
var matching_msg = ""; |
| 565 |
if ( item.record_type == 'auth' ){ |
568 |
if (item.record_type == "auth") { |
| 566 |
matching_msg = _("Matches authority %s (score=%s):%s"); |
569 |
matching_msg = _("Matches authority %s (score=%s):%s"); |
| 567 |
if( item.authorized_heading ){ match_citation += item.authorized_heading } |
570 |
if (item.authorized_heading) { |
| 568 |
} else { |
571 |
match_citation += item.authorized_heading; |
| 569 |
matching_msg = _("Matches bibliographic record %s (score=%s):%s"); |
572 |
} |
| 570 |
if( item.title ){ match_citation += item.title + ' ' } |
573 |
} else { |
| 571 |
if( item.author ){ match_citation += item.author } |
574 |
matching_msg = _("Matches bibliographic record %s (score=%s):%s"); |
|
|
575 |
if (item.title) { |
| 576 |
match_citation += item.title + " "; |
| 572 |
} |
577 |
} |
| 573 |
$('td:eq(4) ul', nRow).append('<li><label for="import_record_id_'+aData['import_record_id']+'_match_'+index+'">'+match_option+ |
578 |
if (item.author) { |
| 574 |
matching_msg.format(item.candidate_match_id, item.score, |
579 |
match_citation += item.author; |
| 575 |
'<a target="_blank" href="' + record_details_url |
580 |
} |
| 576 |
+ item.candidate_match_id + '">' + match_citation + '</a></label></li>') |
581 |
} |
|
|
582 |
$("td:eq(4) ul", nRow).append( |
| 583 |
'<li><label for="import_record_id_' + |
| 584 |
aData["import_record_id"] + |
| 585 |
"_match_" + |
| 586 |
index + |
| 587 |
'">' + |
| 588 |
match_option + |
| 589 |
matching_msg.format(item.candidate_match_id, item.score, '<a target="_blank" href="' + record_details_url + item.candidate_match_id + '">' + match_citation + "</a></label></li>") |
| 577 |
); |
590 |
); |
| 578 |
$('td:eq(5) ul', nRow).append('<li><a href="' |
591 |
$("td:eq(5) ul", nRow).append('<li><a href="' + diff_url.format(import_batch_id, aData["import_record_id"], item.candidate_match_id, item.record_type) + '">' + _("View") + "</a></li>"); |
| 579 |
+ diff_url.format(import_batch_id, aData['import_record_id'], item.candidate_match_id, item.record_type) + '">' + _("View") + '</a></li>'); |
|
|
| 580 |
checked = ""; |
592 |
checked = ""; |
| 581 |
}); |
593 |
}); |
| 582 |
if( !any_checked ){ checked = 'checked="checked"'; } |
594 |
if (!any_checked) { |
| 583 |
$('td:eq(4) ul', nRow).prepend('<li><label><input type="radio" data-import_record_id="'+aData['import_record_id']+'" class="chosen" name="import_record_id_'+aData['import_record_id']+'_match" value="none" ' + checked + disabled + ' > '+_("Ignore matches")+'</label></li>'); |
595 |
checked = 'checked="checked"'; |
| 584 |
$('td:eq(5) ul', nRow).prepend('<li> </li>'); |
596 |
} |
| 585 |
} |
597 |
$("td:eq(4) ul", nRow).prepend( |
| 586 |
if (aData['diff_url']) { |
598 |
'<li><label><input type="radio" data-import_record_id="' + |
| 587 |
$('td:eq(5)', nRow).html( |
599 |
aData["import_record_id"] + |
| 588 |
'<a href="' + aData['diff_url'] + '">' + _("View") + '</a>' |
600 |
'" class="chosen" name="import_record_id_' + |
|
|
601 |
aData["import_record_id"] + |
| 602 |
'_match" value="none" ' + |
| 603 |
checked + |
| 604 |
disabled + |
| 605 |
" > " + |
| 606 |
_("Ignore matches") + |
| 607 |
"</label></li>" |
| 589 |
); |
608 |
); |
|
|
609 |
$("td:eq(5) ul", nRow).prepend("<li> </li>"); |
| 610 |
} |
| 611 |
if (aData["diff_url"]) { |
| 612 |
$("td:eq(5)", nRow).html('<a href="' + aData["diff_url"] + '">' + _("View") + "</a>"); |
| 590 |
} |
613 |
} |
| 591 |
if (aData["matched"]) { |
614 |
if (aData["matched"]) { |
| 592 |
let buttons = '<a class="btn btn-default btn-xs" target="_blank" href="' + record_details_url + aData["matched"] + '"><i class="fa-solid fa-eye"></i> ' + _("View") + "</a> "; |
615 |
let buttons = '<a class="btn btn-default btn-xs" target="_blank" href="' + record_details_url + aData["matched"] + '"><i class="fa-solid fa-eye"></i> ' + _("View") + "</a> "; |
|
Lines 597-640
Link Here
|
| 597 |
} |
620 |
} |
| 598 |
}, |
621 |
}, |
| 599 |
}); |
622 |
}); |
| 600 |
$("#revert_batch_form").on("submit", function() { |
623 |
$("#revert_batch_form").on("submit", function () { |
| 601 |
return confirm(_("Are you sure you want to undo the import of this batch into the catalog?")); |
624 |
return confirm(_("Are you sure you want to undo the import of this batch into the catalog?")); |
| 602 |
}); |
625 |
}); |
| 603 |
} |
626 |
} |
| 604 |
|
627 |
|
| 605 |
$("body").on("change", ".chosen", function(e) { |
628 |
$("body").on("change", ".chosen", function (e) { |
| 606 |
let apimethod = "DELETE"; |
629 |
let apimethod = "DELETE"; |
| 607 |
let apidata =""; |
630 |
let apidata = ""; |
| 608 |
if( $(this).val() != 'none' ){ |
631 |
if ($(this).val() != "none") { |
| 609 |
apimethod = 'PUT'; |
632 |
apimethod = "PUT"; |
| 610 |
apidata = JSON.stringify({ candidate_match_id: $(this).val() }); |
633 |
apidata = JSON.stringify({ candidate_match_id: $(this).val() }); |
| 611 |
} |
634 |
} |
| 612 |
$.ajax({ |
635 |
$.ajax({ |
| 613 |
url: '/api/v1/import_batches/' + import_batch_id + '/records/'+$(this).data('import_record_id')+'/matches/chosen', |
636 |
url: "/api/v1/import_batches/" + import_batch_id + "/records/" + $(this).data("import_record_id") + "/matches/chosen", |
| 614 |
method: apimethod, |
637 |
method: apimethod, |
| 615 |
data: apidata, |
638 |
data: apidata, |
| 616 |
contentType: 'application/json' |
639 |
contentType: "application/json", |
| 617 |
}).fail(function(){ alert(_("Unable to update match choices")); return false; }); |
640 |
}).fail(function () { |
|
|
641 |
alert(_("Unable to update match choices")); |
| 642 |
return false; |
| 643 |
}); |
| 618 |
}); |
644 |
}); |
| 619 |
|
645 |
|
| 620 |
$("body").on("click", ".previewMARC", function(e) { |
646 |
$("body").on("click", ".previewMARC", function (e) { |
| 621 |
e.preventDefault(); |
647 |
e.preventDefault(); |
| 622 |
var ltitle = $(this).text(); |
648 |
var ltitle = $(this).text(); |
| 623 |
var page = $(this).attr("href"); |
649 |
var page = $(this).attr("href"); |
| 624 |
$("#marcPreviewLabel").text(ltitle); |
650 |
$("#marcPreviewLabel").text(ltitle); |
| 625 |
$("#marcPreview .modal-body").load(page + " table"); |
651 |
$("#marcPreview .modal-body").load(page + " table"); |
| 626 |
$('#marcPreview').modal("show"); |
652 |
$("#marcPreview").modal("show"); |
| 627 |
}); |
653 |
}); |
| 628 |
$("#marcPreview").on("hidden.bs.modal", function() { |
654 |
$("#marcPreview").on("hidden.bs.modal", function () { |
| 629 |
$("#marcPreviewLabel").html(""); |
655 |
$("#marcPreviewLabel").html(""); |
| 630 |
$("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"" + interface + "/" + theme + "/img/spinner-small.gif\" alt=\"\" /> " + _("Loading") + "</div>"); |
656 |
$("#marcPreview .modal-body").html('<div id="loading"><img src="' + interface + "/" + theme + '/img/spinner-small.gif" alt="" /> ' + _("Loading") + "</div>"); |
| 631 |
}); |
657 |
}); |
| 632 |
$(".batch_form").on("submit", function() { |
658 |
$(".batch_form").on("submit", function () { |
| 633 |
if ($(this).hasClass("batch_delete")) { |
659 |
if ($(this).hasClass("batch_delete")) { |
| 634 |
return confirm(_("Are you sure you want to permanently delete this batch?")); |
660 |
return confirm(_("Are you sure you want to permanently delete this batch?")); |
| 635 |
} else { |
661 |
} else { |
| 636 |
if ($(this).find("input[name='import_status']").val() === "imported" ) { |
662 |
if ($(this).find("input[name='import_status']").val() === "imported") { |
| 637 |
return confirm(_("This batch contains imported records. Are you sure you wish to clear all the reservoir records? This cannot be undone.")); |
663 |
return confirm(_("This batch contains imported records. Are you sure you wish to clear all the reservoir records? This cannot be undone.")); |
| 638 |
} else { |
664 |
} else { |
| 639 |
return confirm(_("Clear all reservoir records staged in this batch? This cannot be undone.")); |
665 |
return confirm(_("Clear all reservoir records staged in this batch? This cannot be undone.")); |
| 640 |
} |
666 |
} |