[tools 2/2] testbot/cgi: Add CollectionBlock::GetPropertyValue().

Francois Gouget fgouget at codeweavers.com
Tue May 3 12:48:04 CDT 2022


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 at codeweavers.com>
---
With ValueFormatter generating the HTML is pretty easy but just
returning a value leads to even simpler code with the ternary
operator.
---
 .../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 08844d066..336c7cd05 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});
 }
 
-- 
2.30.2



More information about the wine-devel mailing list