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 8b28e90629..082c77e88d 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 @@ -18,19 +18,45 @@ //]]> + [% INCLUDE 'header.inc' %] [% INCLUDE 'cat-search.inc' %] - +[% IF ( TemplatesLoop ) %] + [% FOREACH TemplatesLoo IN TemplatesLoop %] + [% IF ( TemplatesLoo.selected ) %] + [% SET template_name = TemplatesLoo.name %] + [% END %] + [% END %] +[% END %] + +
-

MARC modification templates

+ +
+ New template + [% IF ( template_id != '' ) %] + New action + [% END %] +
[% IF error %] [% IF error == 'no_from_field' %] @@ -40,246 +66,278 @@ [% IF ( TemplatesLoop ) %] -
- - - - -
+ [% IF ( template_id == '' ) %] -
- - - -
+

MARC modification templates [% template_id %]

- - [% IF ( ActionsLoop ) %] - - - - - - - - - - - - - [% FOREACH ActionsLoo IN ActionsLoop %] +
Actions for this template
Change orderOrderActionDescription  
+ - - - - - - - + + - [% END %] + + + [% FOREACH TemplatesLoo IN TemplatesLoop %] + + + + + [% END %] +
- - Go up - - - - Go top - - - - Go bottom - - - - Go down - - [% ActionsLoo.ordering %] - [% IF ( ActionsLoo.action_delete_field ) %] Delete [% END %] - [% 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 ) %] - 1st - [% END %] - [% END %] - - field - - [% ActionsLoo.from_field %][% IF ( ActionsLoo.from_subfield ) %]$[% ActionsLoo.from_subfield %][% END %] - - [% IF ( ActionsLoo.field_value ) %] - with value [% ActionsLoo.field_value %] - [% END %] - - [% IF ( ActionsLoo.to_field ) %] - to [% ActionsLoo.to_field %][% IF ( ActionsLoo.to_subfield ) %]$[% ActionsLoo.to_subfield %][% END %] - - [% IF ( ActionsLoo.to_regex_search ) %] - using RegEx s/[% ActionsLoo.to_regex_search %]/[% ActionsLoo.to_regex_replace %]/[% ActionsLoo.to_regex_modifiers %] - [% END %] - [% END %] - - [% IF ( ActionsLoo.conditional ) %] - [% IF ( ActionsLoo.conditional_if ) %] if [% END %] - [% IF ( ActionsLoo.conditional_unless ) %] unless [% END %] - - [% ActionsLoo.conditional_field %][% IF ( ActionsLoo.conditional_subfield ) %]$[% ActionsLoo.conditional_subfield %][% END %] - - [% IF ( ActionsLoo.conditional_comparison_exists ) %] exists [% END %] - [% IF ( ActionsLoo.conditional_comparison_not_exists ) %] does not exist [% END %] - [% IF ( ActionsLoo.conditional_comparison_equals ) %] matches [% END %] - [% IF ( ActionsLoo.conditional_comparison_not_equals ) %] does not match [% END %] - - [% IF ( ActionsLoo.conditional_regex ) %] RegEx m/[% END %] - [% ActionsLoo.conditional_value %] - [% IF ( ActionsLoo.conditional_regex ) %]/[% END %] - [% END %] - [% ActionsLoo.description %]EditDeleteTemplateActions
[% TemplatesLoo.name %] + Edit actions + Duplicate + Delete +
+ [% ELSE %] -

There are no defined actions for this template.

+ +

Actions for [% template_name %]

+ + [% IF ( ActionsLoop ) %] + + + + + + + + + + + + + + [% FOREACH ActionsLoo IN ActionsLoop %] + + + + + + + + + + [% END # /FOREACH ActionsLoo %] + +
Change orderOrderActionDescription  
+ + Move action up + + + + Move action to the top + + + + Move action to the bottom + + + + Move action down + + [% ActionsLoo.ordering %] + [% IF ( ActionsLoo.action_delete_field ) %] Delete [% END %] + [% 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 ) %] + 1st + [% END %] + [% END %] + + field + + [% ActionsLoo.from_field %][% IF ( ActionsLoo.from_subfield ) %]$[% ActionsLoo.from_subfield %][% END %] + + [% IF ( ActionsLoo.field_value ) %] + with value [% ActionsLoo.field_value %] + [% END %] + + [% IF ( ActionsLoo.to_field ) %] + to [% ActionsLoo.to_field %][% IF ( ActionsLoo.to_subfield ) %]$[% ActionsLoo.to_subfield %][% END %] + + [% IF ( ActionsLoo.to_regex_search ) %] + using RegEx s/[% ActionsLoo.to_regex_search %]/[% ActionsLoo.to_regex_replace %]/[% ActionsLoo.to_regex_modifiers %] + [% END %] + [% END %] + + [% IF ( ActionsLoo.conditional ) %] + [% IF ( ActionsLoo.conditional_if ) %] if [% END %] + [% IF ( ActionsLoo.conditional_unless ) %] unless [% END %] + + [% ActionsLoo.conditional_field %][% IF ( ActionsLoo.conditional_subfield ) %]$[% ActionsLoo.conditional_subfield %][% END %] + + [% IF ( ActionsLoo.conditional_comparison_exists ) %] exists [% END %] + [% IF ( ActionsLoo.conditional_comparison_not_exists ) %] does not exist [% END %] + [% IF ( ActionsLoo.conditional_comparison_equals ) %] matches [% END %] + [% IF ( ActionsLoo.conditional_comparison_not_equals ) %] does not match [% END %] + + [% IF ( ActionsLoo.conditional_regex ) %] RegEx m/[% END %] + [% ActionsLoo.conditional_value %] + [% IF ( ActionsLoo.conditional_regex ) %]/[% END %] + [% END %] + [% ActionsLoo.description %] + Edit + + Delete +
+ [% ELSE %] +

