From dfb021b110352e50fe78c65d72579087f9324e33 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 25 Mar 2016 09:47:11 -0400 Subject: [PATCH] Bug 16148 - Revised layout and behavior of marc modification template management This patch makes changes to the layout and behavior of the marc modification template management page to make it adhere better to common interaction patterns in Koha. - The initial view shows a list of templates rather than pre-selecting the first available template for editing. - A toolbar has been added with a "New template" button. - The initial view of existing templates has an actions menu containing menu items for 'Edit actions,' 'Duplicate,' and 'Delete.' It doesn't appear to be possible to edit an existing template's name. - The "Create template" form is no longer shown all the time. - Clicking the "New template" toolbar button triggers a modal with the form for creating a template. An existing template can be chosen to duplicate. - Choosing "Duplicate" from one of the template menus triggers the "New template" modal and preselects the corresponding template in the "duplicate" - [% FOREACH TemplatesLoo IN TemplatesLoop %] - [% IF ( TemplatesLoo.selected ) %] - - [% ELSE %] - - [% END %] - [% END %] - - - - - -
- - - -
- - - [% IF ( ActionsLoop ) %] - - + [% IF ( template_id == '' ) %] - - - - - - - - +

MARC modification templates [% template_id %]

- [% 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.

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

+

- + -

-
+ + + + [% END %] [% ELSE %]

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

- [% END %] - -
-
- Create a new template - - - - Required - - - - - [% IF ( template_id ) %] - - - - [% END %] -
-
+ [% END # /IF TemplatesLoop %] + + + @@ -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 9353637..3c1be0b 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 3689684..4e477c0 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' ); -- 2.8.1