Bug 8014 - On the patron entry form hide "restricted until" field if "Restricted: No" is checked

This patch adds JavaScript to automatically hide the "Restricted
unil" form field on the patron entry form if "Restricted: No" is
selected. If "Restricted: Yes" is chosen the "Until:" field
is shown and focus is given to it.

The patch also adds a note, "(optional)" after the "Until:" field
to make it clearer that a date is not required.

To test, open a patron record and try moving the selection
between "Restricted: No" and "Restricted: Yes." Confirm that
the "Until:" field is shown and hidden as expected. Confirm
that the restricted flag is correctly set or unset upon save,
including setting the flag with or without a date.

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
This commit is contained in:
Owen Leonard 2012-04-27 08:57:16 -04:00 committed by Paul Poulain
parent 57ecf1a332
commit 3da0f42653
2 changed files with 35 additions and 19 deletions

View File

@ -167,3 +167,19 @@ function Dopopguarantor(link) {
var newin=window.open(link,'popup','width=600,height=400,resizable=no,toolbar=false,scrollbars=yes,top');
}
$(document).ready(function(){
if($("#yesdebarred").is(":checked")){
$("#debarreduntil").show();
} else {
$("#debarreduntil").hide();
}
$("#yesdebarred,#nodebarred").change(function(){
if($("#yesdebarred").is(":checked")){
$("#debarreduntil").show();
$("#datedebarred").focus();
} else {
$("#debarreduntil").hide();
}
});
});

View File

@ -1344,25 +1344,25 @@
<label for="nodebarred">No </label>
<input type="radio" id="nodebarred" name="debarred" value="0" checked="checked"/>
[% END %]
<br />
<label for="datedebarred" class="radio">until:</label>
[% IF opduplicate %]
<input type="text" name="datedebarred" id="datedebarred" class="debarred" value="[% datedebarred %]" onclick="this.value=''" />
[% ELSE %]
<input type="text" name="datedebarred" id="datedebarred" class="debarred" value="[% datedebarred %]" />
[% END %]
<img src="[% themelang %]/lib/calendar/cal.gif" id="debarred_button" alt="Show Calendar" />
<script language="JavaScript" type="text/javascript">
Calendar.setup(
{
inputField : "datedebarred",
ifFormat : "[% DHTMLcalendar_dateformat %]",
button : "debarred_button"
}
);
</script>
<br />
<span id="debarreduntil"><label for="datedebarred" class="inline">Until:</label>
[% IF opduplicate %]
<input type="text" name="datedebarred" id="datedebarred" class="debarred" value="[% datedebarred %]" onclick="this.value=''" />
[% ELSE %]
<input type="text" name="datedebarred" id="datedebarred" class="debarred" value="[% datedebarred %]" />
[% END %]
<img src="[% themelang %]/lib/calendar/cal.gif" id="debarred_button" alt="Show Calendar" />
<script language="JavaScript" type="text/javascript">
Calendar.setup(
{
inputField : "datedebarred",
ifFormat : "[% DHTMLcalendar_dateformat %]",
button : "debarred_button"
}
);
</script> <span class="hint">(optional)</span> </span>
</li>
<li>
<label for="debarredcomment" class="radio">Comment:</label>
[% IF ( opduplicate ) %]
<textarea id="debarredcomment" name="debarredcomment" cols="55" rows="3" onclick="this.value=''">[% debarredcomment %]</textarea>