You can now arrange events calendar entries by time.

This commit is contained in:
JT Smith 2003-05-24 16:43:59 +00:00
parent c645a1908f
commit 423ff3e223
3 changed files with 38 additions and 11 deletions

View file

@ -326,6 +326,14 @@ The the base name for this form element. This form element actually returns two
The date and time. Pass as an epoch value. Defaults to today and now. The date and time. Pass as an epoch value. Defaults to today and now.
=item dateExtras
Extra parameters to add to the date form element such as javascript or stylesheet information.
=item timeExtras
Extra parameters to add to the time form element such as javascript or stylesheet information.
=back =back
=cut =cut
@ -333,11 +341,13 @@ The date and time. Pass as an epoch value. Defaults to today and now.
sub dateTime { sub dateTime {
my $output = date({ my $output = date({
name=>$_[0]->{name}."_date", name=>$_[0]->{name}."_date",
value=>$_[0]->{value} value=>$_[0]->{value},
extras=>$_[0]->{dateExtras}
}); });
$output .= time({ $output .= time({
name=>$_[0]->{name}."_time", name=>$_[0]->{name}."_time",
value=>WebGUI::DateTime::getSecondsFromEpoch($_[0]->{value}) value=>WebGUI::DateTime::getSecondsFromEpoch($_[0]->{value}),
extras=>$_[0]->{timeExtras}
}); });
return $output; return $output;
} }

View file

@ -482,7 +482,7 @@ sub date {
#------------------------------------------------------------------- #-------------------------------------------------------------------
=head2 dateTime ( name [ label, value, subtext, uiLevel ] ) =head2 dateTime ( name [ label, value, subtext, uiLevel, dateExtras, timeExtras ] )
Adds a date time row to this form. Adds a date time row to this form.
@ -508,6 +508,14 @@ Extra text to describe this form element or to provide special instructions.
The UI level for this field. See the WebGUI developer's site for details. Defaults to "0". The UI level for this field. See the WebGUI developer's site for details. Defaults to "0".
=item dateExtras
Extra parameters such as javascript or style sheet information that you wish to add to the date form element.
=item timeExtras
Extra parameters such as javascript or style sheet information that you wish to add to the time form element.
=back =back
=cut =cut
@ -515,11 +523,14 @@ The UI level for this field. See the WebGUI developer's site for details. Defaul
sub dateTime { sub dateTime {
my ($output); my ($output);
my ($self, @p) = @_; my ($self, @p) = @_;
my ($name, $label, $value, $subtext, $uiLevel) = rearrange([qw(name label value subtext uiLevel)], @p); my ($name, $label, $value, $subtext, $uiLevel, $dateExtras, $timeExtras) =
rearrange([qw(name label value subtext uiLevel dateExtras timeExtras)], @p);
if (_uiLevelChecksOut($uiLevel)) { if (_uiLevelChecksOut($uiLevel)) {
$output = WebGUI::Form::dateTime({ $output = WebGUI::Form::dateTime({
"name"=>$name, "name"=>$name,
"value"=>$value "value"=>$value,
"dateExtras"=>$dateExtras,
"timeExtras"=>$timeExtras
}); });
$output .= _subtext($subtext); $output .= _subtext($subtext);
$output = $self->_tableFormRow($label,$output); $output = $self->_tableFormRow($label,$output);

View file

@ -14,6 +14,7 @@ use strict;
use HTML::CalendarMonthSimple; use HTML::CalendarMonthSimple;
use Tie::CPHash; use Tie::CPHash;
use WebGUI::DateTime; use WebGUI::DateTime;
use WebGUI::FormProcessor;
use WebGUI::HTMLForm; use WebGUI::HTMLForm;
use WebGUI::Icon; use WebGUI::Icon;
use WebGUI::International; use WebGUI::International;
@ -336,13 +337,18 @@ sub www_editEvent {
$f->hidden("func","editEventSave"); $f->hidden("func","editEventSave");
$f->text("name",WebGUI::International::get(99),$event{name}); $f->text("name",WebGUI::International::get(99),$event{name});
$f->HTMLArea("description",WebGUI::International::get(85),$event{description}); $f->HTMLArea("description",WebGUI::International::get(85),$event{description});
$f->date("startDate",WebGUI::International::get(14,$_[0]->get("namespace")),$event{startDate}, $f->dateTime(
'onBlur="this.form.endDate.value=this.form.startDate.value;this.form.until.value=this.form.startDate.value;"'); -name=>"startDate",
$f->date( -label=>WebGUI::International::get(14,$_[0]->get("namespace")),
-value=>$event{startDate},
-dateExtras=>'onBlur="this.form.endDate_date.value=this.form.startDate_date.value;this.form.until.value=this.form.startDate_date.value;"',
-timeExtras=>'onBlur="this.form.endDate_time.value=this.form.startDate_time.value"'
);
$f->dateTime(
-name=>"endDate", -name=>"endDate",
-label=>WebGUI::International::get(15,$_[0]->get("namespace")), -label=>WebGUI::International::get(15,$_[0]->get("namespace")),
-value=>$event{endDate}, -value=>$event{endDate},
-extras=>'onBlur="this.form.until.value=this.form.endDate.value;"' -dateExtras=>'onBlur="this.form.until.value=this.form.endDate_date.value;"'
); );
$f->raw($special); $f->raw($special);
if ($session{form}{eid} eq "new") { if ($session{form}{eid} eq "new") {
@ -363,9 +369,9 @@ sub www_editEvent {
sub www_editEventSave { sub www_editEventSave {
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage()); return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
my (@startDate, @endDate, $until, @eventId, $i, $recurringEventId); my (@startDate, @endDate, $until, @eventId, $i, $recurringEventId);
$startDate[0] = setToEpoch($session{form}{startDate}); $startDate[0] = WebGUI::FormProcessor::dateTime("startDate");
$startDate[0] = time() unless ($startDate[0] > 0); $startDate[0] = time() unless ($startDate[0] > 0);
$endDate[0] = setToEpoch($session{form}{endDate}); $endDate[0] = WebGUI::FormProcessor::dateTime("endDate");
$endDate[0] = $startDate[0] unless ($endDate[0] >= $startDate[0]); $endDate[0] = $startDate[0] unless ($endDate[0] >= $startDate[0]);
if ($session{form}{eid} eq "new") { if ($session{form}{eid} eq "new") {
$session{form}{name} = $session{form}{name} || "unnamed"; $session{form}{name} = $session{form}{name} || "unnamed";