[Rt-commit] rt branch, create-action, updated. 4fbfa44e9f08e3eb4af37fd6434fd1ef0d47c9b3
sartak at bestpractical.com
sartak at bestpractical.com
Wed Oct 14 16:09:45 EDT 2009
The branch, create-action has been updated
via 4fbfa44e9f08e3eb4af37fd6434fd1ef0d47c9b3 (commit)
via a26c47b870d209f76b970f8118d508c0f45a4064 (commit)
from bcc3c0b6dd46903401b5d3c337ce8a2cfce1d7f1 (commit)
Summary of changes:
lib/RT/View/Form/Field/SelectUser.pm | 23 +++++++++++++++++------
1 files changed, 17 insertions(+), 6 deletions(-)
- Log -----------------------------------------------------------------
commit a26c47b870d209f76b970f8118d508c0f45a4064
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Wed Oct 14 16:09:27 2009 -0400
Factor out render-user logic into a method
diff --git a/lib/RT/View/Form/Field/SelectUser.pm b/lib/RT/View/Form/Field/SelectUser.pm
index 4399409..9564ddd 100644
--- a/lib/RT/View/Form/Field/SelectUser.pm
+++ b/lib/RT/View/Form/Field/SelectUser.pm
@@ -4,6 +4,19 @@ use strict;
use Jifty::View::Declare;
use base 'Jifty::Web::Form::Field::Select';
+sub _render_user {
+ my $self = shift;
+ my $user = shift;
+
+ if (!ref($user)) {
+ my $user_object = RT::Model::User->new;
+ $user_object->load($user);
+ $user = $user_object;
+ }
+
+ return $user->name;
+}
+
sub _render_select_values {
my $self = shift;
my $rendered = '';
@@ -21,9 +34,7 @@ sub _render_select_values {
: $current_value eq $value );
$rendered .= qq!>!;
- my $user = RT::Model::User->new;
- $user->load($value);
- $rendered .= $user->name;
+ $rendered .= $self->_render_user($value);
$rendered .= qq!</option>\n!;
}
@@ -38,7 +49,7 @@ sub render_value {
my $value = $self->current_value;
if(defined $value) {
my @value = grep { $_->{value} eq $value } $self->available_values;
- $value = $value[0]->{display} if scalar @value;
+ $value = $self->_render_user($value[0]->{value}) if scalar @value;
}
$field .= Jifty->web->escape(_($value)) if defined $value;
$field .= qq!</span>\n!;
commit 4fbfa44e9f08e3eb4af37fd6434fd1ef0d47c9b3
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Wed Oct 14 16:09:38 2009 -0400
Simplification
diff --git a/lib/RT/View/Form/Field/SelectUser.pm b/lib/RT/View/Form/Field/SelectUser.pm
index 9564ddd..a075fee 100644
--- a/lib/RT/View/Form/Field/SelectUser.pm
+++ b/lib/RT/View/Form/Field/SelectUser.pm
@@ -22,8 +22,8 @@ sub _render_select_values {
my $rendered = '';
my $current_value = $self->current_value;
- for my $value ($self->available_values) {
- $value = $value->{value} if ref($value) eq 'HASH';
+ for ($self->available_values) {
+ my $value = $_->{value};
$value = "" unless defined $value;
$rendered .= qq!<option value="@{[ Jifty->web->escape($value) ]}"!;
$rendered .= qq! selected="selected"!
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list