View | Details | Raw Unified | Return to bug 35104
Collapse All | Expand All

(-)a/Koha/Biblio/Metadata.pm (-2 / +5 lines)
Lines 117-125 sub store { Link Here
117
117
118
    $self->SUPER::store;
118
    $self->SUPER::store;
119
119
120
    # Sync nonxml_stripped error rows: clear any existing, then re-add if needed
120
    # If this save triggered fresh stripping, replace all existing nonxml_stripped
121
    $self->metadata_errors->search( { error_type => 'nonxml_stripped' } )->delete;
121
    # errors with the new set.  If the save was clean (no stripping needed), leave
122
    # any existing errors alone – they are review flags requiring explicit human
123
    # resolution and should not be silently cleared by a routine re-save.
122
    if ($nonxml_error_message) {
124
    if ($nonxml_error_message) {
125
        $self->metadata_errors->search( { error_type => 'nonxml_stripped' } )->delete;
123
        my @occurrences =
126
        my @occurrences =
124
            ref $nonxml_error_message eq 'ARRAY'
127
            ref $nonxml_error_message eq 'ARRAY'
125
            ? @{$nonxml_error_message}
128
            ? @{$nonxml_error_message}
(-)a/cataloguing/addbiblio.pl (+29 lines)
Lines 681-686 if ($biblionumber) { Link Here
681
    }
681
    }
682
}
682
}
683
683
684
# Load any existing nonxml_stripped errors so they can be shown in the edit form
685
# with quick-links to the affected fields.
686
if ( $biblio && $is_a_modif ) {
687
    my @existing_errors = $biblio->metadata->metadata_errors->search( { error_type => 'nonxml_stripped' } )->as_list;
688
    if (@existing_errors) {
689
        $template->param(
690
            existing_nonxml_errors => [
691
                map {
692
                    my $msg = $_->message;
693
694
                    # First line is "TAG$sub: invalid char ..." – extract tag/subfield
695
                    my ($field_ref) = $msg =~ /^(\S+?):/;
696
                    my ( $tag, $subfield ) =
697
                          $field_ref && $field_ref =~ /^(\w+)\$(\w)$/ ? ( $1,         $2 )
698
                        : $field_ref                                  ? ( $field_ref, undef )
699
                        :                                               ( undef, undef );
700
                    {
701
                        id        => $_->id,
702
                        message   => $msg,
703
                        field_ref => $field_ref // '',
704
                        tag       => $tag       // '',
705
                        subfield  => $subfield  // '',
706
                    }
707
                } @existing_errors
708
            ]
709
        );
710
    }
711
}
712
684
#-------------------------------------------------------------------------------------
713
#-------------------------------------------------------------------------------------
685
if ( $op eq "cud-addbiblio" ) {
714
if ( $op eq "cud-addbiblio" ) {
686
715
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt (-1 / +34 lines)
Lines 193-198 Link Here
193
                document.getElementById("form-errors").scrollIntoView();
193
                document.getElementById("form-errors").scrollIntoView();
194
            });
194
            });
195
195
196
            $("body").on("click", ".nonxml-linkfield", function(e){
197
                e.preventDefault();
198
                var tag = $(this).data("tag");
199
                var sub = $(this).data("subfield") || "@";
200
                // Find the first subfield_line for this tag+subfield (random suffix unknown)
201
                var $li = $('li[id^="subfield' + tag + sub + '"]').first();
202
                if ( !$li.length ) return;
203
                // Determine which tab contains the field
204
                var $tabpane = $li.closest(".tab-pane");
205
                if ( $tabpane.length ) {
206
                    selectTab("#" + $tabpane.attr("id"));
207
                }
208
                window.scrollTo(0, getScrollto($li.attr("id"), "toolbar"));
209
            });
210
196
        });
211
        });
197
212
198
        function selectTab( tablink ){
213
        function selectTab( tablink ){
Lines 798-803 Link Here
798
[% END #/ WRAPPER sub-header.inc %]
813
[% END #/ WRAPPER sub-header.inc %]
799
814
800
[% WRAPPER 'main-container.inc' wide_centered => 1 %]
815
[% WRAPPER 'main-container.inc' wide_centered => 1 %]
816
    [% IF existing_nonxml_errors %]
817
        <div class="alert alert-warning" id="nonxml-errors-notice">
818
            <h2>Data quality warnings</h2>
819
            <p><strong>Non-XML characters were automatically stripped from this record when it was last saved. Please review the affected fields and correct or confirm the data.</strong></p>
820
            <ul>
821
                [% FOREACH err IN existing_nonxml_errors %]
822
                    <li>
823
                        [% IF err.tag %]
824
                            <a class="nonxml-linkfield btn btn-link" href="#" data-tag="[% err.tag | html %]" [% IF err.subfield %]data-subfield="[% err.subfield | html %]"[% END %]>
825
                                <i class="fa fa-arrow-right" aria-hidden="true"></i>
826
                                Go to [% err.field_ref | html %]
827
                            </a>
828
                        [% END %]
829
                        <code>[% err.message | html %]</code>
830
                    </li>
831
                [% END %]
832
            </ul>
833
        </div>
834
    [% END %]
801
    [% IF ( INVALID_METADATA ) %]
835
    [% IF ( INVALID_METADATA ) %]
802
        <div class="alert alert-warning">
836
        <div class="alert alert-warning">
803
            <h1>Errors found</h1>
837
            <h1>Errors found</h1>
804
- 

Return to bug 35104