Bugzilla – Attachment 167231 Details for
Bug 36975
Allow MarcModificationTemplates to change the record source for a batch of records
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36975 : set record source in modifications templates
Bug-36975--set-record-source-in-modifications-temp.patch (text/plain), 10.28 KB, created by
Arthur Suzuki
on 2024-05-28 21:15:32 UTC
(
hide
)
Description:
Bug 36975 : set record source in modifications templates
Filename:
MIME Type:
Creator:
Arthur Suzuki
Created:
2024-05-28 21:15:32 UTC
Size:
10.28 KB
patch
obsolete
>From 9533f6355db6679a3541fdb1aa05f07a2b68f9d7 Mon Sep 17 00:00:00 2001 >From: Arthur Suzuki <arthur.suzuki@biblibre.com> >Date: Tue, 28 May 2024 00:38:36 +0200 >Subject: [PATCH] Bug 36975 : set record source in modifications templates > >--- > C4/MarcModificationTemplates.pm | 8 ++++++ > .../data/mysql/atomicupdate/bug_36975.pl | 13 +++++++++ > .../tools/marc_modification_templates.tt | 27 ++++++++++++++++--- > .../prog/js/marc_modification_templates.js | 10 ++++++- > tools/marc_modification_templates.pl | 14 ++++++---- > 5 files changed, 62 insertions(+), 10 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_36975.pl > >diff --git a/C4/MarcModificationTemplates.pm b/C4/MarcModificationTemplates.pm >index 13b81ca0b41..9088773d062 100644 >--- a/C4/MarcModificationTemplates.pm >+++ b/C4/MarcModificationTemplates.pm >@@ -32,6 +32,7 @@ use Koha::SimpleMARC qw( > move_field > update_field > ); >+use Koha::Biblios; > use Koha::MoreUtils; > use Koha::DateUtils qw( dt_from_string ); > >@@ -698,6 +699,13 @@ sub ModifyRecordWithTemplate { > field_numbers => $field_numbers, > }); > } >+ elsif ( $action eq 'set_record_source' ) { >+ my $biblionumber = $record->subfield('999', 'c'); >+ return unless $biblionumber; >+ my $biblio = Koha::Biblios->find($biblionumber); >+ return unless $biblio; >+ $biblio->metadata->set({record_source_id => $field_value})->store; >+ } > } > } > >diff --git a/installer/data/mysql/atomicupdate/bug_36975.pl b/installer/data/mysql/atomicupdate/bug_36975.pl >new file mode 100644 >index 00000000000..705b561aa1c >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_36975.pl >@@ -0,0 +1,13 @@ >+use Modern::Perl; >+ >+return { >+ bug_number => "36975", >+ description => "Add set_record_source action to marc_modification_templates_action table", >+ up => sub { >+ my ($args) = @_; >+ my ( $dbh, $out ) = @$args{qw(dbh out)}; >+ >+ $dbh->do(q{ALTER TABLE `marc_modification_template_actions` MODIFY COLUMN `action` enum('delete_field', 'add_field', 'update_field', 'move_field', 'copy_field', 'copy_and_replace_field', 'set_record_source') NOT NULL AFTER `ordering`;}); >+ say $out "Added new action type 'set_record_source'"; >+ }, >+}; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt >index f2eecda2938..082a6ffde6a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt >@@ -162,6 +162,15 @@ > > <td>[% ActionsLoo.ordering | html %]</td> > <td> >+ [% IF ( ActionsLoo.action_set_record_source ) %] >+ <span>Set record source</span> >+ <span>with value</span> >+ [% FOREACH source IN RecordSources %] >+ [% IF ( source.record_source_id == ActionsLoo.field_value ) %] >+ <em>[% source.name | html %]</em> >+ [% END %] >+ [% END %] >+ [% ELSE %] > [% IF ( ActionsLoo.action_delete_field ) %] <span>Delete</span> [% END %] > [% IF ( ActionsLoo.action_add_field ) %] <span>Add new</span> [% END %] > [% IF ( ActionsLoo.action_update_field ) %] <span>Update existing or add new</span> [% END %] >@@ -174,9 +183,9 @@ > <span>1st</span> > [% END %] > [% END %] >- >+ > <span>field</span> >- >+ > [% ActionsLoo.from_field | html %][% IF ( ActionsLoo.from_subfield.length ) %]$[% ActionsLoo.from_subfield | html %][% END %] > > [% IF ( ActionsLoo.field_value ) %] >@@ -190,7 +199,7 @@ > <span>using RegEx</span> s<strong>/[% ActionsLoo.to_regex_search | html %]/[% ActionsLoo.to_regex_replace | html %]/[% ActionsLoo.to_regex_modifiers | html %]</strong> > [% END %] > [% END %] >- >+ [% END %] > [% IF ( ActionsLoo.conditional ) %] > [% IF ( ActionsLoo.conditional_if ) %] <span>if</span> [% END %] > [% IF ( ActionsLoo.conditional_unless ) %] <span>unless</span> [% END %] >@@ -244,6 +253,7 @@ > <option value="move_field">Move</option> > <option value="copy_field">Copy</option> > <option value="copy_and_replace_field">Copy and replace</option> >+ <option value="set_record_source">Set record source</option> > </select> > > <span id="field_number_block"> >@@ -252,12 +262,21 @@ > <option value="1">1st</option> > </select> > </span> >- >+ <span id="from_field_block"> > field(s) <input type="text" name="from_field" id="from_field" size="3" maxlength="3" /> <input type="text" name="from_subfield" id="from_subfield" size="1" maxlength="1" title="let blank for the entire field" /> >+ </span> > > <span name="with_value_block" id="with_value_block" style="display:none;"> > with value <input type="text" name="field_value" id="field_value" /> > </span> >+ <span name="source_selector" id="source_selector" style="display:none;"> >+ <select id="record_source_id" name="record_source_id"> >+ <option value=''>No specified source</option> >+ [% FOREACH source IN RecordSources %] >+ <option value=[% source.record_source_id %]>[% source.name %]</option> >+ [% END %] >+ </select> >+ </span> > > <span name="to_field_block" id="to_field_block" style="display:none;"> > to field <input type="text" name="to_field" id="to_field" size="3" maxlength="3" /> <input type="text" name="to_subfield" id="to_subfield" size="1" maxlength="1" title="let blank for the entire field" /> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js b/koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js >index 39dfd7226d7..650c117542b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js >@@ -38,7 +38,7 @@ $(document).ready(function() { > return false; > } > } >- if ( $("#from_field").val().length <= 0 ) { >+ if ( action != 'set_record_source' && $("#from_field").val().length <= 0 ) { > alert( __("The source field should be filled.") ); > return false; > } >@@ -172,6 +172,14 @@ function onActionChange(selectObj) { > show('to_field_block'); > break; > >+ case 'set_record_source': >+ hide('field_number_block'); >+ hide('from_field_block'); >+ hide('to_field_block'); >+ hide('with_value_block'); >+ show('source_selector'); >+ break; >+ > } > } > >diff --git a/tools/marc_modification_templates.pl b/tools/marc_modification_templates.pl >index 6105d74c15a..a226e5aacf1 100755 >--- a/tools/marc_modification_templates.pl >+++ b/tools/marc_modification_templates.pl >@@ -19,7 +19,7 @@ > use Modern::Perl; > > use CGI qw ( -utf8 ); >- >+use Koha::RecordSources; > use C4::Auth qw( get_template_and_user ); > use C4::Output qw( output_html_with_http_headers ); > use C4::MarcModificationTemplates qw( >@@ -75,8 +75,10 @@ if ( $op eq "cud-create_template" ) { > my $conditional_value = $cgi->param('conditional_value'); > my $conditional_regex = ( $cgi->param('conditional_regex') eq 'on' ) ? 1 : 0; > my $description = $cgi->param('description'); >- >- if ($from_field) { >+ $field_value = $cgi->param('record_source_id') >+ if ($action eq 'set_record_source'); >+ >+ if ($from_field or $action eq 'set_record_source') { > unless ($mmta_id) { > AddModificationTemplateAction( > $template_id, $action, >@@ -127,7 +129,7 @@ foreach my $action ( @actions ) { > $action->{'action_move_field'} = ( $action->{'action'} eq 'move_field' ); > $action->{'action_copy_field'} = ( $action->{'action'} eq 'copy_field' ); > $action->{'action_copy_and_replace_field'} = ( $action->{'action'} eq 'copy_and_replace_field' ); >- >+ $action->{'action_set_record_source'} = ( $action->{'action'} eq 'set_record_source' ); > if( defined $action->{'conditional'} ){ > $action->{'conditional_if'} = ( $action->{'conditional'} eq 'if' ); > $action->{'conditional_unless'} = ( $action->{'conditional'} eq 'unless' ); >@@ -141,10 +143,12 @@ foreach my $action ( @actions ) { > } > } > >+my $record_sources = Koha::RecordSources->search(); >+ > $template->param( > TemplatesLoop => \@templates, > ActionsLoop => \@actions, >- >+ RecordSources => $record_sources, > template_id => $template_id, > ); > >-- >2.39.2
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 36975
: 167231 |
168014
|
178726