This brings the collection blocks in line with the Submit page.
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- This can be tested on the Users, VMs and Branches administrator pages. --- .../lib/ObjectModel/CGI/CollectionBlock.pm | 36 +++++++------------ 1 file changed, 13 insertions(+), 23 deletions(-)
diff --git a/testbot/lib/ObjectModel/CGI/CollectionBlock.pm b/testbot/lib/ObjectModel/CGI/CollectionBlock.pm index 36f1b0188..3e3ee2952 100644 --- a/testbot/lib/ObjectModel/CGI/CollectionBlock.pm +++ b/testbot/lib/ObjectModel/CGI/CollectionBlock.pm @@ -47,9 +47,12 @@ our @EXPORT = qw(new); use POSIX qw(strftime); use URI::Escape;
+use ObjectModel::CGI::Table; use ObjectModel::CGI::ValueFormatter;
+my $Unique; + =pod =over 12
@@ -82,6 +85,7 @@ sub new($$$@) my $self = {Collection => $Collection, EnclosingPage => $EnclosingPage, RW => 1, + Unique => $Unique++, }; $self = bless $self, $class; $self->_initialize(@_); @@ -331,9 +335,12 @@ sub GenerateHeaderRow($$$) my ($self, $Row) = @_;
print "<tr>\n"; - if (@{$Row->{ItemActions}}) + if (@{$Row->{ItemActions}} and $Row->{Rows}) { - print "<th> </th>\n"; + $self->{EnclosingPage}->GenerateImportJS(GetTableJSFile()); + print "<th>"; + GenerateMasterCheckbox("block$self->{Unique}"); + print "</th>\n"; } foreach my $PropertyDescriptor (@{$Row->{PropertyDescriptors}}) { @@ -377,7 +384,7 @@ sub GenerateDataRow($$) if (@{$Row->{ItemActions}}) { print "<td><input name='", $self->SelName($Row->{Item}->GetKey()), - "' type='checkbox' /></td>\n"; + "' type='checkbox' cbgroup='block$self->{Unique}'/></td>\n"; } foreach my $PropertyDescriptor (@{$Row->{PropertyDescriptors}}) { @@ -442,6 +449,7 @@ EOF $self->GenerateFormStart(); $self->GenerateErrorDiv();
+ my $Items = $self->{Collection}->GetSortedItems(); print "<table border='0' cellpadding='5' cellspacing='0' summary='" . "Overview of " . $Collection->GetCollectionName() . "'>\n"; print "<thead>\n"; @@ -450,12 +458,12 @@ EOF DetailsPage => $self->GetDetailsPage(), ItemActions => $self->{RW} ? $self->GetItemActions() : [], Row => 0, # 0 for the header ---> 1 for the first line + Rows => scalar(@$Items), }; $self->GenerateHeaderRow($Row); print "</thead>\n";
print "<tbody>\n"; - my $Items = $self->{Collection}->GetSortedItems(); foreach my $Item (@$Items) { $Row->{Row}++; @@ -473,25 +481,7 @@ EOF
if (@{$Row->{ItemActions}} and @$Items) { - print <<EOF; -<div class='CollectionBlockActions'> -<script type='text/javascript'> -<!-- -function ToggleAll() -{ - for (var i = 0; i < document.forms[0].elements.length; i++) - { - if(document.forms[0].elements[i].type == 'checkbox') - document.forms[0].elements[i].checked = !(document.forms[0].elements[i].checked); - } -} - -// Only put javascript link in document if javascript is enabled -document.write("<a href='javascript:void(0)' onClick='ToggleAll();'>Toggle All<\\\/a> "); -//--> -</script> -EOF - print "For selected ", $self->{Collection}->GetCollectionName() . ":"; + print "<div class='CollectionBlockActions'>For selected ", $self->{Collection}->GetCollectionName() . ":"; foreach my $Action (@{$Row->{ItemActions}}) { print " <input type='submit' name='Action' value='" .