[LON-CAPA-cvs] cvs: loncom /interface lonannounce.pm
www
lon-capa-cvs@mail.lon-capa.org
Wed, 21 May 2003 16:26:46 -0000
www Wed May 21 12:26:46 2003 EDT
Modified files:
/loncom/interface lonannounce.pm
Log:
Bugs 1479, 1480: Better date entry, and better placement of Remove button.
Index: loncom/interface/lonannounce.pm
diff -u loncom/interface/lonannounce.pm:1.8 loncom/interface/lonannounce.pm:1.9
--- loncom/interface/lonannounce.pm:1.8 Wed Apr 30 11:49:45 2003
+++ loncom/interface/lonannounce.pm Wed May 21 12:26:46 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Announce
#
-# $Id: lonannounce.pm,v 1.8 2003/04/30 15:49:45 matthew Exp $
+# $Id: lonannounce.pm,v 1.9 2003/05/21 16:26:46 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -121,45 +121,14 @@
'dlsav' => $todayhash{'dlsav'} ));
my $weekday=$firstday{'weekday'};
# ------------------------------------------------------------ Print the screen
- my $pjump_function = &Apache::lonhtmlcommon::pjump_javascript_definition();
+
$r->print(<<ENDDOCUMENT);
<html>
<head>
<title>The LearningOnline Network with CAPA</title>
<script>
- function pclose() {
- parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
- "height=350,width=350,scrollbars=no,menubar=no");
- parmwin.close();
- }
-
- $pjump_function
-
- function dateset() {
- if (document.anno.pres_marker.value=='end') {
- document.anno.enddate.value=
- document.anno.pres_value.value;
- }
- if (document.anno.pres_marker.value=='start') {
- document.anno.startdate.value=
- document.anno.pres_value.value;
- }
- pclose();
- }
function trysubmit() {
- if (document.anno.startdate.value=='') {
- alert("Announcements must have a starting date");
- return '';
- }
- if (document.anno.enddate.value=='') {
- alert("Announcements must have a starting date");
- return '';
- }
- if (document.anno.startdate.value>document.anno.enddate.value) {
- alert("Starting date is later than ending date");
- return '';
- }
document.anno.action.value="new";
document.anno.submit();
}
@@ -183,8 +152,19 @@
my $coursedom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
# ----------------------------------------------------- Store new submitted one
if ($ENV{'form.action'} eq 'new') {
+ my $startdate =
+ &Apache::lonhtmlcommon::get_date_from_form('startdate');
+ my $enddate =
+ &Apache::lonhtmlcommon::get_date_from_form('enddate');
+ unless ($startdate=~/^\d+$/) { $startdate=time; }
+ unless ($enddate=~/^\d+$/) { $enddate=$startdate+1; }
+ if ($startdate>$enddate) {
+ my $buffer=$startdate;
+ $startdate=$enddate;
+ $enddate=$buffer;
+ }
&Apache::lonnet::put('calendar',{
- $ENV{'form.startdate'}.'_'.$ENV{'form.enddate'} =>
+ $startdate.'_'.$enddate =>
$ENV{'form.msg'} },$coursedom,$coursenum);
}
# ---------------------------------------------------------------- Remove items
@@ -202,24 +182,23 @@
$tomorrowhash{'day'}++;
my $tomorrow=&Apache::loncommon::maketime(%tomorrowhash);
+ # Deal with date forms
+ my $startdateform = &Apache::lonhtmlcommon::date_setter('anno',
+ 'startdate',
+ $today);
+ my $enddateform = &Apache::lonhtmlcommon::date_setter('anno',
+ 'enddate',
+ $tomorrow);
+ #
+
$r->print(<<ENDFORM);
<form name="anno" method="post">
<input type="hidden" value='' name="action" >
-<input type="hidden" value='' name="pres_value" >
-<input type="hidden" value='' name="pres_type" >
-<input type="hidden" value='' name="pres_marker" >
-<input type="hidden" value='$today' name="startdate" >
-<input type="hidden" value='$tomorrow' name="enddate" >
-<a
- href="javascript:pjump('date_start','Starting Date',document.anno.startdate.value,'start','anno.pres','dateset');"
->Set Starting Date</a>
-<a
- href="javascript:pjump('date_end','Ending Date',document.anno.enddate.value,'end','anno.pres','dateset');"
->Set Ending Date</a><p>
+<table><tr><td>Starting date:</td><td>$startdateform</td></tr>
+<tr><td>Ending date:</td><td>$enddateform</td></tr></table>
<textarea name="msg" rows="4" cols="60">
</textarea>
<input type="button" onClick="trysubmit()" value="Post Announcement"><hr>
-<input type="button" onClick="removesub()" value="Remove Marked"><hr>
ENDFORM
}
# ----------------------------------------------------- Summarize all calendars
@@ -264,7 +243,7 @@
}
# ------------------------------------------------------------------- End table
$r->print('</table>');
- if ($allowed) { $r->print('</form>'); }
+ if ($allowed) { $r->print('<input type="button" onClick="removesub()" value="Remove Checked Entries"></form>'); }
$r->print('<p>'.
'<a href="/adm/announcements?month='.$pm.'&year='.$py.'">Previous Month</a> '.
'<a href="/adm/announcements?month='.$fm.'&year='.$fy.'">Next Month</a><p>'.