Francois Gouget : testbot/cgi: Replace 'toggle all' with a master checkbox.
Alexandre Julliard
julliard at winehq.org
Tue Apr 19 16:14:43 CDT 2022
Module: tools
Branch: master
Commit: 585788aae7865d77c85cc9dfa200cbea3ce1d10d
URL: https://source.winehq.org/git/tools.git/?a=commit;h=585788aae7865d77c85cc9dfa200cbea3ce1d10d
Author: Francois Gouget <fgouget at codeweavers.com>
Date: Tue Apr 19 17:30:25 2022 +0200
testbot/cgi: Replace 'toggle all' with a master checkbox.
This brings the collection blocks in line with the Submit page.
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
testbot/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 36f1b01..3e3ee29 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='" .
More information about the wine-cvs
mailing list