Bug 14098: Add copy_and_replace action to MMT
authorJonathan Druart <jonathan.druart@koha-community.org>
Wed, 27 May 2015 11:38:38 +0000 (13:38 +0200)
committerTomas Cohen Arazi <tomascohen@theke.io>
Mon, 7 Sep 2015 14:17:13 +0000 (11:17 -0300)
This patch add the new value for the MTT action.
It updates the marc_modification_template_actions.action DB field to
allow 'copy_and_replace_field'.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
installer/data/mysql/atomicupdate/Bug-14098-Add_copy_and_replace_action.sql [new file with mode: 0644]
koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt
tools/marc_modification_templates.pl

diff --git a/installer/data/mysql/atomicupdate/Bug-14098-Add_copy_and_replace_action.sql b/installer/data/mysql/atomicupdate/Bug-14098-Add_copy_and_replace_action.sql
new file mode 100644 (file)
index 0000000..bfee4e1
--- /dev/null
@@ -0,0 +1 @@
+alter table marc_modification_template_actions modify column action enum('delete_field','update_field','move_field','copy_field','copy_and_replace_field');
index 6c26d83..5cbc88d 100644 (file)
@@ -14,7 +14,7 @@ $(document).ready(function() {
 
     $("#add_action").submit(function(){
         var action = $("#action").val();
-        if ( action == 'move_field' || action == 'copy_field' ) {
+        if ( action == 'move_field' || action == 'copy_field' || action == 'copy_and_replace_field') {
             if ( $("#from_subfield").val().length != $("#to_subfield").val().length ) {
                 alert(_("Both subfield values should be filled or empty."));
                 return false;
@@ -96,6 +96,12 @@ function onActionChange(selectObj) {
             show('to_field_block');
             break;
 
+        case 'copy_and_replace_field':
+            show('field_number_block');
+            hide('with_value_block');
+            show('to_field_block');
+            break;
+
     }
 }
 
@@ -375,6 +381,7 @@ function setSelectByValue( selectId, value ) {
                                     [% IF ( ActionsLoo.action_update_field ) %] Update [% END %]
                                     [% IF ( ActionsLoo.action_move_field ) %] Move [% END %]
                                     [% IF ( ActionsLoo.action_copy_field ) %] Copy [% END %]
+                                    [% IF ( ActionsLoo.action_copy_and_replace_field ) %] Copy and replace [% END %]
 
                                     [% UNLESS ( ActionsLoo.action_update_field ) %]
                                         [% IF ( ActionsLoo.field_number ) %]
@@ -455,6 +462,7 @@ function setSelectByValue( selectId, value ) {
                             <option value="update_field">Add/Update</option>
                             <option value="move_field">Move</option>
                             <option value="copy_field">Copy</option>
+                            <option value="copy_and_replace_field">Copy and replace</option>
                         </select>
 
                         <span id="field_number_block">
index 31c663b..10589e4 100755 (executable)
@@ -124,6 +124,7 @@ foreach my $action ( @actions ) {
   $action->{'action_update_field'} = ( $action->{'action'} eq 'update_field' );
   $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->{'conditional_if'} = ( $action->{'conditional'} eq 'if' );
   $action->{'conditional_unless'} = ( $action->{'conditional'} eq 'unless' );