Bugzilla – Attachment 92248 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 - Implemented a save marc as draft feature
Bug-20678---Implemented-a-save-marc-as-draft-featu.patch (text/plain), 43.51 KB, created by
Alex Buckley
on 2019-08-15 22:18:52 UTC
(
hide
)
Description:
Bug 20678 - Implemented a save marc as draft feature
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2019-08-15 22:18:52 UTC
Size:
43.51 KB
patch
obsolete
>From b48c458e992b9ac8da6afae36f0ff478ad7528a0 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Wed, 2 May 2018 14:28:31 +0000 >Subject: [PATCH] Bug 20678 - Implemented a save marc as draft feature > >This patch implements the ability to save marc records to the reservior >(in a similar way to how imported staged records are stored in the > reservior). > >The purpose of this feature is to be able to train junior library staff >and catalogers by letting them practise cataloging biblio records and saving them as drafts >(stored in the reservoir). Because these draft records are stored in the >reservoir they are not returned as OPAC search results. > >This patch implements a new 'editcatalogue' subpermission called 'commit_MARC_records_to_catalog'. A staff member must have this subpermission >enabled to commit a record to the catalog. > >In the addbiblio.pl interface users with all editcatalogue >subpermissions (which should be staff experienced with cataloging) will see 4 'Save' options: > >* Save and review record >* Save and edit items >* Save and continue editing >* Save without cataloging > >Junior staff should have all editcatalog subpermissions except for >'commit_MARC_records_to_catalog' and they will see one save option 'Save >without cataloging' and this saves the record as a draft. > >To view and administer all draft records you can click on the 'View >draft records' button in the toolbar on the addbooks.pl page. > >Here draft records are listed newest to oldest and individual draft records can be edited/deleted or all draft records >can be deleted in one go. > >Test plan: > >Test plan: >1. Go to addbooks.pl and notice there is no 'View draft reocrds' button >in the toolbar alongside 'New record' > >2. Apply patch > >3. Restart plack, memcached > >4. Update your database, this can be achieved by runnning >installer/data/mysql/updatedatabase.pl or in Koha staff client going to >Adminstration->Global system preferences->Local use and amending the >Version syspref value > >5. Create two user accounts one with superlibrarian permissions and the >other with all editcatalogue subpermissions except for >'commit_MARC_records_to_catalog' and also enable the catalogue >permission so this user can access the staff client. > >6. Log in as user 1 (superlibrarian) go to Cataloging->New record and >select the 'Save' dropdown box and notice you have 4 options. Select >'Save and view record' and notice you have created a biblio in the >catalog. > >7. Log out and log in as user 2 go to Cataloging->New record and >click the 'Save' button and notice that there is only one option 'Save >without cataloging'. Meaning you are restricted to only creating a draft >record. > >8. Select 'Save without cataloging' and you are re-directed to the >Cataloging main page. Now select the 'View draft records' button and >view your draft record in the table of draft records. > >9. Select the 'Edit' link and notice the addbiblio.pl page for the draft >record is loaded > >10. Return to the View draft records interface and delete the draft >record and notice that after the page reloads the record is no longer >displayed in the table. > >11. Create 2 more draft records and return to the View draft records >interface and select 'Delete all drafts from reservoir' and notice the >drafts table is emptied > >12. Create 1 more draft record and then log out > >13. Log in as user 1 (superlibrarian) and go to the View draft records >interface. > >14. Select the 'Edit' link > >15. Select any save option except for 'Save without cataloguing' and >notice the record is now committed to the catalog. > >16. Return to the 'View draft records' interface and notice the record >you just committed to the catalog has been removed as a draft record in >the reservoir. > >17. Run the unit test t/db_dependent/ImportBatch.t in koha-shell > >18. Notice that unit test 12 passes: 'ok 12 - No biblio expected since >we deleted the biblio from the batch' > >19. Log out and back in as the second user and search for a biblio >record which is in the catalog (i.e. not a draft record) and notice both >in the staff client search results and the biblio detail page the links >to edit the record and items associated with the biblio record are not >displayed. This is because the user you are logged in as has all >edit_catalogue permissions except >CAN_user_editcatalogue_commit_MARC_records_to_catalog which is >neccessary to add/edit/delete biblios or items in the catalog. > >Sponsored-By: Toi Ohomai Institute of Technology, New Zealand > >https://bugs.koha-community.org/show_bug.cgi?id=20678 >--- > C4/ImportBatch.pm | 18 +++ > cataloguing/addbiblio.pl | 12 +- > cataloguing/addbooks.pl | 48 +++++-- > cataloguing/batch_records_ajax.pl | 122 ++++++++++++++++++ > cataloguing/draftrecords.pl | 125 ++++++++++++++++++ > .../atomicupdate/bug_20678_save_draft_records.sql | 3 + > installer/data/mysql/sysprefs.sql | 1 + > .../intranet-tmpl/prog/en/includes/cat-toolbar.inc | 5 +- > .../prog/en/includes/cataloging-search.inc | 5 + > .../intranet-tmpl/prog/en/includes/permissions.inc | 4 + > .../prog/en/modules/catalogue/detail.tt | 4 +- > .../prog/en/modules/catalogue/results.tt | 4 +- > .../prog/en/modules/cataloguing/addbiblio.tt | 16 ++- > .../prog/en/modules/cataloguing/addbooks.tt | 33 ++++- > .../prog/en/modules/cataloguing/draftrecords.tt | 139 +++++++++++++++++++++ > t/db_dependent/ImportBatch.t | 8 +- > 16 files changed, 522 insertions(+), 25 deletions(-) > create mode 100755 cataloguing/batch_records_ajax.pl > create mode 100755 cataloguing/draftrecords.pl > create mode 100644 installer/data/mysql/atomicupdate/bug_20678_save_draft_records.sql > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/draftrecords.tt > >diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm >index 8d39ed2..dde8a3b 100644 >--- a/C4/ImportBatch.pm >+++ b/C4/ImportBatch.pm >@@ -45,6 +45,7 @@ BEGIN { > GetImportBatch > AddAuthToBatch > AddBiblioToBatch >+ DeleteBiblioInBatch > AddItemsToImportBiblio > ModAuthorityInBatch > ModBiblioInBatch >@@ -296,6 +297,15 @@ sub AddBiblioToBatch { > return $import_record_id; > } > >+=head2 DeleteBiblioInBatch >+ DeleteBiblioInBatch( $import_record_id ); >+=cut >+ >+sub DeleteBiblioInBatch { >+ my ($subroutine, $import_record_id) = @_; >+ _delete_import_record_marc($import_record_id); >+} >+ > =head2 ModBiblioInBatch > > ModBiblioInBatch($import_record_id, $marc_record); >@@ -1614,6 +1624,14 @@ sub _update_import_record_marc { > $sth->finish(); > } > >+sub _delete_import_record_marc { >+ my ($import_record_id, $subroutine) = @_; >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare("DELETE FROM import_records WHERE import_record_id = ?"); >+ $sth->execute($import_record_id); >+ $sth->finish(); >+} >+ > sub _add_auth_fields { > my ($import_record_id, $marc_record) = @_; > >diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl >index 00b2501..94c75ad 100755 >--- a/cataloguing/addbiblio.pl >+++ b/cataloguing/addbiblio.pl >@@ -698,7 +698,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') // q{}; >@@ -840,7 +840,15 @@ if ( $op eq "addbiblio" ) { > ModBiblio( $record, $biblionumber, $frameworkcode ); > } > else { >- ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode ); >+ if ($previewrecord) { >+ AddBiblioToBatch(1, 0, $record, 'biblio', int(rand(99999)), 1); >+ print $input->redirect('/cgi-bin/koha/cataloguing/addbooks.pl'); >+ } else { >+ if ($breedingid) { >+ C4::ImportBatch->DeleteBiblioInBatch($breedingid); >+ } >+ ( $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/cataloguing/addbooks.pl b/cataloguing/addbooks.pl >index 2082913..b863be7 100755 >--- a/cataloguing/addbooks.pl >+++ b/cataloguing/addbooks.pl >@@ -46,6 +46,7 @@ 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 $lang = C4::Languages::getlanguage($input); > >@@ -61,8 +62,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; >@@ -128,16 +129,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 only draft records will be returned to the template. $countbr must be based on the number of drafts in the reservoir >+if ($drafts_only) { >+ $countbr = $count; >+ $template->param( query => $query, drafts_only => $drafts_only ); > } > > my $servers = Koha::Z3950Servers->search( >diff --git a/cataloguing/batch_records_ajax.pl b/cataloguing/batch_records_ajax.pl >new file mode 100755 >index 0000000..a242881a >--- /dev/null >+++ b/cataloguing/batch_records_ajax.pl >@@ -0,0 +1,122 @@ >+#!/usr/bin/perl >+ >+# Copyright 2013 ByWater Solutions >+# Based on circ/ysearch.pl: Copyright 2007 Tamil s.a.r.l. >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+=head1 NAME >+ >+batch_records_ajax.pl - A script for searching batch imported records via ajax >+ >+=head1 SYNOPSIS >+ >+This script is to be used as a data source for DataTables that load and display >+the records from an import batch. >+ >+=cut >+ >+use Modern::Perl; >+ >+use CGI qw ( -utf8 ); >+use JSON qw/ to_json /; >+ >+use C4::Context; >+use C4::Charset; >+use C4::Auth qw/check_cookie_auth/; >+use C4::ImportBatch; >+ >+my $input = new CGI; >+ >+my @sort_columns = >+ qw/import_record_id title status overlay_status overlay_status/; >+ >+my $import_batch_id = $input->param('import_batch_id'); >+my $offset = $input->param('iDisplayStart'); >+my $results_per_page = $input->param('iDisplayLength'); >+my $sorting_column = $sort_columns[ $input->param('iSortCol_0') // 0 ]; >+my $sorting_direction = $input->param('sSortDir_0'); >+ >+$results_per_page = undef if $results_per_page && $results_per_page == -1; >+ >+binmode STDOUT, ":encoding(UTF-8)"; >+print $input->header( -type => 'text/plain', -charset => 'UTF-8' ); >+ >+my ( $auth_status, $sessionID ) = >+ check_cookie_auth( $input->cookie('CGISESSID'), { tools => 'manage_staged_marc' } ); >+if ( $auth_status ne "ok" ) { >+ exit 0; >+} >+ >+my $batch = GetImportBatch($import_batch_id); >+my $records = >+ GetImportRecordsRange( $import_batch_id, $offset, $results_per_page, undef, >+ { order_by => $sorting_column, order_by_direction => $sorting_direction } ); >+my @list = (); >+foreach my $record (@$records) { >+ my $citation = $record->{'title'} || $record->{'authorized_heading'}; >+ $citation .= " $record->{'author'}" if $record->{'author'}; >+ $citation .= " (" if $record->{'issn'} or $record->{'isbn'}; >+ $citation .= $record->{'isbn'} if $record->{'isbn'}; >+ $citation .= ", " if $record->{'issn'} and $record->{'isbn'}; >+ $citation .= $record->{'issn'} if $record->{'issn'}; >+ $citation .= ")" if $record->{'issn'} or $record->{'isbn'}; >+ >+ my $match = GetImportRecordMatches( $record->{'import_record_id'}, 1 ); >+ my $match_citation = ''; >+ my $match_id; >+ if ( $#$match > -1 ) { >+ if ( $match->[0]->{'record_type'} eq 'biblio' ) { >+ $match_citation .= $match->[0]->{'title'} >+ if defined( $match->[0]->{'title'} ); >+ $match_citation .= ' ' . $match->[0]->{'author'} >+ if defined( $match->[0]->{'author'} ); >+ $match_id = $match->[0]->{'biblionumber'}; >+ } >+ elsif ( $match->[0]->{'record_type'} eq 'auth' ) { >+ if ( defined( $match->[0]->{'authorized_heading'} ) ) { >+ $match_citation .= $match->[0]->{'authorized_heading'}; >+ $match_id = $match->[0]->{'candidate_match_id'}; >+ } >+ } >+ } >+ >+ push @list, >+ { >+ DT_RowId => $record->{'import_record_id'}, >+ import_record_id => $record->{'import_record_id'}, >+ citation => $citation, >+ status => $record->{'status'}, >+ overlay_status => $record->{'overlay_status'}, >+ match_citation => $match_citation, >+ matched => $record->{'matched_biblionumber'} >+ || $record->{'matched_authid'} >+ || 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, >+ catalog_link => "/cgi-bin/koha/cataloguing/addbiblio.pl?breedingid=$record->{import_record_id}", >+ delete_link =>"/cgi-bin/koha/cataloguing/draftrecords.pl?biblionumber=$record->{import_record_id}&op=delete_record", >+ }; >+} >+ >+my $data; >+$data->{'iTotalRecords'} = $batch->{'num_records'}; >+$data->{'iTotalDisplayRecords'} = $batch->{'num_records'}; >+$data->{'sEcho'} = $input->param('sEcho') || undef; >+$data->{'aaData'} = \@list; >+ >+print to_json($data); >diff --git a/cataloguing/draftrecords.pl b/cataloguing/draftrecords.pl >new file mode 100755 >index 0000000..2dcf446 >--- /dev/null >+++ b/cataloguing/draftrecords.pl >@@ -0,0 +1,125 @@ >+#!/usr/bin/perl >+ >+# Copyright 2018 Catalyst IT >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+=head1 cataloguing:draftrecords.pl >+ >+ TODO >+ >+=cut >+ >+use strict; >+use warnings; >+use CGI qw ( -utf8 ); >+use C4::Auth; >+use C4::Biblio; >+use C4::Breeding; >+use C4::Output; >+use C4::Koha; >+use C4::Search; >+use C4::ImportBatch; >+ >+use Koha::BiblioFrameworks; >+use Koha::SearchEngine::Search; >+use Koha::SearchEngine::QueryBuilder; >+ >+my $input = new CGI; >+ >+my $success = $input->param('biblioitem'); >+my $query = $input->param('q'); >+my @value = $input->multi_param('value'); >+my $page = $input->param('page') || 1; >+my $biblionumber= $input->param('biblionumber'); >+my $op = $input->param('op'); >+my $results_per_page = 20; >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "cataloguing/draftrecords.tt", >+ query => $input, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { editcatalogue => '*' }, >+ debug => 1, >+ } >+); >+ >+# fill with books in breeding farm >+ >+my $countbr = 0; >+my @resultsbr; >+if ($query) { >+# fill isbn or title, depending on what has been entered >+#u must do check on isbn because u can find number in beginning of title >+#check is on isbn legnth 13 for new isbn and 10 for old isbn >+ my ( $title, $isbn ); >+ if ($query=~/\d/) { >+ my $clean_query = $query; >+ $clean_query =~ s/-//g; # remove hyphens >+ my $querylength = length $clean_query; >+ if ( $querylength == 13 || $querylength == 10 ) { >+ $isbn = $query; >+ } >+ } >+ if (!$isbn) { >+ $title = $query; >+ } >+ ( $countbr, @resultsbr ) = BreedingSearch( $title, $isbn ); >+} >+ >+if ($op && $op eq 'delete_record') { >+ C4::ImportBatch->DeleteBiblioInBatch($biblionumber); >+} elsif ($op && $op eq 'delete_all') { >+ CleanBatch(1); >+} >+ >+ >+my $breeding_loop = []; >+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}, >+ }; >+} >+ >+my $schema = Koha::Database->new()->schema(); >+my $servers = $schema->resultset('Z3950server')->search( >+ { >+ recordtype => 'biblio', >+ servertype => ['zed', 'sru'], >+ }, >+ { result_class => 'DBIx::Class::ResultClass::HashRefInflator', >+ order_by => ['rank', 'servername'], >+ }, >+); >+ >+my $frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] }); >+$template->param( >+ servers => $servers, >+ frameworks => $frameworks, >+ breeding_count => $countbr, >+ breeding_loop => $breeding_loop, >+ z3950_search_params => C4::Search::z3950_search_args($query), >+); >+ >+output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/installer/data/mysql/atomicupdate/bug_20678_save_draft_records.sql b/installer/data/mysql/atomicupdate/bug_20678_save_draft_records.sql >new file mode 100644 >index 0000000..554396c >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_20678_save_draft_records.sql >@@ -0,0 +1,3 @@ >+INSERT IGNORE 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'); >+INSERT IGNORE INTO permissions (module_bit, code, description) VALUES (9, 'commit_MARC_records_to_catalog', 'Commit MARC records to the catalog. If not enabled then a patron will only be able to create draft records if other editcatalogue subpermissions are enabled'); >+INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('EnableDraftRecords', 1, NULL, 'If enabled staff and catalogers will be able to save records to the reservoir as a draft rather than to the catalog. Also the link to the draft records interface in the Cataloguing module will be visible', 'YesNo'); >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 82a8402..23f2042 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -164,6 +164,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('EmailPurchaseSuggestions','0','0|EmailAddressForSuggestions|BranchEmailAddress|KohaAdminEmailAddress','Choose email address that new purchase suggestions will be sent to: ','Choice'), > ('EnableAdvancedCatalogingEditor','0','','Enable the Rancor advanced cataloging editor','YesNo'), > ('EnableBorrowerFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'), >+('EnableDraftRecords', 1, NULL, 'If enabled staff and catalogers will be able to save records to the reservoir as a draft rather than to the catalog. Also the link to the draft records interface in the Cataloguing module will be visible', 'YesNo'), > ('EnableOpacSearchHistory','1','YesNo','Enable or disable opac search history',''), > ('EnableSearchHistory','0','','Enable or disable search history','YesNo'), > ('EnhancedMessagingPreferences','1','','If ON, allows patrons to select to receive additional messages about items due or nearly due.','YesNo'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc >index 7ab50f5..35833a0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc >@@ -1,8 +1,7 @@ > [% INCLUDE 'blocking_errors.inc' %] > <div id="toolbar" class="btn-toolbar"> > >-[% IF ( CAN_user_editcatalogue_edit_catalogue || CAN_user_editcatalogue_edit_items || >-CAN_user_serials_create_subscription ) %] >+[% IF CAN_user_editcatalogue_commit_MARC_records_to_catalog && (CAN_user_editcatalogue_edit_catalogue || CAN_user_editcatalogue_edit_items || CAN_user_serials_create_subscription) %] > <div class="btn-group"> > <button class="btn btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> New <span class="caret"></span></button> > <ul class="dropdown-menu"> >@@ -27,7 +26,7 @@ CAN_user_serials_create_subscription ) %] > </div> > [% END %] > >-[% IF ( CAN_user_editcatalogue_edit_catalogue || CAN_user_editcatalogue_edit_items || CAN_user_tools_items_batchmod || CAN_user_tools_items_batchdel ) or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) %] >+[% IF ((CAN_user_editcatalogue_commit_MARC_records_to_catalog) and (( CAN_user_editcatalogue_edit_catalogue || CAN_user_editcatalogue_edit_items || CAN_user_tools_items_batchmod || CAN_user_tools_items_batchdel ) or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ))) %] > <div class="btn-group"> > <button class="btn btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-pencil"></i> Edit <span class="caret"></span></button> > <ul class="dropdown-menu"> >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 d979f69..527193c 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/includes/permissions.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc >index 26f779a..148c922 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc >@@ -291,6 +291,10 @@ > Fast cataloging > </span> > <span class="permissioncode">([% name | html %])</span> >+ [%- CASE 'commit_MARC_records_to_catalog' -%] >+ <span class="sub_permission commit_MARC_records_to_catalog"> >+ Commit MARC records to the catalog. If not enabled then a patron will only be able to create draft records if other editcatalogue subpermissions are enabled >+ </span> > [%- CASE 'remaining_permissions' -%] > <span class="sub_permission remaining_permissions_subpermission"> > Remaining permissions for managing fines and fees >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >index 3819628..77a4a6c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -213,7 +213,7 @@ > [% IF ( hostrecords ) %]<th>Host records</th>[% END %] > [% IF ( analyze ) %]<th>Used in</th><th></th>[% END %] > [% IF ( ShowCourseReserves ) %]<th>Course Reserves</th>[% END %] >- [% IF ( CAN_user_editcatalogue_edit_items ) %]<th class="NoSort"> </th>[% END %] >+ [% IF ( CAN_user_editcatalogue_commit_MARC_records_to_catalog && CAN_user_editcatalogue_edit_items ) %]<th class="NoSort"> </th>[% END %] > </tr> > </thead> > <tbody> >@@ -400,7 +400,7 @@ > [% END %] > </td> > [% END %] >- [% IF CAN_user_editcatalogue_edit_items %] >+ [% IF CAN_user_editcatalogue_commit_MARC_records_to_catalog && CAN_user_editcatalogue_edit_items %] > <td class="actions"> > [% UNLESS item.cannot_be_edited %] > <a class="btn btn-default btn-xs" href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=[% item.biblionumber | html %]&itemnumber=[% item.itemnumber | html %]#edititem"><i class="fa fa-pencil"></i> Edit</a> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >index c8af35f..3ead3be 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >@@ -439,10 +439,10 @@ > | <a id="requst_article_[% SEARCH_RESULT.biblionumber | html %]" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% SEARCH_RESULT.biblionumber | html %]">Request article</a> > [% END %] > >- [% IF ( CAN_user_editcatalogue_edit_catalogue ) %] >+ [% IF ( CAN_user_editcatalogue_commit_MARC_records_to_catalog && CAN_user_editcatalogue_edit_catalogue ) %] > | <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% SEARCH_RESULT.biblionumber | uri %]">Edit record</a> > [% END %] >- [% IF ( CAN_user_editcatalogue_edit_items ) %] >+ [% IF ( CAN_user_editcatalogue_commit_MARC_records_to_catalog && CAN_user_editcatalogue_edit_items ) %] > | <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% SEARCH_RESULT.biblionumber | uri %]">Edit items</a> > [% END %] > >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 635b6cc..82138f8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >@@ -92,6 +92,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"); >@@ -524,9 +531,12 @@ > <span class="caret"></span> > </button> > <ul class="dropdown-menu"> >- <li><a id="saveandview" href="#">Save and view record</a></li> >- <li><a id="saveanditems" href="#">Save and edit items</a></li> >- <li><a id="saveandcontinue" href="#">Save and continue editing</a></li> >+ [% IF CAN_user_editcatalogue_commit_MARC_records_to_catalog %] >+ <li><a id="saveandview" href="#">Save and view record</a></li> >+ <li><a id="saveanditems" href="#">Save and edit items</a></li> >+ <li><a id="saveandcontinue" href="#">Save and continue editing</a></li> >+ [% END %] >+ <li><a id="previewrecord" name="previewrecord" href="#">Save as draft</a></li> > </ul> > </div> > [% 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 90f80bf..dfbaec9 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 # /IF servers.count %] >+ <a class="btn btn-default btn-sm" href="/cgi-bin/koha/cataloguing/draftrecords.pl"><i class="fa fa-eye" aria-hidden="true"></i> View draft records</a></button> > [% IF ( total ) %] > <div class="btn-group"><button type="submit" class="btn btn-default merge-items"><i class="fa fa-compress"></i> Merge selected</button></div> > [% END %] >@@ -155,8 +156,18 @@ > [% END # /IF total %] > > [% IF ( query ) %] >+ [% IF (drafts_only) %] >+ <div> >+ <a href="#searchresult-breeding">[% breeding_count %] result(s) found in reservoir</a> >+ </div> >+ [% END %] > <div id="searchresult-breeding"> >+ [% IF (drafts_only) %] >+ <h3>Draft records in reservoir</h3> >+ [% ELSE %] > <h3>Biblios in reservoir</h3> >+ [% END %] >+ > [% IF ( breeding_loop ) %] > <table> > <tr> >@@ -178,6 +189,13 @@ > <td>[% breeding_loo.edition | html %]</td> > <td>[% breeding_loo.file | html %]</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 | html %]" role="button" data-toggle="dropdown" href="#"> > Actions <b class="caret"></b> >@@ -186,7 +204,11 @@ > <li><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.id | uri %]" 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 | uri %]" 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 | uri %]"><i class="fa fa-plus"></i> Add biblio</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> >@@ -226,6 +248,15 @@ > //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(""); > return false; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/draftrecords.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/draftrecords.tt >new file mode 100644 >index 0000000..a34bf98 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/draftrecords.tt >@@ -0,0 +1,139 @@ >+[% SET footerjs = 1 %] >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Cataloging › Draft records</title> >+[% INCLUDE 'doc-head-close.inc' %] >+[% INCLUDE 'browser-strings.inc' %] >+<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" /> >+<style type="text/css"> >+ #jobpanel,#jobstatus,#jobfailed { display : none; } >+ span.change-status { font-style:italic; color:#666; display:none; } >+</style> >+</head> >+<body class="cat"> >+ [% INCLUDE 'header.inc' %] >+ <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloguing</a> › View draft records</div> >+ <div id="doc" class="yui-t2"> >+ <div id="bd"> >+ <div id="yui-main"> >+ [% IF ( CAN_user_editcatalogue_edit_catalogue ) %] >+ <div id="toolbar" class="btn-toolbar"> >+ [% IF Koha.Preference( 'EnableAdvancedCatalogingEditor' ) == 1 %] >+ <a id="useadvanced" href="/cgi-bin/koha/cataloguing/editor.pl" class="btn btn-default btn-sm"><i class="fa fa-pencil"></i> Advanced editor</a> >+ [% END %] >+ <div class="btn-group"> >+ <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> New record <span class="caret"></span></button> >+ <ul class="dropdown-menu"> >+ <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?frameworkcode=">Default framework</a></li> >+ [% FOREACH framework IN frameworks %] >+ <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?frameworkcode=[% framework.frameworkcode %]">[% framework.frameworktext %]</a></li> >+ [% END %] >+ </ul> >+ </div> >+ [% IF servers.count > 0 %] >+ <div class="btn-group"> >+ <button class="btn btn-default btn-sm" id="z3950search"><i class="fa fa-search"></i> New from Z39.50/SRU</button> >+ <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"> >+ <span class="caret"></span> >+ </button> >+ <ul class="dropdown-menu"> >+ <li id="" class="z3950searchFw"><a href="#">Default framework</a></li> >+ [% FOREACH framework IN frameworks %] >+ <li id="[% framework.frameworkcode %]" class="z3950searchFw"><a href="#">[% framework.frameworktext %]</a></li> >+ [% END %] >+ </ul> >+ </div> >+ [% END %] >+ <a class="btn btn-default btn-sm" href="/cgi-bin/koha/cataloguing/draftrecords.pl"><i class="fa fa-eye" aria-hidden="true"></i> 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 %] >+ </div> >+ [% END %] >+ <h1>View draft records</h1> >+ <div id="draftrecords"> >+ <p> To edit or save these draft records click the 'Edit' link beside the appropriate record. >+ <form action="/cgi-bin/koha/cataloguing/draftrecords.pl" method="post"> >+ <input type="hidden" name="op" id="delete_all_drafts" value='delete_all'/> >+ <button type="submit">Delete all drafts from reservoir</button> >+ </form> >+ </p> >+ <table id="records-table"> >+ <thead> >+ <tr> >+ <th>#</th> >+ <th>Citation</th> >+ <th>Status</th> >+ <th>Edit record</th> >+ <th>Delete record</th> >+ </tr> >+ </thead> >+ </table> >+ </div> >+ </div> >+ </div> >+ </div> >+</body> >+[% MACRO jsinclude BLOCK %] >+<script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu_[% KOHA_VERSION %].js"></script> >+<script type="text/javascript" src="[% interface %]/[% theme %]/js/background-job-progressbar_[% KOHA_VERSION %].js"></script> >+[% INCLUDE 'datatables.inc' %] >+<script type="text/javascript"> >+ $(document).ready(function(){ >+ $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, { >+ "bSort": true, >+ "order": [0, "desc"], >+ "bAutoWidth": false, >+ "bFilter": false, >+ "bProcessing": true, >+ "bServerSide": true, >+ "sAjaxSource": 'batch_records_ajax.pl', >+ "sPaginationType": "full_numbers", >+ "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">', >+ "aoColumns": [ >+ { "mDataProp": "import_record_id" }, >+ { "mDataProp": "citation" }, >+ { "mDataProp": "status" }, >+ { "mDataProp": "catalog_link" }, >+ { "mDataProp": "delete_link" } >+ ], >+ "fnServerData": function ( sSource, aoData, fnCallback ) { >+ aoData.push( { "name": "import_batch_id", "value": 1 } ); >+ $.ajax({ >+ 'dataType': 'json', >+ 'type': 'POST', >+ 'url': sSource, >+ 'data': aoData, >+ 'success': function(json){ >+ fnCallback(json); >+ } >+ }); >+ }, >+ "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) { >+ [% IF ( record_type == 'auth' ) %] >+ var record_details_url = "/cgi-bin/koha/authorities/detail.pl?authid="; >+ [% ELSE %] >+ var record_details_url = "/cgi-bin/koha/catalogue/detail.pl?biblionumber="; >+ [% END %] >+ $('td:eq(1)', nRow).html( >+ '<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData['import_record_id'] + '&viewas=html" class="previewMARC">' + aData['citation'] + '</a>' >+ ); >+ $('td:eq(2)', nRow).html( >+ aData['status'] == 'staged' ? _("Draft") : >+ aData['status'] >+ ); >+ if (aData['catalog_link']){ >+ $('td:eq(3)', nRow).html( >+ '<a href="' + aData['catalog_link'] + '">' + "Edit" + '</a>' >+ ); >+ } >+ if (aData['delete_link']){ >+ $('td:eq(4)', nRow).html( >+ '<a href="' + aData['delete_link'] + '">' + "Delete" + '</a>' >+ ); >+ } >+ }, >+ })); >+ }); >+</script> >+[% END %] >+[% INCLUDE 'intranet-bottom.inc' %] >diff --git a/t/db_dependent/ImportBatch.t b/t/db_dependent/ImportBatch.t >index 66ffcf9..08a51a9 100644 >--- a/t/db_dependent/ImportBatch.t >+++ b/t/db_dependent/ImportBatch.t >@@ -1,8 +1,9 @@ > #!/usr/bin/perl > > use Modern::Perl; >-use Test::More tests => 14; >+use Test::More tests => 15; > use File::Basename; >+use Cwd qw(abs_path); > use File::Temp qw/tempfile/; > > use t::lib::Mocks; >@@ -143,6 +144,11 @@ $dbh->do( "DELETE FROM items WHERE itemnumber=?", undef, $itemno ); > is( @a, 0, 'No item numbers expected since we deleted the item' ); > $dbh->do( $sql, undef, undef, $import_record_id ); # remove link again > >+#Test DeleteBiblioInBatch >+my @a = DeleteBiblioInBatch( $import_record_id); #Remove the MARC record from import_biblios and import_records tables >+my $biblio_in_import_records = $dbh->do('SELECT * FROM import_records WHERE import_batch_id = "$import_record_id"'); >+is( $biblio_in_import_records, "0E0", 'No biblio expected since we deleted the biblio from the batch' ); >+ > # fresh data > my $sample_import_batch3 = { > matcher_id => 3, >-- >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