Module: tools Branch: master Commit: b80115f963f28bf38cf089e28f3bf8f582ba714e URL: https://source.winehq.org/git/tools.git/?a=commit;h=b80115f963f28bf38cf089e2... Author: Francois Gouget <fgouget(a)codeweavers.com> Date: Thu Apr 7 00:31:18 2022 +0200 testbot/cgi: Improve the Add button label for multi-word item class names. Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- testbot/lib/ObjectModel/CGI/CollectionBlock.pm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/testbot/lib/ObjectModel/CGI/CollectionBlock.pm b/testbot/lib/ObjectModel/CGI/CollectionBlock.pm index 13c2a62..736c3f8 100644 --- a/testbot/lib/ObjectModel/CGI/CollectionBlock.pm +++ b/testbot/lib/ObjectModel/CGI/CollectionBlock.pm @@ -570,6 +570,15 @@ sub OnItemAction($$$) # Actions handling # +sub GetAddButtonLabel($) +{ + my ($self) = @_; + + my $Label = $self->{Collection}->GetItemName(); + $Label =~ s/([a-z])([A-Z])/$1 $2/g; + return "Add $Label"; +} + =pod =over 12 @@ -587,9 +596,7 @@ sub GetActions($) { my ($self) = @_; - return $self->GetDetailsPage() ? - ["Add ". $self->{Collection}->GetItemName()] : - []; + return $self->GetDetailsPage() ? [$self->GetAddButtonLabel()] : []; } =pod @@ -614,7 +621,7 @@ sub OnAction($$) { my ($self, $Action) = @_; - if ($self->{RW} and $Action eq "Add ". $self->{Collection}->GetItemName()) + if ($self->{RW} and $Action eq $self->GetAddButtonLabel()) { my $Target = $self->GetDetailsPage(); my ($MasterColNames, $MasterColValues) = $self->{Collection}->GetMasterCols();