[Jifty-commit] r2285 - in jifty/branches/template-declare: .
lib/Jifty/Action
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Sun Dec 3 02:44:47 EST 2006
Author: audreyt
Date: Sun Dec 3 02:44:47 2006
New Revision: 2285
Modified:
jifty/branches/template-declare/ (props changed)
jifty/branches/template-declare/lib/Jifty/Action/Record.pm
jifty/branches/template-declare/lib/Jifty/DateTime.pm
Log:
* Merge down into template-declare branch.
Modified: jifty/branches/template-declare/lib/Jifty/Action/Record.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Action/Record.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Action/Record.pm Sun Dec 3 02:44:47 2006
@@ -251,6 +251,7 @@
};
}
my $autocomplete_method = "autocomplete_" . $field;
+
if ( $self->record->can($autocomplete_method) ) {
$info->{'autocompleter'} ||= sub {
my ( $self, $value ) = @_;
@@ -261,6 +262,30 @@
%columns );
};
}
+ elsif ($column->autocompleted) {
+ # Auto-generated autocompleter
+ $info->{'autocompleter'} ||= sub {
+ my ( $self, $value ) = @_;
+
+ my $collection = Jifty::Collection->new(
+ record_class => $self->record_class,
+ current_user => $self->record->current_user
+ );
+
+ $collection->unlimit;
+ $collection->rows_per_page(20);
+ $collection->limit(column => $field, value => $value, operator => 'STARTSWITH') if length($value);
+ $collection->columns('id', $field);
+ $collection->order_by(column => $field);
+ $collection->group_by(column => $field);
+
+ my @choices;
+ while (my $record = $collection->next) {
+ push @choices, $record->$field;
+ }
+ return @choices;
+ };
+ }
my $canonicalize_method = "canonicalize_" . $field;
if ( $self->record->can($canonicalize_method) ) {
@@ -361,7 +386,6 @@
$event_class->new($event_info)->publish;
}
-
=head1 SEE ALSO
L<Jifty::Action>, L<Jifty::Record>, L<Jifty::DBI::Record>,
Modified: jifty/branches/template-declare/lib/Jifty/DateTime.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/DateTime.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/DateTime.pm Sun Dec 3 02:44:47 2006
@@ -79,6 +79,9 @@
if($string =~ /^\s* (?:monday|tuesday|wednesday|thursday|friday|saturday|sunday)$/xi) {
$string = "next $string";
}
+
+ # Why are we parsing this as GMT? This feels really wrong. It will get the wrong answer
+ # if the current user is in another tz.
Date::Manip::Date_Init("TZ=GMT");
$now = Date::Manip::UnixDate( $string, "%o" );
}
More information about the Jifty-commit
mailing list