From d7043f547b03f587177c5e4d24d9552bea12efca Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Tue, 24 Apr 2018 20:13:52 +0000 Subject: [PATCH] Bug 20678 - Save draft MARC record without committing to catalog In the 'Save' dropdown button in addbiblio.pl patrons can select the 'Save without cataloguing' button. This saves the catalog to the import_biblio db table (also referred to as the reservoir) but not to the catalog. To re-edit or save this draft record the user can either go to Tools->Manage staged MARC records and select the 'Draft records' tab, which displays all these draft records along with links to edit them in the cataloguing interface. Or the patron can search for the record in the addbooks.pl webpage in the cataloguing interface and the record will be displayed in the 'Biblios in the reservoir' section of results. Then the user can select Actions->Continue editing draft record By being able to save a record as a draft it means a librarian does not have to either save a un-finished MARC record to the catalog, or start again cataloguing from scratch if they are interrupted during cataloguing. Test plan: 1. Drop and re-create your DB and go through the web installation process so that the new atomicupdate is run 2. Go to Tools->Manage staged MARC records and notice there is a default batch file 'draft_marc_records.mrc' (with the id of 1) this batch file is what all the draft records will be 'stored' in when they are stored in the import_biblios db table. A batch file is required for all records in this aforementioned table due to foreign key constraints. 3. Go to Cataloging->New record and create a MARC record and select Save->Save without cataloging 4. Search for the title you just created and notice it is displayed in the 'Biblios in reservoir' result section and not in the catalog results. 5. Select Actions->Continue editing draft record' and now select 'Save and view record' 6. Now search the catalog for the title and the detail page of the cataloged record appears showing the record is now committed to the catalog. 7. Go to Tools->Manage staged MARC records and click on the 'Draft records' tab and notice the title you saved as a draft is displayed in the table along with a 'Edit' link which is for the cataloging page. The benefit of having this table of all draft records is librarians can quickly find all draft records and click to edit and commit the draft records to the catalog without having to remember the title of the draft record was in the cataloging search Sponsored-by: Toi Ohomai library --- cataloguing/addbiblio.pl | 10 ++- .../mysql/atomicupdate/add_draft_record_batch.sql | 1 + .../prog/en/modules/cataloguing/addbiblio.tt | 10 +++ .../prog/en/modules/cataloguing/addbooks.tt | 4 + .../prog/en/modules/tools/manage-marc-import.tt | 90 +++++++++++++++++++--- tools/batch_records_ajax.pl | 6 +- 6 files changed, 107 insertions(+), 14 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/add_draft_record_batch.sql diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 4ecaf69..6f0f924 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -702,7 +702,7 @@ my $fa_barcode = $input->param('barcode'); my $fa_branch = $input->param('branch'); my $fa_stickyduedate = $input->param('stickyduedate'); my $fa_duedatespec = $input->param('duedatespec'); - +my $previewrecord = $input->param('preview'); my $userflags = 'edit_catalogue'; my $changed_framework = $input->param('changed_framework'); @@ -774,6 +774,7 @@ my ( if (($biblionumber) && !($breedingid)){ $record = GetMarcBiblio({ biblionumber => $biblionumber }); } + if ($breedingid) { ( $record, $encoding ) = MARCfindbreeding( $breedingid ) ; } @@ -843,7 +844,12 @@ if ( $op eq "addbiblio" ) { ModBiblio( $record, $biblionumber, $frameworkcode ); } else { - ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode ); + if ($previewrecord) { + AddBiblioToBatch(1, 0, $record, 'biblio', int(rand(99999)), 0); + print $input->redirect('/cgi-bin/koha/cataloguing/addbooks.pl'); + } else { + ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode ); + } } if ($redirect eq "items" || ($mode ne "popup" && !$is_a_modif && $redirect ne "view" && $redirect ne "just_save")){ if ($frameworkcode eq 'FA'){ diff --git a/installer/data/mysql/atomicupdate/add_draft_record_batch.sql b/installer/data/mysql/atomicupdate/add_draft_record_batch.sql new file mode 100644 index 0000000..0432d25 --- /dev/null +++ b/installer/data/mysql/atomicupdate/add_draft_record_batch.sql @@ -0,0 +1 @@ +INSERT INTO import_batches (import_batch_id,record_type,file_name,comments) VALUES (1, 'biblio', 'draft_marc_records.mrc', 'MARC file containing draft MARC records created in the addbiblio.pl file but not saved to the Koha catalog'); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt index c92d51e..41864ae 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt @@ -85,6 +85,13 @@ return false; }); + $("#previewrecord").click(function(){ + $(".btn-group").removeClass("open"); + document.getElementById('preview').value = 1; + onOption(); + return false; + }); + $("#saveandview").click(function(){ $(".btn-group").removeClass("open"); redirect("view"); @@ -345,6 +352,7 @@ function AreMandatoriesNotOk(){ function Check(){ var StrAlert = AreMandatoriesNotOk(); if( ! StrAlert ){ + document.f.submit(); return true; } else { @@ -467,6 +475,7 @@ function Changefwk() {
  • Save and view record
  • Save and edit items
  • Save and continue editing
  • +
  • Save without cataloging
  • [% END %] @@ -554,6 +563,7 @@ function Changefwk() { [% END %] + diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt index 7305bd5..21d73c2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt @@ -180,7 +180,11 @@
  • MARC preview
  • Card preview
  • [% IF ( CAN_user_editcatalogue_edit_catalogue ) %] + [% IF breeding_loo.file == "draft_marc_records.mrc" %] +
  • Continue editing draft record
  • + [% ELSE %]
  • Add biblio
  • + [% END %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt index 21cd576..422bf74 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt @@ -32,7 +32,7 @@
    -

    Manage staged MARC records +

    Manage staged MARC records [% IF ( import_batch_id ) %] › Batch [% import_batch_id %] [% END %] @@ -60,7 +60,7 @@

    No records have been staged.

    Stage MARC records for import.

    -
    + /div> [% END %] [% END %] @@ -270,6 +270,14 @@ [% END %]

    [% END %] +
    + + +
    +
    @@ -284,8 +292,8 @@ [% FOREACH batch_lis IN batch_list %] - - + + - + [% END %]
    #
    [% batch_lis.import_batch_id %][% batch_lis.file_name %][% batch_lis.import_batch_id %][% batch_lis.file_name %] [% batch_lis.comments %] [% IF ( batch_lis.record_type == 'auth' ) %]Authority[% ELSE %]Bibliographic[% END %] @@ -307,7 +315,7 @@ [% batch_lis.upload_timestamp %] [% batch_lis.num_records %][% batch_lis.num_items %][% IF ( batch_lis.num_items ) %] (Create label batch)[% END %][% batch_lis.num_items %][% IF ( batch_lis.num_items ) %] (Create label batch)[% END %] [% IF ( batch_lis.can_clean ) %]
    @@ -326,6 +334,28 @@
    +
    + +
    +

    To edit or save these draft records click the 'Edit' link beside the appropriate record.

    + + + + + + + + + + + + + +
    #CitationStatusMatch typeMatch detailsDiffRecordCatalog link
    +
    +
    +
    + [% IF ( pages ) %]
    [% FOREACH page IN pages %] @@ -396,7 +426,35 @@ $(this).parent().hide(); }); - [% IF import_batch_id %] + [% IF !(import_batch_id) %] + document.getElementById('draftrecords').style.display = 'none'; + var marcfileslink = document.getElementById("marcfileslink"); + marcfileslink.style.backgroundColor = "#FFF"; + [% END %] + + var marcfiles = document.getElementById("marcfiles"); + var draftrecords = document.getElementById("draftrecords"); + var draftrecordslink = document.getElementById("draftrecordslink"); + var marcfileslink = document.getElementById("marcfileslink"); + + $("#draftrecordslink").click(function(e){ + draftrecords.style.display = "block"; + draftrecordslink.style.backgroundColor = "#FFF"; + marcfileslink.style.backgroundColor= "#e6f0f2"; + marcfiles.style.display = "none"; + if (document.getElementById("draftrecords").style.display === 'block') { + [% draft_record_to_display = 1 %] + } + }); + + $("#marcfileslink").click(function(e){ + draftrecords.style.display = "none"; + marcfiles.style.display = "block"; + draftrecordslink.style.backgroundColor = "#e6f0f2"; + marcfileslink.style.backgroundColor= "#FFF"; + }); + + [% IF (import_batch_id || draft_record_to_display) %] $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, { "bAutoWidth": false, "bFilter": false, @@ -412,11 +470,16 @@ { "mDataProp": "overlay_status" }, { "mDataProp": "match_citation" }, { "mDataProp": "diff_url" }, - { "mDataProp": "matched" } + { "mDataProp": "matched" }, + [% IF !(import_batch_id) %] { "mDataProp": "catalog_link" } [% END %] ], - "fnServerData": function ( sSource, aoData, fnCallback ) { - aoData.push( { "name": "import_batch_id", "value": [% import_batch_id %] } ); - + [% IF (import_batch_id) %] + "fnServerData": function ( sSource, aoData, fnCallback ) { + aoData.push( { "name": "import_batch_id", "value": [% import_batch_id %] } ); + [% ELSE %] + "fnServerData": function ( sSource, aoData, fnCallback ) { + aoData.push( { "name": "import_batch_id", "value": [% draft_record_to_display %] } ); + [% END %] $.ajax({ 'dataType': 'json', 'type': 'POST', @@ -475,6 +538,13 @@ '' + aData['matched'] + '' ); + [% IF !(import_batch_id) %] + if (aData['catalog_link']){ + $('td:eq(7)', nRow).html( + '' + "Edit" + '' + ); + } + [% END %] }, })); $("#import_batch_form").on("submit",function(){ diff --git a/tools/batch_records_ajax.pl b/tools/batch_records_ajax.pl index 349d858..f6aeaa8 100755 --- a/tools/batch_records_ajax.pl +++ b/tools/batch_records_ajax.pl @@ -38,6 +38,7 @@ use C4::Context; use C4::Charset; use C4::Auth qw/check_cookie_auth/; use C4::ImportBatch; +use Data::Dumper; my $input = new CGI; @@ -107,10 +108,11 @@ foreach my $record (@$records) { || q{}, score => $#$match > -1 ? $match->[0]->{'score'} : 0, match_id => $match_id, - diff_url => $match_id ? "/cgi-bin/koha/tools/showdiffmarc.pl?batchid=$import_batch_id&importid=$record->{import_record_id}&id=$match_id" : undef + diff_url => $match_id ? "/cgi-bin/koha/tools/showdiffmarc.pl?batchid=$import_batch_id&importid=$record->{import_record_id}&id=$match_id" : undef, + catalog_link => "/cgi-bin/koha/cataloguing/addbiblio.pl?breedingid=$record->{import_record_id}", }; } - +warn Dumper(@list); my $data; $data->{'iTotalRecords'} = $batch->{'num_records'}; $data->{'iTotalDisplayRecords'} = $batch->{'num_records'}; -- 2.1.4