|
Lines 155-168
Link Here
|
| 155 |
|
155 |
|
| 156 |
$(".tag_anchor").on("click", function(e){ |
156 |
$(".tag_anchor").on("click", function(e){ |
| 157 |
e.preventDefault(); |
157 |
e.preventDefault(); |
| 158 |
var toolbar_height = $("#toolbar").outerHeight(); |
|
|
| 159 |
$(".tag_anchor").removeClass("selected"); |
158 |
$(".tag_anchor").removeClass("selected"); |
| 160 |
$(this).addClass("selected"); |
159 |
$(this).addClass("selected"); |
| 161 |
var link = this.href; |
160 |
var link = this.href; |
| 162 |
var linkid = link.substring( link.indexOf("#") + 1 ); |
161 |
var linkid = link.substring( link.indexOf("#") + 1 ); |
| 163 |
var dest = $("#" + linkid ); |
162 |
window.scrollTo( 0, getScrollto( linkid, "toolbar" ) ); |
| 164 |
var yoffset = dest.offset(); |
163 |
}); |
| 165 |
window.scrollTo( 0, yoffset.top - toolbar_height - 20 ); |
164 |
|
|
|
165 |
$("body").on("click", ".linkfield", function(e){ |
| 166 |
e.preventDefault(); |
| 167 |
var tab = $(this).data("tab"); |
| 168 |
var field = $(this).data("field"); |
| 169 |
var tablink = $("a[data-tabid='" + tab + "']" ); |
| 170 |
selectTab( tablink ); |
| 171 |
window.scrollTo( 0, getScrollto( field, "toolbar" ) ); |
| 172 |
}); |
| 173 |
|
| 174 |
$("body").on("click", ".show-errors", function(e){ |
| 175 |
document.getElementById("form-errors").scrollIntoView(); |
| 166 |
}); |
176 |
}); |
| 167 |
|
177 |
|
| 168 |
}); |
178 |
}); |
|
Lines 176-181
Link Here
|
| 176 |
$(".tag_anchors_" + tabid ).addClass("tab_selected").show(); |
186 |
$(".tag_anchors_" + tabid ).addClass("tab_selected").show(); |
| 177 |
} |
187 |
} |
| 178 |
|
188 |
|
|
|
189 |
/** |
| 190 |
* Returns a roughly ideal position to scroll an element into view |
| 191 |
* @param {string} target - The HTML id of the element to scroll into view |
| 192 |
* @param {string} elemid - The HTML id of the element which might obscure |
| 193 |
* the view of the target element e.g. a floating toolbar |
| 194 |
* @return {number} - The y-coordinate to pass to window.scrollTo() |
| 195 |
*/ |
| 196 |
function getScrollto( target, elemid ){ |
| 197 |
var dest = $("#" + target ); |
| 198 |
var yoffset = dest.offset(); |
| 199 |
|
| 200 |
if( elemid != "" ){ |
| 201 |
var element = $("#" + elemid ); |
| 202 |
var elem_height = element.outerHeight(); |
| 203 |
} else { |
| 204 |
elem_height = 0; |
| 205 |
} |
| 206 |
return yoffset.top - elem_height - 20; |
| 207 |
} |
| 208 |
|
| 179 |
function redirect(dest){ |
209 |
function redirect(dest){ |
| 180 |
$("#redirect").attr("value",dest); |
210 |
$("#redirect").attr("value",dest); |
| 181 |
return Check(); |
211 |
return Check(); |
|
Lines 185-191
Link Here
|
| 185 |
var onOption = function () { |
215 |
var onOption = function () { |
| 186 |
return Check(); |
216 |
return Check(); |
| 187 |
} |
217 |
} |
| 188 |
[% END %] |
218 |
[% END %] |
| 189 |
|
219 |
|
| 190 |
/** |
220 |
/** |
| 191 |
* this function append button for create new authority if not found |
221 |
* this function append button for create new authority if not found |
|
Lines 512-525
function PopupMARCFieldDoc(field) {
Link Here
|
| 512 |
var label = new Array(); |
542 |
var label = new Array(); |
| 513 |
var flag=0; |
543 |
var flag=0; |
| 514 |
var tabflag= new Array(); |
544 |
var tabflag= new Array(); |
| 515 |
var StrAlert = ""; |
545 |
var StrAlert = "<div id='form-errors' class='dialog alert list'>"; |
| 516 |
var notFilledClass = "subfield_not_filled"; |
546 |
var notFilledClass = "subfield_not_filled"; |
| 517 |
|
547 |
|
| 518 |
if (mandatory) { |
548 |
if (mandatory) { |
| 519 |
[% FOREACH BIG_LOO IN BIG_LOOP %] |
549 |
[% FOREACH BIG_LOO IN BIG_LOOP %] |
| 520 |
[% FOREACH innerloo IN BIG_LOO.innerloop %] |
550 |
[% FOREACH innerloo IN BIG_LOO.innerloop %] |
| 521 |
[% IF ( innerloo.mandatory ) %] |
551 |
[% IF ( innerloo.mandatory ) %] |
| 522 |
fields.push(new Array("[% innerloo.tag | html %]","[% innerloo.index | html %][% innerloo.random | html %]","[% innerloo.index | html %]")); |
552 |
fields.push(new Array("[% innerloo.tag | html %]","[% innerloo.index | html %][% innerloo.random | html %]","[% innerloo.index | html %]", "[% BIG_LOO.number | html %]")); |
| 523 |
[% END %] |
553 |
[% END %] |
| 524 |
[% FOREACH subfield_loo IN innerloo.subfield_loop %] |
554 |
[% FOREACH subfield_loo IN innerloo.subfield_loop %] |
| 525 |
[% IF ( subfield_loo.mandatory ) %]subfields.push("[% subfield_loo.id | html %]"); |
555 |
[% IF ( subfield_loo.mandatory ) %]subfields.push("[% subfield_loo.id | html %]"); |
|
Lines 529-540
function PopupMARCFieldDoc(field) {
Link Here
|
| 529 |
[% END %] |
559 |
[% END %] |
| 530 |
[% END %] |
560 |
[% END %] |
| 531 |
[% END %] |
561 |
[% END %] |
| 532 |
StrAlert = _("Can't save this record because the following field aren't filled:"); |
562 |
StrAlert += "<h4>" + _("The following subfields aren't filled:") + "</h4>"; |
| 533 |
} else { |
563 |
} else { |
| 534 |
[% FOREACH BIG_LOO IN BIG_LOOP %] |
564 |
[% FOREACH BIG_LOO IN BIG_LOOP %] |
| 535 |
[% FOREACH innerloo IN BIG_LOO.innerloop %] |
565 |
[% FOREACH innerloo IN BIG_LOO.innerloop %] |
| 536 |
[% IF ( innerloo.important ) %] |
566 |
[% IF ( innerloo.important ) %] |
| 537 |
fields.push(new Array("[% innerloo.tag | html %]","[% innerloo.index | html %][% innerloo.random | html %]","[% innerloo.index | html %]")); |
567 |
fields.push(new Array("[% innerloo.tag | html %]","[% innerloo.index | html %][% innerloo.random | html %]","[% innerloo.index | html %]", "[% BIG_LOO.number | html %]")); |
| 538 |
[% END %] |
568 |
[% END %] |
| 539 |
[% FOREACH subfield_loo IN innerloo.subfield_loop %] |
569 |
[% FOREACH subfield_loo IN innerloo.subfield_loop %] |
| 540 |
[% IF ( subfield_loo.important ) %]subfields.push("[% subfield_loo.id | html %]"); |
570 |
[% IF ( subfield_loo.important ) %]subfields.push("[% subfield_loo.id | html %]"); |
|
Lines 544-554
function PopupMARCFieldDoc(field) {
Link Here
|
| 544 |
[% END %] |
574 |
[% END %] |
| 545 |
[% END %] |
575 |
[% END %] |
| 546 |
[% END %] |
576 |
[% END %] |
| 547 |
StrAlert = _("A few important fields are not filled:"); |
577 |
StrAlert += "<h4>" + _("A few important fields are not filled:") + "</h4>"; |
| 548 |
notFilledClass = "important_subfield_not_filled"; |
578 |
notFilledClass = "important_subfield_not_filled"; |
| 549 |
} |
579 |
} |
| 550 |
|
580 |
StrAlert += "<ul>"; |
| 551 |
StrAlert += "\n\n"; |
|
|
| 552 |
for(var i=0,len=subfields.length; i<len ; i++){ |
581 |
for(var i=0,len=subfields.length; i<len ; i++){ |
| 553 |
var tag=subfields[i].substr(4,3); |
582 |
var tag=subfields[i].substr(4,3); |
| 554 |
var subfield=subfields[i].substr(17,1); |
583 |
var subfield=subfields[i].substr(17,1); |
|
Lines 572-589
function PopupMARCFieldDoc(field) {
Link Here
|
| 572 |
} else { |
601 |
} else { |
| 573 |
tabflag[tag+subfield+tagnumber][0] = 1; |
602 |
tabflag[tag+subfield+tagnumber][0] = 1; |
| 574 |
} |
603 |
} |
|
|
604 |
tabflag[tag+subfield+tagnumber][3] = subfields[i]; |
| 575 |
} |
605 |
} |
|
|
606 |
|
| 576 |
for (var tagsubfieldid in tabflag){ |
607 |
for (var tagsubfieldid in tabflag){ |
| 577 |
if (tabflag[tagsubfieldid][0]==0){ |
608 |
if (tabflag[tagsubfieldid][0]==0){ |
| 578 |
var tag=tagsubfieldid.substr(0,3); |
609 |
var tag=tagsubfieldid.substr(0,3); |
| 579 |
var subfield=tagsubfieldid.substr(3,1); |
610 |
var subfield=tagsubfieldid.substr(3,1); |
| 580 |
StrAlert += "\t* "+_("tag %s subfield %s %s in tab %s").format(tag, subfield, tabflag[tagsubfieldid][1], tabflag[tagsubfieldid][2]) + "\n"; |
611 |
StrAlert += "<li>"+_("Tag %s subfield %s %s in tab %s").format(tag, subfield, formatFieldName( tabflag[tagsubfieldid][1] ), tabflag[tagsubfieldid][2]) + ' <a class="linkfield btn btn-link" href="#" data-tab="' + tabflag[tagsubfieldid][2] + '" data-field="' + tabflag[tagsubfieldid][3] + '"><i class="fa fa-arrow-right" aria-hidden="true"></i> Go to field</a></li>'; |
| 581 |
//StrAlert += "\t* "+label[i]+_(" in tab ")+tab[i]+"\n"; |
|
|
| 582 |
flag=1; |
612 |
flag=1; |
| 583 |
} |
613 |
} |
| 584 |
} |
614 |
} |
| 585 |
|
615 |
StrAlert += "</ul>"; |
| 586 |
/* Check for mandatories/importants field(not subfields) */ |
616 |
/* Check for mandatories/importants field(not subfields) */ |
|
|
617 |
/* Loop over array of fields identified as mandatory or |
| 618 |
important to see if at least one subfield is filled */ |
| 619 |
mandatoryFields = new Object(); |
| 620 |
|
| 587 |
for(var i=0,len=fields.length; i<len; i++){ |
621 |
for(var i=0,len=fields.length; i<len; i++){ |
| 588 |
isempty = true; |
622 |
isempty = true; |
| 589 |
arr = fields[i]; |
623 |
arr = fields[i]; |
|
Lines 600-607
function PopupMARCFieldDoc(field) {
Link Here
|
| 600 |
inputregexp = new RegExp("^tag_" + arr[0] + "_subfield_" + eleminputs[j].value + "_" + arr[2]); |
634 |
inputregexp = new RegExp("^tag_" + arr[0] + "_subfield_" + eleminputs[j].value + "_" + arr[2]); |
| 601 |
|
635 |
|
| 602 |
for( var k=0; k<len2; k++){ |
636 |
for( var k=0; k<len2; k++){ |
| 603 |
if(eleminputs[k].id.match(inputregexp) && eleminputs[k].value){ |
637 |
if( eleminputs[k].id.match(inputregexp) ){ |
| 604 |
isempty = false |
638 |
if( eleminputs[k].value ){ |
|
|
639 |
isempty = false |
| 640 |
} |
| 605 |
} |
641 |
} |
| 606 |
} |
642 |
} |
| 607 |
|
643 |
|
|
Lines 621-644
function PopupMARCFieldDoc(field) {
Link Here
|
| 621 |
isempty = false; |
657 |
isempty = false; |
| 622 |
} |
658 |
} |
| 623 |
} |
659 |
} |
|
|
660 |
|
| 624 |
} else { |
661 |
} else { |
| 625 |
isempty = false; |
662 |
isempty = false; |
| 626 |
} |
663 |
} |
| 627 |
|
664 |
|
| 628 |
if(isempty){ |
665 |
if(isempty){ |
| 629 |
flag = 1; |
666 |
flag = 1; |
| 630 |
StrAlert += "\t* "; |
|
|
| 631 |
if (mandatory) { |
667 |
if (mandatory) { |
| 632 |
StrAlert += _("Field %s is mandatory, at least one of its subfields must be filled.").format(arr[0]); |
668 |
mandatoryFields[ arr[0] ] = { |
|
|
669 |
importance: "mandatory", |
| 670 |
elemid: "div_indicator_" + divid, |
| 671 |
tab: arr[3] |
| 672 |
} |
| 633 |
} else { |
673 |
} else { |
| 634 |
StrAlert += _("Field %s is important, at least one of its subfields must be filled.").format(arr[0]); |
674 |
mandatoryFields[ arr[0] ] = { |
|
|
675 |
importance: "important", |
| 676 |
elemid: "div_indicator_" + divid, |
| 677 |
tab: arr[3] |
| 678 |
} |
| 635 |
} |
679 |
} |
| 636 |
StrAlert += "\n"; |
|
|
| 637 |
} |
680 |
} |
| 638 |
|
681 |
|
| 639 |
} |
682 |
} |
| 640 |
|
683 |
|
|
|
684 |
if( Object.entries(mandatoryFields).length > 0 ){ |
| 685 |
StrAlert += "<h4>" + _("The following fields aren't filled:") + "</h4>"; |
| 686 |
StrAlert += "<ul>"; |
| 687 |
for( var prop in mandatoryFields ){ |
| 688 |
if( mandatoryFields[prop]["importance"] == "mandatory" ){ |
| 689 |
StrAlert += "<li>" + _("Field %s is mandatory, at least one of its subfields must be filled.").format( prop ) + ' <a class="linkfield btn btn-link" href="#" data-tab="' + mandatoryFields[prop]["tab"] + '" data-field="' + mandatoryFields[prop]["elemid"] + '"><i class="fa fa-arrow-right" aria-hidden="true"></i> Go to field</a></li>'; |
| 690 |
} else { |
| 691 |
StrAlert += "<li>" + _("Field %s is important, at least one of its subfields must be filled.").format(arr[0]) + ' <a class="linkfield btn btn-link" href="#" data-tab="' + mandatoryFields[prop]["tab"] + '" data-field="' + mandatoryFields[prop]["elemid"] + '"><i class="fa fa-arrow-right" aria-hidden="true"></i> Go to field</a></li>'; |
| 692 |
} |
| 693 |
} |
| 694 |
StrAlert += "</ul>"; |
| 695 |
} |
| 696 |
StrAlert += "</div>"; |
| 641 |
if(flag){ |
697 |
if(flag){ |
|
|
698 |
$("#show-errors").html('<button type="button" class="btn btn-danger show-errors"><i class="fa fa-warning"></i> Errors</span>'); |
| 642 |
return StrAlert; |
699 |
return StrAlert; |
| 643 |
} else { |
700 |
} else { |
| 644 |
return flag; |
701 |
return flag; |
|
Lines 663-669
function PopupMARCFieldDoc(field) {
Link Here
|
| 663 |
document.f.submit(); |
720 |
document.f.submit(); |
| 664 |
return true; |
721 |
return true; |
| 665 |
} else { |
722 |
} else { |
| 666 |
alert(StrAlert); |
723 |
$("#check_errors").html( StrAlert ); |
|
|
724 |
$('html, body').animate({ scrollTop: 0 }, 'fast'); |
| 725 |
Sticky.hcSticky('refresh'); |
| 667 |
return false; |
726 |
return false; |
| 668 |
} |
727 |
} |
| 669 |
} |
728 |
} |
|
Lines 704-709
function PopupMARCFieldDoc(field) {
Link Here
|
| 704 |
f.submit(); |
763 |
f.submit(); |
| 705 |
} |
764 |
} |
| 706 |
|
765 |
|
|
|
766 |
/* Wrap a value in HTML without putting HTML in translatable string */ |
| 767 |
function formatFieldName( string ){ |
| 768 |
return "<strong><em>" + string + "</em></strong>"; |
| 769 |
} |
| 707 |
</script> |
770 |
</script> |
| 708 |
[% Asset.css("css/addbiblio.css") | $raw %] |
771 |
[% Asset.css("css/addbiblio.css") | $raw %] |
| 709 |
</head> |
772 |
</head> |
|
Lines 739-744
function PopupMARCFieldDoc(field) {
Link Here
|
| 739 |
<div class="row"> |
802 |
<div class="row"> |
| 740 |
<div class="col-md-10 col-md-offset-1"> |
803 |
<div class="col-md-10 col-md-offset-1"> |
| 741 |
|
804 |
|
|
|
805 |
<div id="check_errors"></div> |
| 806 |
|
| 742 |
<h1> |
807 |
<h1> |
| 743 |
[% IF ( biblionumber ) %] |
808 |
[% IF ( biblionumber ) %] |
| 744 |
Editing <em>[% title | html %]</em> (Record number [% biblionumber | html %]) |
809 |
Editing <em>[% title | html %]</em> (Record number [% biblionumber | html %]) |
|
Lines 881-888
function PopupMARCFieldDoc(field) {
Link Here
|
| 881 |
</div> |
946 |
</div> |
| 882 |
[% END %] |
947 |
[% END %] |
| 883 |
[% ELSE %] |
948 |
[% ELSE %] |
| 884 |
<a class="btn btn-default" id="cancel" href="/cgi-bin/koha/cataloguing/addbooks.pl">Cancel</a> |
949 |
<div class="btn-group"> |
|
|
950 |
<a class="btn btn-default" id="cancel" href="/cgi-bin/koha/cataloguing/addbooks.pl">Cancel</a> |
| 951 |
</div> |
| 885 |
[% END %] |
952 |
[% END %] |
|
|
953 |
<div id="show-errors" class="btn-group"></div> |
| 886 |
[% END # /UNLESS circborrowernumber %] |
954 |
[% END # /UNLESS circborrowernumber %] |
| 887 |
<div class="toolbar-tabs-container"> |
955 |
<div class="toolbar-tabs-container"> |
| 888 |
[% IF ( BIG_LOOP && BIG_LOOP.size > 1 ) %] |
956 |
[% IF ( BIG_LOOP && BIG_LOOP.size > 1 ) %] |
| 889 |
- |
|
|