From 555bd995ad086cc922edee46d1bbbb42089234e4 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 14 Feb 2014 14:29:47 -0500 Subject: [PATCH] Bug 11767 - Use validation plugin when creating new authority framework tag The page for adding a new tag to an authority framework includes some custom form validation JavaScript which can be removed in favor of HTML5 validation attributes and Koha's built-in validation plugin. This patch does so. The patch also moves some tag markup out of the script and into the template where it belongs. To test, apply the patch and go to Administration -> Authority types -> MARC structure -> New tag. Try submitting the form without entering a tag number. This should trigger a validation warning. Submission of the form with valid data should work correctly. Editing an existing tag should also work correctly. Signed-off-by: Chris Cormack Signed-off-by: Jonathan Druart --- admin/auth_tag_structure.pl | 6 +- .../prog/en/modules/admin/auth_tag_structure.tt | 61 ++++++-------------- 2 files changed, 19 insertions(+), 48 deletions(-) diff --git a/admin/auth_tag_structure.pl b/admin/auth_tag_structure.pl index 31b510a..ae2d2da 100755 --- a/admin/auth_tag_structure.pl +++ b/admin/auth_tag_structure.pl @@ -111,18 +111,14 @@ if ($op eq 'add_form') { -id=>'authorised_value', -values=> \@authorised_values, -size=>1, - -tabindex=>'', -multiple=>0, -default => $data->{'authorised_value'}, ); if ($searchfield) { - $template->param(action => "Modify tag", - searchfield => "$searchfield"); + $template->param('searchfield' => $searchfield); $template->param('heading_modify_tag_p' => 1); } else { - $template->param(action => "Add tag", - searchfield => ""); $template->param('heading_add_tag_p' => 1); } $template->param('use_heading_flags_p' => 1); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_tag_structure.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_tag_structure.tt index f8c3910..aed89bc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_tag_structure.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_tag_structure.tt @@ -19,43 +19,7 @@ "sPaginationType": "four_button" })); }); - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// - function isNotNull(f,noalert) { - if (f.value.length ==0) { -return false; - } - return true; - } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// - function isNum(v,maybenull) { - var n = new Number(v.value); - if (isNaN(n)) { - return false; - } - if (maybenull==0 && v.value=='') { - return false; - } - return true; - } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// - function Check(f) { - var ok=1; - var _alertString=""; - var alertString2; - if (f.tagfield.value.length==0) { - _alertString += "\n- " + _("tag number missing"); - } - if (_alertString.length==0) { - document.Aform.submit(); - } else { - alertString2 = _("Form not submitted because of the following problem(s)"); - alertString2 += "\n------------------------------------------------------------------------------------\n"; - alertString2 += _alertString; - alert(alertString2); - } - } - //]]> +//]]> @@ -112,17 +76,25 @@ return false; [% IF ( add_form ) %]

- [% IF ( use_heading_flags_p ) %] [% IF ( heading_modify_tag_p ) %]Modify tag[% END %] [% IF ( heading_add_tag_p ) %]New tag[% END %] - [% ELSE %][% action %][% END %]

-
+ [% IF ( heading_modify_tag_p ) %][% END %] -
    -
  1. Tag: [% searchfield %]
  2. +
    +
      + [% IF ( heading_modify_tag_p ) %] +
    1. + Tag: + + [% searchfield %] +
    2. + [% ELSE %] +
    3. + [% END %] +
    4. @@ -141,7 +113,10 @@ return false;
    5. [% authorised_value %] (if you select a value here, the indicators will be limited to the authorized value list)
    -

    +
    + + Cancel +
    [% END %] -- 1.7.10.4