[tools] testbot/cgi: Better select which FormPage fields can be shown / edited.
Also better document why each type of field can or cannot be edited / shown. Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com> --- testbot/lib/ObjectModel/CGI/FormPage.pm | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/testbot/lib/ObjectModel/CGI/FormPage.pm b/testbot/lib/ObjectModel/CGI/FormPage.pm index 3ac62239d5..e432fcbbd2 100644 --- a/testbot/lib/ObjectModel/CGI/FormPage.pm +++ b/testbot/lib/ObjectModel/CGI/FormPage.pm @@ -208,6 +208,8 @@ sub GetInputType($$) { my ($self, $PropertyDescriptor) = @_; + # Note: Editing Detailrefs and Itemrefs is not supported which leaves only + # Basic and Enum property descriptors here. return $PropertyDescriptor->GetClass() eq "Enum" ? "select" : $PropertyDescriptor->GetType() eq "B" ? "checkbox" : $PropertyDescriptor->GetType() eq "textarea" ? "textarea" : @@ -331,12 +333,20 @@ sub DisplayProperty($$) { my ($self, $PropertyDescriptor) = @_; - if ($PropertyDescriptor->GetClass() eq "Detailref") - { - return ""; - } - - return "rw"; + return # Detailref fields point to a Collection of objects matching the + # primary key of this form data. As such they can neither be shown + # nor edited. + $PropertyDescriptor->GetClass() eq "Detailref" ? "" : + # Itemref fields are keys identifying other objects and thus would + # require careful validation if edited. Requiring users to manually + # 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... + $PropertyDescriptor->GetClass() ne "Basic" ? "rw" : + $PropertyDescriptor->GetType() ne "S" ? "rw" : + # ...except autoincrement ones (shown as <unset> if undefined) + "ro"; } sub GetActions($) -- 2.30.2
participants (1)
-
Francois Gouget