Module: tools
Branch: master
Commit: 663642b1fd161e5c08d015eb11891993f7479a9d
URL: https://source.winehq.org/git/tools.git/?a=commit;h=663642b1fd161e5c08d015e…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Tue May 3 19:48:04 2022 +0200
testbot/cgi: Add CollectionBlock::GetPropertyValue().
This is practical for adding support for synthesized columns that have
standard values without having to also deal with generating HTML for
them.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
testbot/lib/ObjectModel/CGI/CollectionBlock.pm | 27 +++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/testbot/lib/ObjectModel/CGI/CollectionBlock.pm b/testbot/lib/ObjectModel/CGI/CollectionBlock.pm
index 08844d0..336c7cd 100644
--- a/testbot/lib/ObjectModel/CGI/CollectionBlock.pm
+++ b/testbot/lib/ObjectModel/CGI/CollectionBlock.pm
@@ -173,7 +173,8 @@ By default this matches the property list of the items in the collection and
that list is then pruned by DisplayProperty().
However it is possible to redefine this method to reorder the columns or add
-extra columns where the values will be synthesized by GenerateDataView().
+extra columns where the values will be synthesized by GetPropertyValue() or
+generated directly by GenerateDataView().
=back
=cut
@@ -311,6 +312,27 @@ sub GenerateHeaderView($$$)
=pod
=over 12
+=item C<GetPropertyValue()>
+
+Returns the underlying property value.
+
+This is useful for providing values for the synthetic columns.
+See GenerateDataView().
+
+=back
+=cut
+
+sub GetPropertyValue($$$)
+{
+ my ($self, $Row, $Col) = @_;
+
+ my $PropertyName = $Col->{Descriptor}->GetName();
+ return $Row->{Item}->$PropertyName;
+}
+
+=pod
+=over 12
+
=item C<GenerateDataView()>
Generates an HTML snippet representing the property value in a user-readable
@@ -346,8 +368,7 @@ sub GenerateDataView($$$)
{
my ($self, $Row, $Col) = @_;
- my $PropertyName = $Col->{Descriptor}->GetName();
- my $Value = $Row->{Item}->$PropertyName;
+ my $Value = $self->GetPropertyValue($Row, $Col);
GenerateValueHTML($self, $Col->{Descriptor}, $Value, $Col->{Format});
}
Module: tools
Branch: master
Commit: 38745b4ac3445615c966c4bee226c4b6b2a42548
URL: https://source.winehq.org/git/tools.git/?a=commit;h=38745b4ac3445615c966c4b…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Tue May 3 19:47:59 2022 +0200
testbot/cgi: Allow overriding the collection block's property list.
GetPropertyDescriptors() can now be redefined which allows reordering
the item's properties and inserting extra 'synthetic' ones.
Neither of these was possible by redefining DisplayProperty().
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
testbot/lib/ObjectModel/CGI/CollectionBlock.pm | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/testbot/lib/ObjectModel/CGI/CollectionBlock.pm b/testbot/lib/ObjectModel/CGI/CollectionBlock.pm
index 594ed56..08844d0 100644
--- a/testbot/lib/ObjectModel/CGI/CollectionBlock.pm
+++ b/testbot/lib/ObjectModel/CGI/CollectionBlock.pm
@@ -161,6 +161,29 @@ sub GenerateErrorPopup($)
# Individual item property support
#
+
+=pod
+=over 12
+
+=item C<GetPropertyDescriptors()>
+
+Returns the list of columns for the collection table.
+
+By default this matches the property list of the items in the collection and
+that list is then pruned by DisplayProperty().
+
+However it is possible to redefine this method to reorder the columns or add
+extra columns where the values will be synthesized by GenerateDataView().
+
+=back
+=cut
+
+sub GetPropertyDescriptors($)
+{
+ my ($self) = @_;
+ return $self->{Collection}->GetPropertyDescriptors();
+}
+
=pod
=over 12
@@ -430,7 +453,7 @@ sub GenerateList($)
my ($self) = @_;
my $Collection = $self->{Collection};
- my $PropertyDescriptors = $Collection->GetPropertyDescriptors();
+ my $PropertyDescriptors = $self->GetPropertyDescriptors();
my $ColIndex = 0;
my (@Cols, $HasDT);