The old CollectionPage is not used anymore so replace it with the new implementation. This means CollectionBlockForPage and the CallXxx() trampolines are not needed anymore either.
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- Removes quite a bit of code. Yay! --- .../lib/ObjectModel/CGI/CollectionBlock.pm | 169 +++-------------- .../ObjectModel/CGI/CollectionBlockForPage.pm | 154 --------------- testbot/lib/ObjectModel/CGI/CollectionPage.pm | 179 ++++-------------- .../ObjectModel/CGI/SimpleCollectionPage.pm | 138 -------------- testbot/web/JobDetails.pl | 4 +- testbot/web/PatchesList.pl | 4 +- testbot/web/admin/BranchesList.pl | 4 +- testbot/web/admin/UsersList.pl | 4 +- testbot/web/admin/VMsList.pl | 4 +- 9 files changed, 73 insertions(+), 587 deletions(-) delete mode 100644 testbot/lib/ObjectModel/CGI/CollectionBlockForPage.pm delete mode 100644 testbot/lib/ObjectModel/CGI/SimpleCollectionPage.pm
diff --git a/testbot/lib/ObjectModel/CGI/CollectionBlock.pm b/testbot/lib/ObjectModel/CGI/CollectionBlock.pm index cbe22f90f..40ad61b2b 100644 --- a/testbot/lib/ObjectModel/CGI/CollectionBlock.pm +++ b/testbot/lib/ObjectModel/CGI/CollectionBlock.pm @@ -37,32 +37,6 @@ Also, because this is only one part of a web page, some methods, such as those dealing with errors, are delegated to the EnclosingPage object which must implement the ObjectModel::CGI::Page interface.
-Other methods are designed so they can be overridden by the enclosing page as -a way to allow it to modify how the collection block looks or behaves. These -methods can be identified by their CallXxx() trampoline. The override -mechanism works as follows: -- The CollectionBlock class and any subclass should never call overridable - methods directly. Instead they should call the corresponding CallXxx() - trampoline. -- The CollectionBlock class provides a default CallXxx() implementation which - simply calls the corresponding Xxx() method. This allows using the - CollectionBlock as is. -- Pages that want to customize the CollectionBlock behavior should use the - CollectionBlockForPage class instead. That class provides an alternative - implementation for each CallXxx(...) method that calls - $self->{EnclosingPage}->Xxx($CollectionBlock, ...). Note how the Xxx() - method in the enclosing page gets an extra parameter so it can both know - which collection block it received the call from, and call the collection - block methods. -- The page should in turn provide implementations for all the Xxx() methods. - The simplest way to do so is for such pages use CollectionPage as their base - class. CollectionPage provides default Xxx($CollectionBlock,...) - implementations that just reflect these calls back to - $CollectionBlock->Xxx(). - -Of course an alternative way for a page to customize the collection block -behavior is to subclass it and use that subclass instead. - =cut
package ObjectModel::CGI::CollectionBlock; @@ -118,13 +92,6 @@ sub Create($$@) return ObjectModel::CGI::CollectionBlock->new(@_); }
-sub CallGetDetailsPage($) -{ - my ($self) = @_; - - return $self->GetDetailsPage(); -} - sub GetDetailsPage($) { my ($self) = @_; @@ -144,14 +111,14 @@ sub escapeHTML($$) # Error handling framework #
-sub CallGenerateErrorDiv($) +sub GenerateErrorDiv($) { my ($self) = @_;
$self->{EnclosingPage}->GenerateErrorDiv(); }
-sub CallGenerateErrorPopup($) +sub GenerateErrorPopup($) { my ($self) = @_;
@@ -163,13 +130,6 @@ sub CallGenerateErrorPopup($) # Individual item property support #
-sub CallDisplayProperty($$) -{ - my ($self, $PropertyDescriptor) = @_; - - return $self->DisplayProperty($PropertyDescriptor); -} - =pod =over 12
@@ -190,13 +150,6 @@ sub DisplayProperty($$) return $PropertyDescriptor->GetClass ne "Detailref"; }
-sub CallSortKeys($$) -{ - my ($self, $Keys) = @_; - - return $self->SortKeys($Keys); -} - sub SortKeys($$) { my ($self, $Keys) = @_; @@ -204,13 +157,6 @@ sub SortKeys($$) return $Keys; }
-sub CallGetDisplayValue($$$) -{ - my ($self, $Item, $PropertyDescriptor) = @_; - - return $self->GetDisplayValue($Item, $PropertyDescriptor); -} - sub GetDisplayValue($$$) { my ($self, $Item, $PropertyDescriptor) = @_; @@ -258,13 +204,6 @@ sub GetDisplayValue($$$) return $Value; }
-sub CallGetEscapedDisplayValue($$$) -{ - my ($self, $Item, $PropertyDescriptor) = @_; - - return $self->GetEscapedDisplayValue($Item, $PropertyDescriptor); -} - sub GetEscapedDisplayValue($$$) { my ($self, $Item, $PropertyDescriptor) = @_; @@ -286,8 +225,7 @@ sub GetEscapedDisplayValue($$$) } else { - $Value = $self->escapeHTML($self->CallGetDisplayValue($Item, - $PropertyDescriptor)); + $Value = $self->escapeHTML($self->GetDisplayValue($Item, $PropertyDescriptor)); }
return $Value; @@ -298,13 +236,6 @@ sub GetEscapedDisplayValue($$$) # Item cell generation #
-sub CallGenerateHeaderCell($$) -{ - my ($self, $PropertyDescriptor) = @_; - - return $self->GenerateHeaderCell($PropertyDescriptor); -} - sub GenerateHeaderCell($$) { my ($self, $PropertyDescriptor) = @_; @@ -312,13 +243,6 @@ sub GenerateHeaderCell($$) "</th>\n"; }
-sub CallGenerateDataCell($$$$) -{ - my ($self, $Item, $PropertyDescriptor, $DetailsPage) = @_; - - return $self->GenerateDataCell($Item, $PropertyDescriptor, $DetailsPage); -} - sub GenerateDataCell($$$$) { my ($self, $Item, $PropertyDescriptor, $DetailsPage) = @_; @@ -347,7 +271,7 @@ sub GenerateDataCell($$$$) } print "<a href='", $self->escapeHTML($Query), "'>"; } - print $self->CallGetEscapedDisplayValue($Item, $PropertyDescriptor); + print $self->GetEscapedDisplayValue($Item, $PropertyDescriptor); if ($NeedLink) { print "</a>"; @@ -360,13 +284,6 @@ sub GenerateDataCell($$$$) # Collection table generation #
-sub CallGenerateFormStart($) -{ - my ($self) = @_; - - $self->GenerateFormStart(); -} - sub GenerateFormStart($) { my ($self) = @_; @@ -384,13 +301,6 @@ sub GenerateFormStart($) } }
-sub CallGenerateHeaderRow($$$) -{ - my ($self, $PropertyDescriptors, $ItemActions) = @_; - - $self->GenerateHeaderRow($PropertyDescriptors, $ItemActions); -} - sub GenerateHeaderRow($$$) { my ($self, $PropertyDescriptors, $ItemActions) = @_; @@ -402,9 +312,9 @@ sub GenerateHeaderRow($$$) } foreach my $PropertyDescriptor (@$PropertyDescriptors) { - if ($self->CallDisplayProperty($PropertyDescriptor)) + if ($self->DisplayProperty($PropertyDescriptor)) { - $self->CallGenerateHeaderCell($PropertyDescriptor); + $self->GenerateHeaderCell($PropertyDescriptor); } }
@@ -419,13 +329,6 @@ sub SelName($$) return "sel_" . $Key; }
-sub CallGenerateDataRow($$$$$$) -{ - my ($self, $Item, $PropertyDescriptors, $DetailsPage, $Class, $ItemActions) = @_; - - $self->GenerateDataRow($Item, $PropertyDescriptors, $DetailsPage, $Class, $ItemActions); -} - sub GenerateDataRow($$$$$$) { my ($self, $Item, $PropertyDescriptors, $DetailsPage, $Class, $ItemActions) = @_; @@ -438,21 +341,14 @@ sub GenerateDataRow($$$$$$) } foreach my $PropertyDescriptor (@$PropertyDescriptors) { - if ($self->CallDisplayProperty($PropertyDescriptor)) + if ($self->DisplayProperty($PropertyDescriptor)) { - $self->CallGenerateDataCell($Item, $PropertyDescriptor, $DetailsPage); + $self->GenerateDataCell($Item, $PropertyDescriptor, $DetailsPage); } } print "</tr>\n"; }
-sub CallGenerateFormEnd($) -{ - my ($self) = @_; - - $self->GenerateFormEnd(); -} - sub GenerateFormEnd($) { #my ($self) = @_; @@ -503,26 +399,26 @@ EOF }
print "<div class='CollectionBlock'>\n"; - $self->CallGenerateFormStart(); - $self->CallGenerateErrorDiv(); + $self->GenerateFormStart(); + $self->GenerateErrorDiv();
print "<table border='0' cellpadding='5' cellspacing='0' summary='" . "Overview of " . $Collection->GetCollectionName() . "'>\n"; print "<thead>\n"; - my $ItemActions = $self->CallGetItemActions(); - $self->CallGenerateHeaderRow($PropertyDescriptors, $ItemActions); + my $ItemActions = $self->GetItemActions(); + $self->GenerateHeaderRow($PropertyDescriptors, $ItemActions); print "</thead>\n";
print "<tbody>\n"; - my $DetailsPage = $self->CallGetDetailsPage(); + my $DetailsPage = $self->GetDetailsPage(); my $Row = 0; - my $Keys = $self->CallSortKeys($self->{Collection}->GetKeys()); + my $Keys = $self->SortKeys($self->{Collection}->GetKeys()); foreach my $Key (@$Keys) { my $Class = ($Row % 2) == 0 ? "even" : "odd"; my $Item = $self->{Collection}->GetItem($Key); - $self->CallGenerateDataRow($Item, $PropertyDescriptors, $DetailsPage, - $Class, $ItemActions); + $self->GenerateDataRow($Item, $PropertyDescriptors, $DetailsPage, + $Class, $ItemActions); $Row++; } if (@$Keys == 0) @@ -563,7 +459,7 @@ EOF print "</div>\n"; }
- my $Actions = $self->CallGetActions(); + my $Actions = $self->GetActions(); if (@$Actions != 0) { print "<div class='CollectionBlockActions'>\n"; @@ -574,8 +470,8 @@ EOF print "</div>\n"; }
- $self->CallGenerateErrorPopup(undef); - $self->CallGenerateFormEnd(); + $self->GenerateErrorPopup(undef); + $self->GenerateFormEnd(); print "</div>\n"; }
@@ -584,13 +480,6 @@ EOF # Per-item actions handling #
-sub CallGetItemActions($) -{ - my ($self) = @_; - - return $self->GetItemActions(); -} - =pod =over 12
@@ -613,13 +502,6 @@ sub GetItemActions($) return ["Delete"]; }
-sub CallOnItemAction($$$) -{ - my ($self, $Item, $Action) = @_; - - return $self->OnItemAction($Item, $Action); -} - =pod =over 12
@@ -661,13 +543,6 @@ sub OnItemAction($$$) # Actions handling #
-sub CallGetActions($) -{ - my ($self) = @_; - - return $self->GetActions(); -} - =pod =over 12
@@ -685,7 +560,7 @@ sub GetActions($) { my ($self) = @_;
- return $self->CallGetDetailsPage() ? + return $self->GetDetailsPage() ? ["Add ". $self->{Collection}->GetItemName()] : []; } @@ -714,7 +589,7 @@ sub OnAction($$)
if ($Action eq "Add " . $self->{Collection}->GetItemName()) { - my $Target = $self->CallGetDetailsPage(); + my $Target = $self->GetDetailsPage(); my ($MasterColNames, $MasterColValues) = $self->{Collection}->GetMasterCols(); if (defined($MasterColNames)) { @@ -732,7 +607,7 @@ sub OnAction($$) if (defined $self->{EnclosingPage}->GetParam($self->SelName($Key))) { my $Item = $self->{Collection}->GetItem($Key); - return 0 if (!$self->CallOnItemAction($Item, $Action)); + return 0 if (!$self->OnItemAction($Item, $Action)); } } return 1; diff --git a/testbot/lib/ObjectModel/CGI/CollectionBlockForPage.pm b/testbot/lib/ObjectModel/CGI/CollectionBlockForPage.pm deleted file mode 100644 index 5bdc7d32e..000000000 --- a/testbot/lib/ObjectModel/CGI/CollectionBlockForPage.pm +++ /dev/null @@ -1,154 +0,0 @@ -# -*- Mode: Perl; perl-indent-level: 2; indent-tabs-mode: nil -*- -# Collection block for list pages -# -# Copyright 2009 Ge van Geldorp -# Copyright 2014, 2017-2018, 2022 Francois Gouget -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - -use strict; - -package ObjectModel::CGI::CollectionBlockForPage; - -=head1 NAME - -ObjectModel::CGI::CollectionBlockForPage - Collection block for list pages - -Allows the CollectionPage class to provide implementations for most of the -CollectionBlock methods. See CollectionBlock for details. - -=cut - -use ObjectModel::CGI::CollectionBlock; -our @ISA = qw(ObjectModel::CGI::CollectionBlock); - - -sub CallGetDetailsPage($) -{ - my ($self) = @_; - - return $self->{EnclosingPage}->GetDetailsPage($self); -} - - -# -# Item properties support -# - -sub CallDisplayProperty($$) -{ - my ($self, $PropertyDescriptor) = @_; - - return $self->{EnclosingPage}->DisplayProperty($self, $PropertyDescriptor); -} - -sub CallSortKeys($$) -{ - my ($self, $Keys) = @_; - - return $self->{EnclosingPage}->SortKeys($self, $Keys); -} - -sub CallGetDisplayValue($$$) -{ - my ($self, $Item, $PropertyDescriptor) = @_; - - return $self->{EnclosingPage}->GetDisplayValue($self, $Item, $PropertyDescriptor); -} - - -# -# Item cell generation -# - -sub CallGenerateHeaderCell($$) -{ - my ($self, $PropertyDescriptor) = @_; - - return $self->{EnclosingPage}->GenerateHeaderCell($self, $PropertyDescriptor); -} - -sub CallGenerateDataCell($$$$) -{ - my ($self, $Item, $PropertyDescriptor, $DetailsPage) = @_; - - return $self->{EnclosingPage}->GenerateDataCell($self, $Item, $PropertyDescriptor, $DetailsPage); -} - - -# -# Collection table generation -# - -sub CallGenerateFormStart($) -{ - my ($self) = @_; - - $self->{EnclosingPage}->GenerateFormStart($self); -} - -sub CallGenerateHeaderRow($$$) -{ - my ($self, $PropertyDescriptors, $ItemActions) = @_; - - $self->{EnclosingPage}->GenerateHeaderRow($self, $PropertyDescriptors, $ItemActions); -} - -sub CallGenerateDataRow($$$$$$) -{ - my ($self, $Item, $PropertyDescriptors, $DetailsPage, $Class, $ItemActions) = @_; - - $self->{EnclosingPage}->GenerateDataRow($self, $Item, $PropertyDescriptors, $DetailsPage, $Class, $ItemActions); -} - -sub CallGenerateFormEnd($) -{ - my ($self) = @_; - - $self->{EnclosingPage}->GenerateFormEnd($self); -} - - -# -# Per-item actions handling -# - -sub CallGetItemActions($) -{ - my ($self) = @_; - - return $self->{EnclosingPage}->GetItemActions($self); -} - -sub CallOnItemAction($$$) -{ - my ($self, $Item, $Action) = @_; - - return $self->{EnclosingPage}->OnItemAction($self, $Item, $Action); -} - - -# -# Actions handling -# - -sub CallGetActions($) -{ - my ($self) = @_; - - return $self->{EnclosingPage}->GetActions($self); -} - -1; diff --git a/testbot/lib/ObjectModel/CGI/CollectionPage.pm b/testbot/lib/ObjectModel/CGI/CollectionPage.pm index ddbbd663e..2de667b89 100644 --- a/testbot/lib/ObjectModel/CGI/CollectionPage.pm +++ b/testbot/lib/ObjectModel/CGI/CollectionPage.pm @@ -26,106 +26,65 @@ package ObjectModel::CGI::CollectionPage;
ObjectModel::CGI::CollectionPage - Base class for list pages
-Generates a page containing a single collection block. +A page containing a single collection block.
-It uses the CollectionBlockForPage class which means CollectionPage implements -both the ObjectModel::CGI::Page and ObjectModel::CGI::CollectionBlock -interfaces. The latter allows it to customize the collection block without -having to define a CollectionBlock subclass. +The CollectionPage instances have the following properties: +=over +=item Collection +The collection containing the items to be shown in the CollectionBlock widget. + +=item CollectionBlock +The widget showing the items in the specified collection. + +=item ActionPerformed +Set to true if an action was specified and succeeded. +=back
=cut
use ObjectModel::CGI::Page; our @ISA = qw(ObjectModel::CGI::Page);
-use ObjectModel::CGI::CollectionBlockForPage; - - -sub _initialize($$$$) -{ - my ($self, $Request, $RequiredRole, $Collection) = @_; - - $self->{Collection} = $Collection; - - $self->SUPER::_initialize($Request, $RequiredRole); -} - -sub CreateCollectionBlock($$) -{ - my ($self, $Collection) = @_; - - return ObjectModel::CGI::CollectionBlockForPage->new($Collection, $self); -} - -sub GetDetailsPage($$) -{ - my ($self, $CollectionBlock) = @_; - - return $CollectionBlock->GetDetailsPage(); -} - - -# -# Item properties support -# - -sub DisplayProperty($$$) -{ - my ($self, $CollectionBlock, $PropertyDescriptor) = @_; - - return $CollectionBlock->DisplayProperty($PropertyDescriptor); -} - -sub SortKeys($$$) -{ - my ($self, $CollectionBlock, $Keys) = @_; - - return $CollectionBlock->SortKeys($Keys); -} +# Use require to avoid overriding Page::new() +require ObjectModel::CGI::CollectionBlock;
-sub GetDisplayValue($$$$) -{ - my ($self, $CollectionBlock, $Item, $PropertyDescriptor) = @_; - - return $CollectionBlock->GetDisplayValue($Item, $PropertyDescriptor); -}
+=pod +=over 12
-# -# Item cell generation -# - -sub GenerateHeaderCell($$$) -{ - my ($self, $CollectionBlock, $PropertyDescriptor) = @_; +=item C<_initialize()>
- $CollectionBlock->GenerateHeaderCell($PropertyDescriptor); -} +Sets up the new page object.
-sub GenerateDataCell($$$$$) -{ - my ($self, $CollectionBlock, $Item, $PropertyDescriptor, $DetailsPage) = @_; +Parameters: +=over
- $CollectionBlock->GenerateDataCell($Item, $PropertyDescriptor, $DetailsPage); -} +=item Request +=item RequiredRole +See Page::new().
+=item Collection +This is the collection of items that should be shown in the CollectionBlock +widget.
-# -# Collection table generation -# +=item BlockCreator +If undefined the page will create an instance of the CollectionBlock class. +Otherwise it will use this function to create the CollectionBlock widget, thus +enabling use of a CollectionBlock subclass.
-sub GenerateHeaderRow($$$$) -{ - my ($self, $CollectionBlock, $PropertyDescriptors, $ItemActions) = @_; +=back
- $CollectionBlock->GenerateHeaderRow($PropertyDescriptors, $ItemActions); -} +=back +=cut
-sub GenerateDataRow($$$$$$$) +sub _initialize($$$$;$) { - my ($self, $CollectionBlock, $Item, $PropertyDescriptors, $DetailsPage, $Class, $ItemActions) = @_; + my ($self, $Request, $RequiredRole, $Collection, $BlockCreator) = @_;
- $CollectionBlock->GenerateDataRow($Item, $PropertyDescriptors, $DetailsPage, $Class, $ItemActions); + $self->{Collection} = $Collection; + $BlockCreator ||= &ObjectModel::CGI::CollectionBlock::Create; + $self->{CollectionBlock} = &$BlockCreator($Collection, $self); + $self->SUPER::_initialize($Request, $RequiredRole); }
@@ -153,13 +112,6 @@ sub GenerateTitle($) } }
-sub GenerateFormStart($$) -{ - my ($self, $CollectionBlock) = @_; - - $CollectionBlock->GenerateFormStart(); -} - sub GenerateBody($) { my ($self) = @_; @@ -167,69 +119,20 @@ sub GenerateBody($) print "<div class='CollectionPageBody'>\n"; $self->GenerateTitle(); print "<div class='Content'>\n"; - my $CollectionBlock = $self->CreateCollectionBlock($self->{Collection}); - $CollectionBlock->GenerateList(); + $self->{CollectionBlock}->GenerateList(); print "</div>\n"; print "</div>\n"; }
-sub GenerateFormEnd($$) -{ - my ($self, $CollectionBlock) = @_; - - $CollectionBlock->GenerateFormEnd(); -} - sub GeneratePage($) { my ($self) = @_;
if ($self->GetParam("Action")) { - my $CollectionBlock = $self->CreateCollectionBlock($self->{Collection}); - $self->{ActionPerformed} = $self->OnAction($CollectionBlock, - $self->GetParam("Action")); + $self->{ActionPerformed} = $self->{CollectionBlock}->OnAction($self->GetParam("Action")); } - $self->SUPER::GeneratePage(); }
- -# -# Per-item actions handling -# - -sub GetItemActions($$) -{ - my ($self, $CollectionBlock) = @_; - - return $CollectionBlock->GetItemActions(); -} - -sub OnItemAction($$$$) -{ - my ($self, $CollectionBlock, $Item, $Action) = @_; - - return $CollectionBlock->OnItemAction($Item, $Action); -} - - -# -# Actions handling -# - -sub GetActions($$) -{ - my ($self, $CollectionBlock) = @_; - - return $CollectionBlock->GetActions(); -} - -sub OnAction($$$) -{ - my ($self, $CollectionBlock, $Action) = @_; - - $CollectionBlock->OnAction($Action); -} - 1; diff --git a/testbot/lib/ObjectModel/CGI/SimpleCollectionPage.pm b/testbot/lib/ObjectModel/CGI/SimpleCollectionPage.pm deleted file mode 100644 index 76e4d5195..000000000 --- a/testbot/lib/ObjectModel/CGI/SimpleCollectionPage.pm +++ /dev/null @@ -1,138 +0,0 @@ -# -*- Mode: Perl; perl-indent-level: 2; indent-tabs-mode: nil -*- -# Base class for list pages -# -# Copyright 2009 Ge van Geldorp -# Copyright 2014, 2017-2018, 2022 Francois Gouget -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - -use strict; - -package ObjectModel::CGI::SimpleCollectionPage; - -=head1 NAME - -ObjectModel::CGI::SimpleCollectionPage - Base class for list pages - -A page containing a single collection block. - -The SimpleCollectionPage instances have the following properties: -=over -=item Collection -The collection containing the items to be shown in the CollectionBlock widget. - -=item CollectionBlock -The widget showing the items in the specified collection. - -=item ActionPerformed -Set to true if an action was specified and succeeded. -=back - -=cut - -use ObjectModel::CGI::Page; -our @ISA = qw(ObjectModel::CGI::Page); - -# Use require to avoid overriding Page::new() -require ObjectModel::CGI::CollectionBlock; - - -=pod -=over 12 - -=item C<_initialize()> - -Sets up the new page object. - -Parameters: -=over - -=item Request -=item RequiredRole -See Page::new(). - -=item Collection -This is the collection of items that should be shown in the CollectionBlock -widget. - -=item BlockCreator -If undefined the page will create an instance of the CollectionBlock class. -Otherwise it will use this function to create the CollectionBlock widget, thus -enabling use of a CollectionBlock subclass. - -=back - -=back -=cut - -sub _initialize($$$$;$) -{ - my ($self, $Request, $RequiredRole, $Collection, $BlockCreator) = @_; - - $self->{Collection} = $Collection; - $BlockCreator ||= &ObjectModel::CGI::CollectionBlock::Create; - $self->{CollectionBlock} = &$BlockCreator($Collection, $self); - $self->SUPER::_initialize($Request, $RequiredRole); -} - - -# -# HTML page generation -# - -sub GetTitle($) -{ - my ($self) = @_; - - my $Title = ucfirst($self->{Collection}->GetCollectionName()); - $Title =~ s/([a-z])([A-Z])/$1 $2/g; - return $Title; -} - -sub GenerateTitle($) -{ - my ($self) = @_; - - my $Title = $self->GetTitle(); - if ($Title) - { - print "<h1 id='PageTitle'>", $self->escapeHTML($Title), "</h1>\n"; - } -} - -sub GenerateBody($) -{ - my ($self) = @_; - - print "<div class='CollectionPageBody'>\n"; - $self->GenerateTitle(); - print "<div class='Content'>\n"; - $self->{CollectionBlock}->GenerateList(); - print "</div>\n"; - print "</div>\n"; -} - -sub GeneratePage($) -{ - my ($self) = @_; - - if ($self->GetParam("Action")) - { - $self->{ActionPerformed} = $self->{CollectionBlock}->OnAction($self->GetParam("Action")); - } - $self->SUPER::GeneratePage(); -} - -1; diff --git a/testbot/web/JobDetails.pl b/testbot/web/JobDetails.pl index ccd40443a..ae99b212c 100644 --- a/testbot/web/JobDetails.pl +++ b/testbot/web/JobDetails.pl @@ -300,8 +300,8 @@ sub OnAction($$)
package JobDetailsPage;
-use ObjectModel::CGI::SimpleCollectionPage; -our @ISA = qw(ObjectModel::CGI::SimpleCollectionPage); +use ObjectModel::CGI::CollectionPage; +our @ISA = qw(ObjectModel::CGI::CollectionPage);
use URI::Escape;
diff --git a/testbot/web/PatchesList.pl b/testbot/web/PatchesList.pl index e756a76ff..49e16d8d2 100644 --- a/testbot/web/PatchesList.pl +++ b/testbot/web/PatchesList.pl @@ -79,10 +79,10 @@ sub GetActions($)
package main;
-use ObjectModel::CGI::SimpleCollectionPage; +use ObjectModel::CGI::CollectionPage; use WineTestBot::Patches;
my $Request = shift; -my $Page = ObjectModel::CGI::SimpleCollectionPage->new($Request, "", CreatePatches(), &PatchesBlock::Create); +my $Page = ObjectModel::CGI::CollectionPage->new($Request, "", CreatePatches(), &PatchesBlock::Create); $Page->SetRefreshInterval(60); $Page->GeneratePage(); diff --git a/testbot/web/admin/BranchesList.pl b/testbot/web/admin/BranchesList.pl index 037023762..27d17fa57 100644 --- a/testbot/web/admin/BranchesList.pl +++ b/testbot/web/admin/BranchesList.pl @@ -22,9 +22,9 @@ use strict;
package main;
-use ObjectModel::CGI::SimpleCollectionPage; +use ObjectModel::CGI::CollectionPage; use WineTestBot::Branches;
my $Request = shift; -my $Page = ObjectModel::CGI::SimpleCollectionPage->new($Request, "admin", CreateBranches()); +my $Page = ObjectModel::CGI::CollectionPage->new($Request, "admin", CreateBranches()); $Page->GeneratePage(); diff --git a/testbot/web/admin/UsersList.pl b/testbot/web/admin/UsersList.pl index 08ae5bffb..f54def261 100644 --- a/testbot/web/admin/UsersList.pl +++ b/testbot/web/admin/UsersList.pl @@ -126,9 +126,9 @@ sub OnItemAction($$$)
package main;
-use ObjectModel::CGI::SimpleCollectionPage; +use ObjectModel::CGI::CollectionPage; use WineTestBot::Users;
my $Request = shift; -my $Page = ObjectModel::CGI::SimpleCollectionPage->new($Request, "admin", CreateUsers(), &UsersBlock::Create); +my $Page = ObjectModel::CGI::CollectionPage->new($Request, "admin", CreateUsers(), &UsersBlock::Create); $Page->GeneratePage(); diff --git a/testbot/web/admin/VMsList.pl b/testbot/web/admin/VMsList.pl index d957b4472..cfd5b91f5 100644 --- a/testbot/web/admin/VMsList.pl +++ b/testbot/web/admin/VMsList.pl @@ -73,9 +73,9 @@ sub OnItemAction($$$)
package main;
-use ObjectModel::CGI::SimpleCollectionPage; +use ObjectModel::CGI::CollectionPage; use WineTestBot::VMs;
my $Request = shift; -my $Page = ObjectModel::CGI::SimpleCollectionPage->new($Request, "admin", CreateVMs(), &VMsBlock::Create); +my $Page = ObjectModel::CGI::CollectionPage->new($Request, "admin", CreateVMs(), &VMsBlock::Create); $Page->GeneratePage();