There are no defined actions for this template.

+ [% END # /IF ActionsLoop %] + +
+ +
+ Add a new action + + + + + + + + + field(s) + + + + + +

+ + + + + + + + + +

+ + + +

+ Cancel + +

+
+ [% END %] -
- -
- Add a new action - - - - - - - - - field(s) - - - - - -

- - - - - - - - - -

- - - -

- - -

-
- [% ELSE %]

There are no defined templates. Please create a template first.

- [% END %] + [% END # /IF TemplatesLoop %] -
-
- Create a new template + +
+
+ + +
@@ -287,5 +345,5 @@ [% INCLUDE 'tools-menu.inc' %] - + [% INCLUDE 'intranet-bottom.inc' %] 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 9353637052..3c1be0b4a1 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js +++ b/koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js @@ -1,4 +1,7 @@ $(document).ready(function() { + window.modaction_legend_innerhtml = document.getElementById('modaction_legend').innerHTML; + window.action_submit_value = document.getElementById('action_submit').value; + $('#select_template').find("input:submit").hide(); $('#select_template').change(function() { $('#select_template').submit(); @@ -43,6 +46,35 @@ $(document).ready(function() { $("#conditional_field,#from_field").change(function(){ updateAllEvery(); }); + + $("#new_action").on("click",function(){ + cancelEditAction(); + $("#add_action").show(); + $("#action").focus(); + }); + + $(".duplicate_template").on("click",function(){ + var template_id = $(this).data("template_id"); + $("#duplicate_a_template").val(template_id); + $("#duplicate_current_template").val(1); + }); + + $('#createTemplate').on('shown', function () { + $("#template_name").focus(); + }); + + $("#duplicate_a_template").on("change",function(){ + if( this.value == '' ){ + $("#duplicate_current_template").val(""); + } else { + $("#duplicate_current_template").val(1); + } + }); + + $(".delete_template").on("click",function(){ + return confirmDelete(); + }); + }); function updateAllEvery(){ @@ -200,6 +232,7 @@ function editAction( mmta_id, ordering, action, field_number, from_field, from_s to_subfield, to_regex_search, to_regex_replace, to_regex_modifiers, conditional, conditional_field, conditional_subfield, conditional_comparison, conditional_value, conditional_regex, description ) { + $("#add_action").show(); document.getElementById('mmta_id').value = mmta_id; setSelectByValue( 'action', action ); @@ -239,8 +272,6 @@ function editAction( mmta_id, ordering, action, field_number, from_field, from_s window.action_submit_value = document.getElementById('action_submit').value; document.getElementById('action_submit').value = MSG_MMT_UPDATE_ACTION; - - show('cancel_edit'); } function cancelEditAction() { @@ -257,6 +288,7 @@ function cancelEditAction() { $("#to_regex_search").val(""); $("#to_regex_replace").val(""); $("#to_regex_modifiers").val(""); + $("#description").val(""); document.getElementById('to_field_regex').checked = false; document.getElementById('to_field_regex').onchange(); @@ -276,8 +308,7 @@ function cancelEditAction() { document.getElementById('modaction_legend').innerHTML = window.modaction_legend_innerhtml; document.getElementById('action_submit').value = window.action_submit_value; - - hide('cancel_edit'); + $("#add_action").hide(); } function setSelectByValue( selectId, value ) { diff --git a/tools/marc_modification_templates.pl b/tools/marc_modification_templates.pl index 3689684c51..4e477c0cf2 100755 --- a/tools/marc_modification_templates.pl +++ b/tools/marc_modification_templates.pl @@ -113,11 +113,6 @@ if ( $op eq "create_template" ) { my @templates = GetModificationTemplates( $template_id ); -unless ( $template_id ) { - $template_id = $templates[0]->{'template_id'}; - @templates = GetModificationTemplates( $template_id ); -} - my @actions = GetModificationTemplateActions( $template_id ); foreach my $action ( @actions ) { $action->{'action_delete_field'} = ( $action->{'action'} eq 'delete_field' );