From e67ad1851716531790b39799b9de2cfc70ca4eae Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 26 Oct 2010 13:13:16 -0700 Subject: [PATCH] fixed #11929: In/Out board breaks in Chrome sometimes --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Asset/Wobject/InOutBoard.pm | 33 +++++++++++++++++--------- t/Asset/Wobject/InOutBoard.t | 10 +++++++- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 52853bd5e..9a39404eb 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,4 +1,5 @@ 7.10.4 + - fixed #11929: In/Out board breaks in Chrome sometimes - fixed #11928: Story Archive breaks if url has extension - fixed #11920: Defaul DataForm emails missing entries. - fixed #11921: DataForm emails contain 1 table per field diff --git a/lib/WebGUI/Asset/Wobject/InOutBoard.pm b/lib/WebGUI/Asset/Wobject/InOutBoard.pm index 88a3477b9..2b6793b11 100644 --- a/lib/WebGUI/Asset/Wobject/InOutBoard.pm +++ b/lib/WebGUI/Asset/Wobject/InOutBoard.pm @@ -115,6 +115,24 @@ sub definition { #------------------------------------------------------------------- +=head2 getStatusList + +Returns the statusList property as an array + +=cut + +sub getStatusList { + my $self = shift; + my $text = $self->get('statusList'); + + return + grep { $_ } # no empty lines + map { s/^\s+//; s/\s+$//; $_ } # trim + split(/\r\n|\r|\n/, $text); # seperated by any kind of newline +} + +#------------------------------------------------------------------- + =head2 prepareView ( ) See WebGUI::Asset::prepareView() for details. @@ -180,16 +198,9 @@ sub view { } my $statusUserId = $self->session->scratch->get("userId") || $self->session->user->userId; - my $statusListString = $self->getValue("statusList"); - my @statusListArray = split("\n",$statusListString); - my $statusListHashRef; - tie %$statusListHashRef, 'Tie::IxHash'; - - foreach my $status (@statusListArray) { - chomp($status); - next if $status eq ""; - $statusListHashRef->{$status} = $status; - } + tie my %statusOptions, 'Tie::IxHash', ( + map { $_ => $_ } $self->getStatusList + ); #$self->session->log->warn("VIEW: userId: ".$statusUserId."\n" ); my ($status) = $session->db->quickArray( @@ -223,7 +234,7 @@ sub view { $f->radioList( -name=>"status", -value=>$status, - -options=>$statusListHashRef, + -options=>\%statusOptions, -label=>$i18n->get(5), -hoverHelp=>$i18n->get('5 description'), ); diff --git a/t/Asset/Wobject/InOutBoard.t b/t/Asset/Wobject/InOutBoard.t index 0178e7fda..29fd6a4ff 100644 --- a/t/Asset/Wobject/InOutBoard.t +++ b/t/Asset/Wobject/InOutBoard.t @@ -18,7 +18,7 @@ use Test::MockObject::Extends; use WebGUI::Test; use WebGUI::Session; -use Test::More tests => 8; # increment this value for each test you create +use Test::More tests => 9; # increment this value for each test you create use Test::Deep; use Data::Dumper; @@ -129,6 +129,14 @@ cmp_deeply( $session->request->setup_body({ }); $session->scratch->delete('userId'); +################################################################ +# +# getStatusList +# +################################################################ +$board->update({statusList => "In\r\nOut\rHome\nLunch"}); +is_deeply [$board->getStatusList], [qw(In Out Home Lunch)], 'getStatusList'; + ################################################################ # # view