[tools] testbot/cgi: Let FormPage operate in read-only mode.
Francois Gouget
fgouget at codeweavers.com
Tue Apr 5 07:20:41 CDT 2022
The FormPage is in read-write mode by default as this is the most common
case, but calling SetReadWrite(0) puts it in read-only mode where it
shows the field values but does not allow modifying them.
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
This will be useful for the failure blacklist details page as it will
operate either in read-only mode or in read-write mode.
---
testbot/lib/ObjectModel/CGI/FormPage.pm | 27 +++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/testbot/lib/ObjectModel/CGI/FormPage.pm b/testbot/lib/ObjectModel/CGI/FormPage.pm
index dfcd55e12..c6a8c6bf1 100644
--- a/testbot/lib/ObjectModel/CGI/FormPage.pm
+++ b/testbot/lib/ObjectModel/CGI/FormPage.pm
@@ -70,6 +70,8 @@ properties that the form should show or allow editing, as specified by
DisplayProperty(). It may be undefined if determining the property list is
delegated to GetPropertyDescriptors().
+By default the form allows modifying the field values.
+
See also Page::new().
=back
@@ -82,11 +84,30 @@ sub _initialize($$$$)
$self->SUPER::_initialize($Request, $RequiredRole);
$self->{PropertyDescriptors} = $PropertyDescriptors;
+ $self->{RW} = 1;
$self->{HasRequired} = !1;
$self->{ActionPerformed} = !1;
$self->{Method} = "post";
}
+=pod
+=over 12
+
+=item C<SetReadWrite()>
+
+If set to true, the form allows editing the fields.
+Otherwise it only shows their values.
+
+=back
+=cut
+
+sub SetReadWrite($$)
+{
+ my ($self, $RW) = @_;
+
+ $self->{RW} = $RW;
+}
+
#
# Property handling
@@ -167,10 +188,12 @@ sub DisplayProperty($$)
# type the appropriate key value would also be cumbersome so this is
# currently not supported. But they can be displayed.
$PropertyDescriptor->GetClass() eq "Itemref" ? "ro" :
- # All other properties can be edited...
+ # All other properties can displayed,
+ !$self->{RW} ? "ro" :
+ # and even edited if in read-write mode...
$PropertyDescriptor->GetClass() ne "Basic" ? "rw" :
$PropertyDescriptor->GetType() ne "S" ? "rw" :
- # ...except autoincrement ones (shown as <unset> if undefined)
+ # ...except autoincrement ones
"ro";
}
--
2.30.2
More information about the wine-devel
mailing list