Bugzilla – Attachment 74960 Details for
Bug 20678
Save draft records without committing them to the catalogue
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20678 - Added new Draft records interface in cataloging
Bug-20678---Added-new-Draft-records-interface-in-c.patch (text/plain), 21.35 KB, created by
Alex Buckley
on 2018-05-02 01:30:49 UTC
(
hide
)
Description:
Bug 20678 - Added new Draft records interface in cataloging
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2018-05-02 01:30:49 UTC
Size:
21.35 KB
patch
obsolete
>From 79bb36b61b44aca0e9cdde330c97636a19f9f2c0 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Mon, 30 Apr 2018 02:18:56 +0000 >Subject: [PATCH] Bug 20678 - Added new Draft records interface in cataloging > >Instead of using the Tools->Manage Staged MARC records interface to list >all draft records and links to edit or delete them I have created a new >interface in the Cataloging module (draftrecords.pl) which is accessible >by clicking the 'View draft records' button at the top of the Cataloging >home page. > >draftrecords.pl contains a JS datatable of all draft records in the >reservoir. There is a link to delete all draft records, in addition to >individual 'Edit' and 'Delete' buttons for each draft record. > >This datatable is based on the datatable on the Manage Staged MARC >records interface and I have removed unneccessary columns such as >comments, type, staged timestamp etc. > >The rationale for creating a new Draft records interface in cataloging >rather than using the existing Manage Staged MARC records interface is >that it is more intuitive for librarians to look in cataloging for draft >records to continue cataloging. They would be very unlikely to think >draft records can be accessed from the Manage Staged MARC records. > >i.e. Although the draft records use the same backend infrastructure as >the staged records the end-users don't know or care about that. Thus it >is best to place the Draft records interface in the Cataloging module as >the draft records are part way through the cataloging workflow. > >Also added to the Cataloging home page I have implemented a 'Drafts >only' search parameter checkbox hidden by default, so if librarians know >the title of the draft record they want they can find it quickly without >wading through catalog records also matching the search term. > >Test plan: > >1. Go to Tools->Manage Staged MARC records, notice the first batch file >is not shown. This is the batch file associated with the draft records. >This is hidden because this file is only needed due to foreign key >constraints in the database but it is not needed to be imported and so >it is safest to hide it. > >2. Go to Cataloging and notice there is a new button in the cataloging >toolbar named 'View draft records' > >3. Create a new record and after inputting record data select Save->Save >without cataloging. You have created a draft record. > >4. Your re-directed to the Cataloging home page. Search for the draft >record by writing in the search term and selecting 'Submit' and notice >it is returned in the 'Biblios in the reservoir' search results. > >There may also be similarly named catalog records displayed in the >result table above. > >5. Now to limit the cataloging search to draft records select the [+] >link next to the search box and select the 'Drafts only' checkbox. > >6. Now notice that only draft records in the reservoir are returned. > >7. Go and create another 3 draft records and then after you are re-directed >to the Cataloging homepage click on the 'View draft records' button in >the cataloging toolbar. > >8. The 'View draft records' webpage is displayed. Notice all 4 draft records are displayed in the datatable. > >9. Select the 'Edit' link of one of the draft records and notice the >addbiblio.pl page for that record is displayed. > >10. Commit the draft record to the catalog by selecting any option of >the 'Save' dropdown box except for the 'Save without cataloging' option. > >11. Then return to the 'View draft records' page and notice the >committed record is not displayed as a draft in the reservoir. > >This can be confirmed by performing a Cataloging search which shows the >record is in the catalog and has been removed from the reservoir. > >12. Back in the 'View draft records' select the 'Delete' link beside one >of the draft records, notice it is successfully deleted. > >13. Select the 'Delete all drafts from reservoir' and notice all the >drafts are removed successfully. > >NOTE: this patch has not added/amended routines in modules and so this >patch does not require further unit tests to be added. I have previously added a >unit test to address module routine changes made in previous patches on >this bug. > >Sponsored-By: Toi Ohomai Institute of Technology >--- > cataloguing/addbooks.pl | 51 +++++++++--- > .../mysql/atomicupdate/add_draft_record_batch.sql | 2 +- > .../prog/en/includes/cataloging-search.inc | 5 ++ > .../prog/en/modules/cataloguing/addbooks.tt | 36 ++++++++- > .../prog/en/modules/tools/manage-marc-import.tt | 93 ++++------------------ > tools/manage-marc-import.pl | 24 +++--- > 6 files changed, 104 insertions(+), 107 deletions(-) > >diff --git a/cataloguing/addbooks.pl b/cataloguing/addbooks.pl >index ae4d7ac..d3d2fa0 100755 >--- a/cataloguing/addbooks.pl >+++ b/cataloguing/addbooks.pl >@@ -33,6 +33,7 @@ use C4::Breeding; > use C4::Output; > use C4::Koha; > use C4::Search; >+use Data::Dumper; > > use Koha::BiblioFrameworks; > use Koha::SearchEngine::Search; >@@ -44,9 +45,9 @@ my $success = $input->param('biblioitem'); > my $query = $input->param('q'); > my @value = $input->multi_param('value'); > my $page = $input->param('page') || 1; >+my $drafts_only = $input->param('drafts_only'); > my $results_per_page = 20; > >- > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > { > template_name => "cataloguing/addbooks.tt", >@@ -58,8 +59,8 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > } > ); > >-# Searching the catalog. >-if ($query) { >+# Searching the catalog unless 'drafts_only' has been selected >+if (($query) && !($drafts_only)) { > > # build query > my @operands = $query; >@@ -90,6 +91,7 @@ if ($query) { > # SimpleSearch() give the results per page we want, so 0 offet here > my $total = @{$marcresults}; > my @newresults = searchResults( 'intranet', $query, $total, $results_per_page, 0, 0, $marcresults ); >+ > $template->param( > total => $total_hits, > query => $query, >@@ -121,16 +123,41 @@ if ($query) { > ( $countbr, @resultsbr ) = BreedingSearch( $title, $isbn ); > } > my $breeding_loop = []; >+ >+my $count; > for my $resultsbr (@resultsbr) { >- push @{$breeding_loop}, { >- id => $resultsbr->{import_record_id}, >- isbn => $resultsbr->{isbn}, >- copyrightdate => $resultsbr->{copyrightdate}, >- editionstatement => $resultsbr->{editionstatement}, >- file => $resultsbr->{file_name}, >- title => $resultsbr->{title}, >- author => $resultsbr->{author}, >- }; >+ >+ #Only return records associated with 'Draft record' file_name if drafts_only has been set >+ if ($drafts_only) { >+ if ($resultsbr->{file_name} eq "Draft record") { >+ push @{$breeding_loop}, { >+ id => $resultsbr->{import_record_id}, >+ isbn => $resultsbr->{isbn}, >+ copyrightdate => $resultsbr->{copyrightdate}, >+ editionstatement => $resultsbr->{editionstatement}, >+ file => $resultsbr->{file_name}, >+ title => $resultsbr->{title}, >+ author => $resultsbr->{author}, >+ }; >+ $count++; >+ } >+ } else { >+ push @{$breeding_loop}, { >+ id => $resultsbr->{import_record_id}, >+ isbn => $resultsbr->{isbn}, >+ copyrightdate => $resultsbr->{copyrightdate}, >+ editionstatement => $resultsbr->{editionstatement}, >+ file => $resultsbr->{file_name}, >+ title => $resultsbr->{title}, >+ author => $resultsbr->{author}, >+ }; >+ } >+} >+ >+#If drafts_only has been set then query, drafts_only need to be returned to template and $countbr must be based on number of drafts in reservoir >+if ($drafts_only) { >+ $countbr = $count; >+ $template->param( query => $query, drafts_only => $drafts_only ); > } > > my $schema = Koha::Database->new()->schema(); >diff --git a/installer/data/mysql/atomicupdate/add_draft_record_batch.sql b/installer/data/mysql/atomicupdate/add_draft_record_batch.sql >index 0432d25..b69e9aa 100644 >--- a/installer/data/mysql/atomicupdate/add_draft_record_batch.sql >+++ b/installer/data/mysql/atomicupdate/add_draft_record_batch.sql >@@ -1 +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'); >+INSERT INTO import_batches (import_batch_id,record_type,file_name,comments) VALUES (1, 'biblio', 'Draft record', '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/includes/cataloging-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cataloging-search.inc >index a289b70..fa1524c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/cataloging-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cataloging-search.inc >@@ -6,7 +6,12 @@ > <p class="tip">Search the catalog and the reservoir:</p> > <form name="search" action="addbooks.pl"> > <input class="head-searchbox" type="text" name="q" size="40" /> >+ <span class="filteraction" id="filteraction_off"> <a href="#">[-]</a></span> >+ <span class="filteraction" id="filteraction_on"> <a href="#">[+]</a></span> > <input type="submit" class="submit" value="Submit" /> >+ <div id="filters"> >+ <p><input type="checkbox" name="drafts_only" value=1>Drafts only</p> >+ </div> > </form> > </div> > >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 31c3659..1708241 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt >@@ -44,6 +44,7 @@ > </ul> > </div> > [% END %] >+ <a class="btn btn-default btn-sm" href="/cgi-bin/koha/cataloguing/draftrecords.pl">View Draft records</a></button> > [% IF ( total ) %] > <div class="btn-group"><button type="submit" class="btn btn-default btn-sm merge-items"><i class="fa fa-compress"></i> Merge selected</button></div> > [% END %] >@@ -142,7 +143,7 @@ > </table> > </div> > [% ELSE %] >- [% IF ( query ) %] >+ [% IF ( (query) && !(drafts_only) ) %] > [% IF ( error ) %]<div class="dialog alert">[% END %]<b>No results found</b> > [% IF ( error ) %] > Error: <span class="error">[% error %]</span></div> >@@ -151,8 +152,17 @@ > [% END %] > > [% IF ( query ) %] >+ [% IF ( drafts_only ) %] >+ <div> >+ <a href="#searchresult-breeding">[% breeding_count %] result(s) found in reservoir</a> >+ </div> >+ [% END %] > <div id="searchresult-breeding"> >- <h3>Biblios in reservoir</h3> >+ [% IF (drafts_only) %] >+ <h3>Draft records in reservoir</h3> >+ [% ELSE %] >+ <h3>Biblios in reservoir</h3> >+ [% END %] > [% IF ( breeding_loop ) %] > <table> > <tr> >@@ -170,7 +180,13 @@ > <td>[% breeding_loo.isbn %]</td> > <td>[% breeding_loo.copyrightdate %]</td> > <td>[% breeding_loo.edition %]</td> >- <td>[% breeding_loo.file %]</td> >+ <td> >+ [% IF breeding_loo.file == "Draft record" %] >+ Draft record >+ [% ELSE %] >+ [% breeding_loo.file %] >+ [% END %] >+ </td> > <td> > <div class="dropup"> > <a class="btn btn-default btn-xs dropdown-toggle" id="reservoirsearchactions[% breeding_loo.id %]" role="button" data-toggle="dropdown" href="#"> >@@ -180,7 +196,11 @@ > <li><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.id %]" class="previewData"><i class="fa fa-eye"></i> MARC preview</a></li> > <li><a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&importid=[% breeding_loo.id %]" class="previewData"><i class="fa fa-eye"></i> Card preview</a></li> > [% IF ( CAN_user_editcatalogue_edit_catalogue ) %] >- <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?breedingid=[% breeding_loo.id %]"><i class="fa fa-plus"></i> Continue editing draft record</a></li> >+ [% IF breeding_loo.file == "Draft record" %] >+ <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?breedingid=[% breeding_loo.id %]"><i class="fa fa-plus"></i> Continue editing draft record</a></li> >+ [% ELSE %] >+ <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?breedingid=[% breeding_loo.id %]"><i class="fa fa-plus"></i> Add biblio</a></li> >+ [% END %] > [% END %] > </ul> > </div> >@@ -220,6 +240,14 @@ > $(document).ready(function() { > //Set focus to cataloging search > $("input[name=q]:eq(0)").focus(); >+ $("#filteraction_off").hide(); >+ $("#filters").hide(); >+ >+ $("#filteraction_off, #filteraction_on").on('click', function(e) { >+ e.preventDefault(); >+ $('#filters').toggle(); >+ $('.filteraction').toggle(); >+ }); > > $("#z3950search").click(function(){ > PopupZ3950(""); >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 422bf74..e77ae50 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 >@@ -270,14 +270,6 @@ > [% END %] > </div> > [% END %] >-<div class="statictabs"> >- <ul> >- <li><a id="marcfileslink">Marc files</a></li> >- <li><a id="draftrecordslink" name="draft_record_to_display" value="1">Draft records</a></li> >- </ul> >- >- <div class="tabs-container"> >-<div id="marcfiles"> > <table> > <tr> > <th>#</th> >@@ -334,28 +326,6 @@ > </tr> > [% END %] > </table> >-</div> >- >-<div id="draftrecords" onload="document.getElementById("draftrecords").style.display ='none';"> >- <p> To edit or save these draft records click the 'Edit' link beside the appropriate record. </p> >- <table id="records-table"> >- <thead> >- <tr> >- <th>#</th> >- <th>Citation</th> >- <th>Status</th> >- <th>Match type</th> >- <th>Match details</th> >- <th><abbr title="Differences between the original biblio and the imported">Diff</abbr></th> >- <th>Record</th> >- <th>Catalog link</th> >- </tr> >- </thead> >- </table> >-</div> >-</div> >-</div> >- > [% IF ( pages ) %] > <div class="pages"> > [% FOREACH page IN pages %] >@@ -426,36 +396,10 @@ > $(this).parent().hide(); > }); > >- [% 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) %] >+ [% IF import_batch_id %] > $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, { >+ "bSort": true, >+ "order": [0, "desc"], > "bAutoWidth": false, > "bFilter": false, > "bProcessing": true, >@@ -471,15 +415,9 @@ > { "mDataProp": "match_citation" }, > { "mDataProp": "diff_url" }, > { "mDataProp": "matched" }, >- [% IF !(import_batch_id) %] { "mDataProp": "catalog_link" } [% END %] > ], >- [% 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 %] >+ "fnServerData": function ( sSource, aoData, fnCallback ) { >+ aoData.push( { "name": "import_batch_id", "value": [% import_batch_id %] } ); > $.ajax({ > 'dataType': 'json', > 'type': 'POST', >@@ -502,13 +440,17 @@ > ); > > $('td:eq(2)', nRow).html( >- aData['status'] == 'imported' ? _("Imported") : >- aData['status'] == 'ignored' ? _("Ignored") : >- aData['status'] == 'reverted' ? _("Reverted") : >- aData['status'] == 'staged' ? _("Staged") : >- aData['status'] == 'error' ? _("Error") : >+ aData['status'] == 'staged' ? _("Draft") : > aData['status'] > ); >+ $('td:eq(2)', nRow).html( >+ aData['status'] == 'imported' ? _("Imported") : >+ aData['status'] == 'ignored' ? _("Ignored") : >+ aData['status'] == 'reverted' ? _("Reverted") : >+ aData['status'] == 'staged' ? _("Staged") : >+ aData['status'] == 'error' ? _("Error") : >+ aData['status'] >+ ); > > $('td:eq(3)', nRow).html( > aData['overlay_status'] == 'no_match' ? _("No match") : >@@ -538,13 +480,6 @@ > '<a target="_blank" href="' + record_details_url > + aData['matched'] + '">' + aData['matched'] + '</a>' > ); >- [% IF !(import_batch_id) %] >- if (aData['catalog_link']){ >- $('td:eq(7)', nRow).html( >- '<a href="' + aData['catalog_link'] + '">' + "Edit" + '</a>' >- ); >- } >- [% END %] > }, > })); > $("#import_batch_form").on("submit",function(){ >diff --git a/tools/manage-marc-import.pl b/tools/manage-marc-import.pl >index 4fea400..76b88f9 100755 >--- a/tools/manage-marc-import.pl >+++ b/tools/manage-marc-import.pl >@@ -207,17 +207,19 @@ sub import_batches_list { > > my @list = (); > foreach my $batch (@$batches) { >- push @list, { >- import_batch_id => $batch->{'import_batch_id'}, >- num_records => $batch->{'num_records'}, >- num_items => $batch->{'num_items'}, >- upload_timestamp => $batch->{'upload_timestamp'}, >- import_status => $batch->{'import_status'}, >- file_name => $batch->{'file_name'} || "($batch->{'batch_type'})", >- comments => $batch->{'comments'}, >- can_clean => ($batch->{'import_status'} ne 'cleaned') ? 1 : 0, >- record_type => $batch->{'record_type'}, >- }; >+ if ( !($batch->{'import_batch_id'} == 1) ) { >+ push @list, { >+ import_batch_id => $batch->{'import_batch_id'}, >+ num_records => $batch->{'num_records'}, >+ num_items => $batch->{'num_items'}, >+ upload_timestamp => $batch->{'upload_timestamp'}, >+ import_status => $batch->{'import_status'}, >+ file_name => $batch->{'file_name'} || "($batch->{'batch_type'})", >+ comments => $batch->{'comments'}, >+ can_clean => ($batch->{'import_status'} ne 'cleaned') ? 1 : 0, >+ record_type => $batch->{'record_type'}, >+ }; >+ } > } > $template->param(batch_list => \@list); > my $num_batches = GetNumberOfNonZ3950ImportBatches(); >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20678
:
74922
|
74928
|
74929
|
74960
|
74961
|
74962
|
75192
|
75193
|
78021
|
78920
|
92248
|
107454
|
107472