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

(-)a/Koha/REST/V1/Biblios/MetadataErrors.pm (+63 lines)
Line 0 Link Here
1
package Koha::REST::V1::Biblios::MetadataErrors;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <https://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Mojo::Base 'Mojolicious::Controller';
21
22
use Koha::Biblio::Metadata::Errors;
23
use Koha::Biblios;
24
25
use Try::Tiny;
26
27
=head1 NAME
28
29
Koha::REST::V1::Biblios::MetadataErrors - REST controller for biblio metadata errors
30
31
=head1 API
32
33
=head2 Methods
34
35
=head3 delete
36
37
Delete (resolve) a single biblio metadata error row.
38
39
=cut
40
41
sub delete {
42
    my $c = shift->openapi->valid_input or return;
43
44
    my $biblio = Koha::Biblios->find( $c->param('biblio_id') );
45
    return $c->render_resource_not_found("Biblio") unless $biblio;
46
47
    my $error = Koha::Biblio::Metadata::Errors->find(
48
        {
49
            id          => $c->param('error_id'),
50
            metadata_id => $biblio->metadata->id,
51
        }
52
    );
53
    return $c->render_resource_not_found("Metadata error") unless $error;
54
55
    return try {
56
        $error->delete;
57
        return $c->render_resource_deleted;
58
    } catch {
59
        $c->unhandled_exception($_);
60
    };
61
}
62
63
1;
(-)a/api/v1/swagger/paths/biblios_metadata_errors.yaml (+48 lines)
Line 0 Link Here
1
---
2
"/biblios/{biblio_id}/metadata/errors/{error_id}":
3
  delete:
4
    x-mojo-to: Biblios::MetadataErrors#delete
5
    operationId: deleteBiblioMetadataError
6
    tags:
7
    - biblios
8
    summary: Delete a biblio metadata error
9
    description: Deletes a specific metadata error record, marking it as resolved.
10
    parameters:
11
    - name: biblio_id
12
      in: path
13
      description: Internal identifier for the bibliographic record
14
      required: true
15
      type: integer
16
    - name: error_id
17
      in: path
18
      description: Internal identifier for the metadata error
19
      required: true
20
      type: integer
21
    produces:
22
    - application/json
23
    responses:
24
      '204':
25
        description: Metadata error deleted
26
      '401':
27
        description: Authentication required
28
        schema:
29
          "$ref": "../swagger.yaml#/definitions/error"
30
      '403':
31
        description: Access forbidden
32
        schema:
33
          "$ref": "../swagger.yaml#/definitions/error"
34
      '404':
35
        description: Metadata error not found
36
        schema:
37
          "$ref": "../swagger.yaml#/definitions/error"
38
      '500':
39
        description: Internal error
40
        schema:
41
          "$ref": "../swagger.yaml#/definitions/error"
42
      '503':
43
        description: Under maintenance
44
        schema:
45
          "$ref": "../swagger.yaml#/definitions/error"
46
    x-koha-authorization:
47
      permissions:
48
        editcatalogue: edit_catalogue
(-)a/api/v1/swagger/swagger.yaml (+2 lines)
Lines 299-304 paths: Link Here
299
    $ref: "./paths/biblios_item_groups.yaml#/~1biblios~1{biblio_id}~1item_groups~1{item_group_id}~1items"
299
    $ref: "./paths/biblios_item_groups.yaml#/~1biblios~1{biblio_id}~1item_groups~1{item_group_id}~1items"
300
  "/biblios/{biblio_id}/item_groups/{item_group_id}/items/{item_id}":
300
  "/biblios/{biblio_id}/item_groups/{item_group_id}/items/{item_id}":
301
    $ref: "./paths/biblios_item_groups.yaml#/~1biblios~1{biblio_id}~1item_groups~1{item_group_id}~1items~1{item_id}"
301
    $ref: "./paths/biblios_item_groups.yaml#/~1biblios~1{biblio_id}~1item_groups~1{item_group_id}~1items~1{item_id}"
302
  "/biblios/{biblio_id}/metadata/errors/{error_id}":
303
    $ref: "./paths/biblios_metadata_errors.yaml#/~1biblios~1{biblio_id}~1metadata~1errors~1{error_id}"
302
  "/biblios/{biblio_id}/merge":
304
  "/biblios/{biblio_id}/merge":
303
    $ref: "./paths/biblios_merge.yaml#/~1biblios~1{biblio_id}~1merge"
305
    $ref: "./paths/biblios_merge.yaml#/~1biblios~1{biblio_id}~1merge"
304
  /cash_registers:
306
  /cash_registers:
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt (-3 / +23 lines)
Lines 208-213 Link Here
208
                window.scrollTo(0, getScrollto($li.attr("id"), "toolbar"));
208
                window.scrollTo(0, getScrollto($li.attr("id"), "toolbar"));
209
            });
209
            });
210
210
211
            $("body").on("click", ".nonxml-resolve", function(e){
212
                e.preventDefault();
213
                var errorId  = $(this).data("error-id");
214
                var biblioId = $(this).data("biblio-id");
215
                var $item    = $("#nonxml-error-" + errorId);
216
                $.ajax({
217
                    url:    "/api/v1/biblios/" + biblioId + "/metadata/errors/" + errorId,
218
                    method: "DELETE",
219
                    success: function(){
220
                        $item.remove();
221
                        if ( $("#nonxml-error-list li").length === 0 ) {
222
                            $("#nonxml-errors-notice").remove();
223
                        }
224
                    },
225
                    error: function(){
226
                        alert( _("Failed to mark error as resolved. Please try again.") );
227
                    }
228
                });
229
            });
230
211
        });
231
        });
212
232
213
        function selectTab( tablink ){
233
        function selectTab( tablink ){
Lines 817-825 Link Here
817
        <div class="alert alert-warning" id="nonxml-errors-notice">
837
        <div class="alert alert-warning" id="nonxml-errors-notice">
818
            <h2>Data quality warnings</h2>
838
            <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>
839
            <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>
840
            <ul id="nonxml-error-list">
821
                [% FOREACH err IN existing_nonxml_errors %]
841
                [% FOREACH err IN existing_nonxml_errors %]
822
                    <li>
842
                    <li id="nonxml-error-[% err.id | html %]">
823
                        [% IF err.tag %]
843
                        [% 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 %]>
844
                            <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>
845
                                <i class="fa fa-arrow-right" aria-hidden="true"></i>
Lines 827-832 Link Here
827
                            </a>
847
                            </a>
828
                        [% END %]
848
                        [% END %]
829
                        <code>[% err.message | html %]</code>
849
                        <code>[% err.message | html %]</code>
850
                        <button class="nonxml-resolve btn btn-default btn-xs" data-error-id="[% err.id | html %]" data-biblio-id="[% biblionumber | html %]"> Mark resolved </button>
830
                    </li>
851
                    </li>
831
                [% END %]
852
                [% END %]
832
            </ul>
853
            </ul>
833
- 

Return to bug 35104