Bugzilla – Attachment 52463 Details for
Bug 16754
Use validation plugin in budgets, planning, and contracts
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16754 - Use validation plugin when adding or editing budgets
Bug-16754---Use-validation-plugin-when-adding-or-e.patch (text/plain), 9.03 KB, created by
Owen Leonard
on 2016-06-16 13:40:22 UTC
(
hide
)
Description:
Bug 16754 - Use validation plugin when adding or editing budgets
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2016-06-16 13:40:22 UTC
Size:
9.03 KB
patch
obsolete
>From 7959d06ec606de50a8cec45ce2ad2f9c6e9d7eb4 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Thu, 16 Jun 2016 09:28:01 -0400 >Subject: [PATCH] Bug 16754 - Use validation plugin when adding or editing > budgets >Content-Type: text/plain; charset="utf-8" > >This patch removes the custom javascript form validation from the budget >edit template and replaces it with validation via the validation plugin. > >I did not reproduce the date comparison portion of the script because it >didn't work correctly in many cases. The datepicker enforces the >requirement that the budget start date precedes the budget end date. > >Also changed: I added the "Required" text next to required fields. > >To test, apply the patch and test the budget creation process for >adding, editing, and duplicating budgets. In all cases: > >- The start date and end date should be required >- The description should be required >- The budget amount should be required to be a number >--- > .../prog/en/modules/admin/aqbudgetperiods.tt | 103 +++++---------------- > 1 file changed, 25 insertions(+), 78 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt >index ecedbea..c312875 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt >@@ -37,74 +37,6 @@ > [% END %] > <script type="text/javascript" src="[% interface %]/[% theme %]/js/acq.js"></script> > <script type="text/javascript"> >-// ################################################################################# >-// Javascript >-// ################################################################################# >- function CheckDuplicateForm(f){ >- var ok=1; >- var _alertString=""; >- var alertString=""; >- if(!(isNotNull(f.budget_period_startdate,1))){ >- _alertString += "\n- " + _("Start date missing"); >- } >- if (!(isNotNull(f.budget_period_enddate,1))){ >- _alertString += "\n- " + _("End date missing"); >- } >- if( f.budget_period_startdate > f.budget_period_enddate ) { >- _alertString += "\n- " + _("Start date must be before end date"); >- } >- if (!(isNotNull(f.budget_period_description,1))){ >- _alertString += "\n- " + _("Budget description missing"); >- } >- >- if(_alertString.length==0){ >- f.submit(); >- } else { >- alertString += _("Form not submitted because of the following problem(s)"); >- alertString += "\n-----------------------------------------\n"; >- alertString += _alertString; >- alert(alertString); >- } >- } >- function Check(f) { >- var ok=1; >- var _alertString=""; >- var alertString2; >- >- if (!(isNotNull(f.budget_period_startdate,1))) { >- _alertString += "\n- " + _("Start date missing"); >- } >- >- if (!(isNotNull(f.budget_period_enddate,1))) { >- _alertString += "\n- " + _("End date missing"); >- } >- >- if ( f.budget_period_startdate > f.budget_period_enddate ) { >- _alertString += "\n- " + _("Start date must be before end date"); >- } >- >- if (!(isNotNull(f.budget_period_description,1))) { >- _alertString += "\n- " + _("Description missing"); >- } >- >- if (!(isNum(f.budget_period_total))) { >- _alertString += "\n- " + _("Amount must be a valid number, or empty"); >- } >- >-/* >- checkBudgetTotal(f) { >- } >-*/ >- >- if (_alertString.length==0) { >- f.submit(); >- } else { >- alertString2 = _("Form not submitted because of the following problem(s)"); >- alertString2 += "\n------------------------------------------------------------------------------------\n"; >- alertString2 += _alertString; >- alert(alertString2); >- } >- } > > $(document).ready(function() { > var tabs = $('#budgetsTabs').tabs(); >@@ -171,6 +103,16 @@ > "sPaginationType": "full_numbers" > })); > [% END %] >+ $("#add_modify_budget").validate({ >+ rules: { >+ budget_period_startdate: "required", >+ budget_period_enddate: "required", >+ budget_period_description: "required", >+ budget_period_total: { >+ number: true >+ } >+ } >+ }); > }); > </script> > >@@ -252,13 +194,13 @@ > <div id="yui-main"> > <div class="yui-b"> > >-[% UNLESS close_form OR closed%] >+[% UNLESS close_form OR closed OR duplicate_form %] > [% INCLUDE 'budgets-admin-toolbar.inc' %] > [% END %] > > [% IF ( duplicate_form ) %] > <h3>Duplicate budget</h3> >-<form action="/cgi-bin/koha/admin/aqbudgetperiods.pl" name="f" method="post"> >+<form action="/cgi-bin/koha/admin/aqbudgetperiods.pl" id="add_modify_budget" name="f" method="post"> > <fieldset class="rows"> > <input type="hidden" name="op" value="duplicate_budget" /> > <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" /> >@@ -268,18 +210,21 @@ > <li> > <label class="required" for="from">Start date: </label> > <input type="text" size="10" id="from" name="budget_period_startdate" value="[% budget_period_startdate | $KohaDates %]" class="datepickerfrom" /> >- <div class="hint">[% INCLUDE 'date-format.inc' %]</div> >+ <span class="required">Required</span> >+ <div class="hint">[% INCLUDE 'date-format.inc' %]</div> > </li> > <li> > > <label class="required" for="to">End date: </label> > <input type="text" size="10" id="to" name="budget_period_enddate" value="[% budget_period_enddate | $KohaDates %]" class="datepickerto" /> >- <div class="hint">[% INCLUDE 'date-format.inc' %]</div> >+ <span class="required">Required</span> >+ <div class="hint">[% INCLUDE 'date-format.inc' %]</div> > </li> > > <li> > <label class="required" for="budget_period_description">Description</label> > <input type="text" id="budget_period_description" name="budget_period_description" value="[% budgetperiod.budget_period_description %]" /> >+ <span class="required">Required</span> > </li> > > <li> >@@ -308,7 +253,7 @@ > </fieldset> > > <fieldset class="action"> >- <input type="button" value="Save Changes" onclick="CheckDuplicateForm(this.form)" /> <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id %]">Cancel</a> >+ <input type="submit" value="Save" /> <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id %]">Cancel</a> > </fieldset> > > </form> >@@ -323,7 +268,7 @@ > [% ELSE %] > <h3>Add budget</h3> > [% END %] >-<form action="/cgi-bin/koha/admin/aqbudgetperiods.pl" name="f" method="post"> >+<form action="/cgi-bin/koha/admin/aqbudgetperiods.pl" id="add_modify_budget" name="f" method="post"> > <fieldset class="rows"> > <!-- ################################################################################# --> > <!-- display information about the budget period that must be added or modified --> >@@ -334,13 +279,15 @@ > <li> > <label class="required" for="from">Start date: </label> > <input type="text" size="10" id="from" name="budget_period_startdate" value="[% budget_period_startdate | $KohaDates %]" class="datepickerfrom" /> >- <div class="hint">[% INCLUDE 'date-format.inc' %]</div> >+ <span class="required">Required</span> >+ <div class="hint">[% INCLUDE 'date-format.inc' %]</div> > </li> > <li> > > <label class="required" for="to">End date: </label> > <input type="text" size="10" id="to" name="budget_period_enddate" value="[% budget_period_enddate | $KohaDates %]" class="datepickerto" /> >- <div class="hint">[% INCLUDE 'date-format.inc' %]</div> >+ <span class="required">Required</span> >+ <div class="hint">[% INCLUDE 'date-format.inc' %]</div> > </li> > > <li> >@@ -349,6 +296,7 @@ > <label class="required" for="budget_period_description">Description: </label> > <input type="text" id="budget_period_description" name="budget_period_description" > size="48" maxlength="80" value="[% budget_period_description %]" /> >+ <span class="required">Required</span> > </li> > > <li> >@@ -378,8 +326,7 @@ > <fieldset class="action"> > <!-- "save changes" button --> > <!-- ###################################### --> >- <input type="button" value="Save" onclick="Check(this.form)" /> >- <!-- <input type="submit" value="Save Changes" /> --> >+ <input type="submit" value="Save" /> > [% IF ( budget_period_id ) %] > <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id %]" class="cancel">Cancel</a> > [% ELSE %] >-- >2.1.4
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 16754
:
52463
|
52476
|
54057
|
79896
|
79940
|
80169