Bugzilla – Attachment 82482 Details for
Bug 21861
The MARC modification template actions editor does not always validate user input
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21861: The MARC modification template actions editor does not always validate user input
Bug-21861-The-MARC-modification-template-actions-e.patch (text/plain), 5.79 KB, created by
Andreas Roussos
on 2018-11-19 12:31:11 UTC
(
hide
)
Description:
Bug 21861: The MARC modification template actions editor does not always validate user input
Filename:
MIME Type:
Creator:
Andreas Roussos
Created:
2018-11-19 12:31:11 UTC
Size:
5.79 KB
patch
obsolete
>From ae90b9cc6373b5da8dadbd3873505b1f2d54ce28 Mon Sep 17 00:00:00 2001 >From: Andreas Roussos <arouss1980@gmail.com> >Date: Sat, 17 Nov 2018 20:03:36 +0200 >Subject: [PATCH] Bug 21861: The MARC modification template actions editor does > not always validate user input > >The MARC modification template actions editor does not validate >user input when adding a conditional clause, making it possible >to save a modification action without filling in all necessary >fields. > >This patch fixes that. > >Test plan: >1) Create a MARC modification template and add a new action, > e.g. "Copy All field(s) 200$a to field 600$a". > Add a condition ("if" or "unless") but leave the relevant > field and subfield textboxes empty. > Add "matches" or "doesn't match" as a comparison operator. > Check the "RegEx" checkbox, leave the regex textbox empty. >2) Click on "Add action" and notice how it accepts your input. > Also notice the extra space in the Action column RegEx. >3) Edit your modification action and notice the missing "m/" > before the conditional RegEx. > >4) Apply the patch and hit CTRL-F5 to reload the relevant JS. > >5) Edit the modification action you added previously (or add > a new one). Try leaving the textboxes mentioned above empty > and then submit your changes. You should get pop-up windows > informing you about missing fields. >6) Now try typing a value in the conditional regex textbox and > Update your action. In the Action column, there should be > no spaces between the delimiters of the matching operator > and the value you just entered. >7) Edit your action: notice how the "m/" before the regular > expression and the "/" after it are now showing correctly. >--- > .../en/modules/tools/marc_modification_templates.tt | 8 +++++--- > .../prog/js/marc_modification_templates.js | 21 +++++++++++++++++++++ > 2 files changed, 26 insertions(+), 3 deletions(-) > >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 d842568e01..877600e868 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 >@@ -157,9 +157,7 @@ > [% IF ( ActionsLoo.conditional_comparison_equals ) %] matches [% END %] > [% IF ( ActionsLoo.conditional_comparison_not_equals ) %] does not match [% END %] > >- [% IF ( ActionsLoo.conditional_regex ) %] RegEx m/[% END %] >- <strong>[% ActionsLoo.conditional_value | html %]</strong> >- [% IF ( ActionsLoo.conditional_regex ) %]/[% END %] >+ [% IF ( ActionsLoo.conditional_regex ) %] RegEx m/[% END %]<strong>[% ActionsLoo.conditional_value | html %]</strong>[% IF ( ActionsLoo.conditional_regex ) %]/[% END %] > [% END %] > </td> > <td>[% ActionsLoo.description | html %]</td> >@@ -356,6 +354,10 @@ > var MSG_MMT_CONFIRM_DEL_TEMPLATE_ACTION = _("Are you sure you wish to delete this template action?"); > var MSG_MMT_EDIT_ACTION = _("Edit action %s"); > var MSG_MMT_UPDATE_ACTION = _("Update action"); >+ var MSG_MMT_CONDITIONAL_FIELD_REQUIRED = _("The conditional field should be filled."); >+ var MSG_MMT_CONDITIONAL_COMPARISON_REQUIRED = _("The conditional comparison operator should be filled."); >+ var MSG_MMT_CONDITIONAL_VALUE_REQUIRED = _("The conditional value should be filled."); >+ var MSG_MMT_CONDITIONAL_VALUE_REGEX_REQUIRED = _("The conditional regular expression should be filled."); > </script> > [% Asset.js("js/marc_modification_templates.js") | $raw %] > [% END %] >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 6a232703ba..1a7b569791 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js >@@ -41,6 +41,26 @@ $(document).ready(function() { > alert( MSG_MMT_SOURCE_FIELD ); > return false; > } >+ if ( $("#conditional").val() == 'if' || $("#conditional").val() == 'unless' ) { >+ if ( $("#conditional_field").val() == '' ) { >+ alert( MSG_MMT_CONDITIONAL_FIELD_REQUIRED ); >+ return false; >+ } >+ if ( $("#conditional_comparison").val() == '' ) { >+ alert( MSG_MMT_CONDITIONAL_COMPARISON_REQUIRED ); >+ return false >+ } >+ if ( $("#conditional_value").val() == '' && >+ ( $("#conditional_comparison").val() == 'equals' || $("#conditional_comparison").val() == 'not_equals' ) ) { >+ if ( document.getElementById('conditional_regex').checked == true ) { >+ alert( MSG_MMT_CONDITIONAL_VALUE_REGEX_REQUIRED ); >+ return false; >+ } else { >+ alert( MSG_MMT_CONDITIONAL_VALUE_REQUIRED ); >+ return false; >+ } >+ } >+ } > }); > > $("#conditional_field,#from_field").change(function(){ >@@ -278,6 +298,7 @@ function editAction( mmta_id, ordering, action, field_number, from_field, from_s > document.getElementById('conditional_value').value = conditional_value; > > document.getElementById('conditional_regex').checked = parseInt( conditional_regex ); >+ document.getElementById('conditional_regex').onchange(); > > document.getElementById('description').value = description; > >-- >2.11.0
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 21861
:
82482
|
82528
|
82581
|
82641
|
82642