Bugzilla – Attachment 18734 Details for
Bug 10409
Do not show course entry form if no departments are found
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10409 - Do not show course entry form if no departments are found
Bug-10409---Do-not-show-course-entry-form-if-no-de.patch (text/plain), 20.44 KB, created by
Jared Camins-Esakov
on 2013-06-07 12:33:46 UTC
(
hide
)
Description:
Bug 10409 - Do not show course entry form if no departments are found
Filename:
MIME Type:
Creator:
Jared Camins-Esakov
Created:
2013-06-07 12:33:46 UTC
Size:
20.44 KB
patch
obsolete
>From d69ba6d4722fe2be8cee6cb0aa8855b2e4bf93c6 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Wed, 5 Jun 2013 08:36:51 -0400 >Subject: [PATCH] Bug 10409 - Do not show course entry form if no departments > are found > >The course reserves entry form should not be shown if there are no >DEPARTMENT authorized values, since this prevents the form from being >submitted. This patch replaces the form with an error message when no >DEPARTMENT authorized values are found. > >Also corrected: > >- Corrected grid structure for more standard display >- Converted labels with no corresponding inputs to <span class="label"> >- Closed unclosed tags >- Corrected incorrect capitalization > >This patch contains whitespace changes, so please ignore whitespace when >examining changes. > >To test, delete any DEPARTMENT authorized values, if present. Create a >new course in Course Reserves. You should see a warning that no >DEPARTMENT values were found. > >If you are logged in with the correct permission, the warning should >contain a link to the correct authorized value page. If you do no, the >warning should refer the problem to an administrator. > >After creating one or more DEPARTMENT values, the form should display >and submit correctly. > >Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com> >After this patch has been applied, I get an error message and no form >if I don't have any DEPARTMENTs defined, which makes sense given that >the form can't be submitted without a DEPARTMENT. >--- > .../prog/en/modules/course_reserves/course.tt | 343 ++++++++++---------- > 1 file changed, 175 insertions(+), 168 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course.tt >index 85817ed..8e6a60d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course.tt >@@ -2,71 +2,75 @@ > <title>Koha › Course reserves › [% IF course_name %] Edit [% course_name %] [% ELSE %] New course [% END %]</title> > [% INCLUDE 'doc-head-close.inc' %] > >-<script type="text/javascript"> >-//<![CDATA[ >+[% IF ( departments ) %] > >- function Check(f) { >- var _alertString = ""; >+ <script type="text/javascript"> >+ //<![CDATA[ > >- if( ! $("#department").val() ) { >- _alertString += _("- You must choose a department") + "\n"; >- } >+ function Check(f) { >+ var _alertString = ""; > >- if( ! $("#course_number").val() ) { >- _alertString += _("- You must choose a course number") + "\n"; >- } >+ if( ! $("#department").val() ) { >+ _alertString += _("- You must choose a department") + "\n"; >+ } > >- if( ! $("#course_name").val() ) { >- _alertString += _("- You must add a course name") + "\n"; >- } >+ if( ! $("#course_number").val() ) { >+ _alertString += _("- You must choose a course number") + "\n"; >+ } > >- if ( _alertString.length ) { >- var alertHeader; >- alertHeader = _("Form not submitted because of the following problem(s)"); >- alertHeader += "\n------------------------------------------------------------------------------------\n\n"; >+ if( ! $("#course_name").val() ) { >+ _alertString += _("- You must add a course name") + "\n"; >+ } > >- alert( alertHeader + _alertString ); >- } else { >- f.submit(); >- } >- } >+ if ( _alertString.length ) { >+ var alertHeader; >+ alertHeader = _("Form not submitted because of the following problem(s)"); >+ alertHeader += "\n------------------------------------------------------------------------------------\n\n"; > >-//]]> >-</script> >- >-<script type="text/javascript"> >-//<![CDATA[ >-$(document).ready(function(){ >- $( "#find_instructor" ).autocomplete({ >- source: "/cgi-bin/koha/circ/ysearch.pl", >- minLength: 3, >- select: function( event, ui ) { >- AddInstructor( ui.item.firstname + " " + ui.item.surname, ui.item.cardnumber ); >- return false; >+ alert( alertHeader + _alertString ); >+ } else { >+ f.submit(); >+ } > } >- }) >- .data( "autocomplete" )._renderItem = function( ul, item ) { >- return $( "<li></li>" ) >- .data( "item.autocomplete", item ) >- .append( "<a>" + item.surname + ", " + item.firstname + " (" + item.cardnumber + ") <small>" + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "</small></a>" ) >- .appendTo( ul ); >- }; >- >-}); > >-function AddInstructor( name, cardnumber ) { >- div = "<div id='borrower_" + cardnumber + "'>" + name + " ( <a href='#' onclick='RemoveInstructor(" + cardnumber + ");return false;'> Remove </a> ) <input type='hidden' name='instructors' value='" + cardnumber + "' /></div>"; >- $('#instructors').append( div ); >+ //]]> >+ </script> >+ >+ <script type="text/javascript"> >+ //<![CDATA[ >+ $(document).ready(function(){ >+ $( "#find_instructor" ).autocomplete({ >+ source: "/cgi-bin/koha/circ/ysearch.pl", >+ minLength: 3, >+ select: function( event, ui ) { >+ AddInstructor( ui.item.firstname + " " + ui.item.surname, ui.item.cardnumber ); >+ return false; >+ } >+ }) >+ .data( "autocomplete" )._renderItem = function( ul, item ) { >+ return $( "<li></li>" ) >+ .data( "item.autocomplete", item ) >+ .append( "<a>" + item.surname + ", " + item.firstname + " (" + item.cardnumber + ") <small>" + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "</small></a>" ) >+ .appendTo( ul ); >+ }; >+ >+ }); >+ >+ function AddInstructor( name, cardnumber ) { >+ div = "<div id='borrower_" + cardnumber + "'>" + name + " ( <a href='#' onclick='RemoveInstructor(" + cardnumber + ");return false;'> Remove </a> ) <input type='hidden' name='instructors' value='" + cardnumber + "' /></div>"; >+ $('#instructors').append( div ); >+ >+ $('#find_instructor').val('').focus(); >+ } > >- $('#find_instructor').val('').focus(); >-} >+ function RemoveInstructor( cardnumber ) { >+ $( '#borrower_' + cardnumber ).remove(); >+ } > >-function RemoveInstructor( cardnumber ) { >- $( '#borrower_' + cardnumber ).remove(); >-} >+ //]]> >+ </script> > >-//]]> >-</script> >+[% END %] > > </head> > >@@ -77,128 +81,131 @@ function RemoveInstructor( cardnumber ) { > > <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/course_reserves/course-reserves.pl">Course reserves</a> › [% IF course_name %] Edit <i>[% course_name %]</i> [% ELSE %] New course [% END %]</div> > >-<div id="doc2" class="yui-t7"> >- <div id="bd"> >- <div id="yui-main"> >- <div class="yui-b"> >- <div class="yui-g"> >- <div class="yui-u first"> >- <form method="post" action="/cgi-bin/koha/course_reserves/mod_course.pl"> >- [% IF course_id %]<input type="hidden" name="course_id" value="[% course_id %]" />[% END %] >- <fieldset class="rows"> >- <legend>[% IF course_id %] Edit [% ELSE %] Create [% END %] course</legend> >- <ol> >- <li> >- <label class="required" for="department">Department:</label> >- [% IF departments %] >- <select id="department" name="department"> >- <option value="">Select A Department</option> >- >- [% FOREACH d IN departments %] >- [% IF d.authorised_value == department %] >- <option value="[% d.authorised_value %]" selected="selected">[% d.lib %]</option> >- [% ELSE %] >- <option value="[% d.authorised_value %]">[% d.lib %]</option> >- [% END %] >- [% END %] >- </select> >+[% IF ( departments ) %] >+ >+ <div id="doc" class="yui-t7"> >+ <div id="bd"> >+ <form method="post" action="/cgi-bin/koha/course_reserves/mod_course.pl"> >+ [% IF course_id %]<input type="hidden" name="course_id" value="[% course_id %]" />[% END %] >+ <fieldset class="rows"> >+ <legend>[% IF course_id %] Edit [% ELSE %] Create [% END %] course</legend> >+ <ol> >+ <li> >+ <label class="required" for="department">Department:</label> >+ <select id="department" name="department"> >+ <option value="">Select a department</option> >+ >+ [% FOREACH d IN departments %] >+ [% IF d.authorised_value == department %] >+ <option value="[% d.authorised_value %]" selected="selected">[% d.lib %]</option> >+ [% ELSE %] >+ <option value="[% d.authorised_value %]">[% d.lib %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </li> >+ >+ <li> >+ <label class="required" for="course_number">Course number:</label> >+ <input id="course_number" name="course_number" type="text" value="[% course_number %]" /> >+ </li> >+ >+ <li> >+ <label for="section">Section:</label> >+ <input id="section" name="section" type="text" value="[% section %]"/> >+ </li> >+ >+ <li> >+ <label class="required" for="course_name">Course name:</label> >+ <input id="course_name" name="course_name" type="text" value="[% course_name %]" /> >+ </li> >+ >+ <li> >+ [% IF terms %] >+ <label for="term">Term:</label> >+ <select id="term" name="term"> >+ <option value=""></option> >+ >+ [% FOREACH t IN terms %] >+ [% IF t.authorised_value == term %] >+ <option value="[% t.authorised_value %]" selected="selected">[% t.lib %]</option> > [% ELSE %] >- <span id="department">No DEPARTMENT authorised values found! Please create one or more authorised values with the category DEPARTMENT.</span> >+ <option value="[% t.authorised_value %]">[% t.lib %]</option> > [% END %] >- </li> >- >- <li> >- <label class="required" for="course_number">Course number:</label> >- <input id="course_number" name="course_number" type="text" value="[% course_number %]" /> >- </li> >- >- <li> >- <label for="section">Section:</label> >- <input id="section" name="section" type="text" value="[% section %]"/> >- </li> >- >- <li> >- <label class="required" for="course_name">Course name:</label> >- <input id="course_name" name="course_name" type="text" value="[% course_name %]" /> >- </li> >- >- <li> >- <label for="term">Term:</label> >- [% IF terms %] >- <select id="term" name="term"> >- <option value=""></option> >- >- [% FOREACH t IN terms %] >- [% IF t.authorised_value == term %] >- <option value="[% t.authorised_value %]" selected="selected">[% t.lib %]</option> >- [% ELSE %] >- <option value="[% t.authorised_value %]">[% t.lib %]</option> >- [% END %] >- [% END %] >- </select> >- [% ELSE %] >- <span id="term">No TERM authorised values found! Please create one or more authorised values with the category TERM.</span> >- [% END %] >- </li> >- >- <li> >- <label for="instructors">Instructors:</label> >- >- <fieldset> >- <div id="instructors"> >- [% FOREACH i IN instructors %] >- <div id="borrower_[% i.cardnumber %]"> >- [% i.surname %], [% i.firstname %] ( <a href='#' onclick='RemoveInstructor( [% i.cardnumber %] );'> Remove </a> ) >- <input type='hidden' name='instructors' value='[% i.cardnumber %]' /> >- </div> >- [% END %] >- </div> >- >- </fieldset> >- >- <fieldset> >- <label for="find_instructor">Instructor search:</label> >- <input autocomplete="off" id="find_instructor" type="text" style="width:150px" class="noEnterSubmit"/> >- <div id="find_instructor_container"></div> >- </fieldset> >- <li> >- <label for="staff_note">Staff note:</label> >- <textarea name="staff_note" id="staff_note">[% staff_note %]</textarea> >- </li> >- >- <li> >- <label for="public_note">Public note:</label> >- <textarea name="public_note" id="public_note">[% public_note %]</textarea> >- </li> >- >- <li> >- <label for="students_count">Number of students:</label> >- <input id="students_count" name="students_count" type="text" value="[% students_count %]" /> >- </li> >- >- <li> >- <label for="enabled">Enabled?</label> >- [% IF enabled == 'no' %] >- <input type="checkbox" name="enabled" id="enabled" /> >- [% ELSE %] >- <input type="checkbox" name="enabled" id="enabled" checked="checked" /> >- [% END %] >- </li> >- </ol> >+ [% END %] >+ </select> >+ [% ELSE %] >+ <span class="label">Term: </span> >+ <span id="term">No TERM authorised values found! Please create one or more authorised values with the category TERM.</span> >+ [% END %] >+ </li> >+ >+ <li> >+ <span class="label">Instructors:</span> >+ >+ <fieldset> >+ <div id="instructors"> >+ [% FOREACH i IN instructors %] >+ <div id="borrower_[% i.cardnumber %]"> >+ [% i.surname %], [% i.firstname %] ( <a href='#' onclick='RemoveInstructor( [% i.cardnumber %] );'> Remove </a> ) >+ <input type='hidden' name='instructors' value='[% i.cardnumber %]' /> >+ </div> >+ [% END %] >+ </div> > </fieldset> > >- <fieldset class="action"> >- <input type="submit" onclick="Check(this.form); return false;" value="Save" class="submit" /> >- >- <a href="/cgi-bin/koha/course_reserves/course-reserves.pl" class="cancel">Cancel</a> >+ <fieldset> >+ <label for="find_instructor">Instructor search:</label> >+ <input autocomplete="off" id="find_instructor" type="text" style="width:150px" class="noEnterSubmit"/> >+ <div id="find_instructor_container"></div> > </fieldset> >- >- </div> >- </div> >- </div> >+ <li> >+ <label for="staff_note">Staff note:</label> >+ <textarea name="staff_note" id="staff_note">[% staff_note %]</textarea> >+ </li> >+ >+ <li> >+ <label for="public_note">Public note:</label> >+ <textarea name="public_note" id="public_note">[% public_note %]</textarea> >+ </li> >+ >+ <li> >+ <label for="students_count">Number of students:</label> >+ <input id="students_count" name="students_count" type="text" value="[% students_count %]" /> >+ </li> >+ >+ <li> >+ <label for="enabled">Enabled?</label> >+ [% IF enabled == 'no' %] >+ <input type="checkbox" name="enabled" id="enabled" /> >+ [% ELSE %] >+ <input type="checkbox" name="enabled" id="enabled" checked="checked" /> >+ [% END %] >+ </li> >+ </ol> >+ </fieldset> >+ >+ <fieldset class="action"> >+ <input type="submit" onclick="Check(this.form); return false;" value="Save" class="submit" /> >+ >+ <a href="/cgi-bin/koha/course_reserves/course-reserves.pl" class="cancel">Cancel</a> >+ </fieldset> >+ </form> > </div> >- </div> >+ >+[% ELSE %] >+ >+<div class="dialog alert"> >+ <p> >+ No DEPARTMENT authorised values found! >+ [% IF ( CAN_user_parameters ) %] >+ Please <a href="/cgi-bin/koha/admin/authorised_values.pl?searchfield=DEPARTMENT">create one or more authorised values</a> with the category DEPARTMENT. >+ [% ELSE %] >+ An administrator must create one or more authorised values with the category DEPARTMENT. >+ [% END %] >+ </p> > </div> > >+[% END %] > > [% INCLUDE 'intranet-bottom.inc' %] >-- >1.7.9.5
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 10409
:
18671
|
18734
|
19278
|
19298
|
19299
|
19683