Francois Gouget : testbot/cgi: Don't show autoincrement fields of new items.

Alexandre Julliard julliard at winehq.org
Tue Mar 22 16:37:57 CDT 2022


Module: tools
Branch: master
Commit: 0a18c4e022589dabd375a51f5c979a296f180f83
URL:    https://source.winehq.org/git/tools.git/?a=commit;h=0a18c4e022589dabd375a51f5c979a296f180f83

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Tue Mar 22 13:15:17 2022 +0100

testbot/cgi: Don't show autoincrement fields of new items.

They don't have a value yet and cannot be edited.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 testbot/lib/ObjectModel/CGI/ItemPage.pm | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/testbot/lib/ObjectModel/CGI/ItemPage.pm b/testbot/lib/ObjectModel/CGI/ItemPage.pm
index 9401154..a178aa6 100644
--- a/testbot/lib/ObjectModel/CGI/ItemPage.pm
+++ b/testbot/lib/ObjectModel/CGI/ItemPage.pm
@@ -99,13 +99,16 @@ sub DisplayProperty($$)
   my ($self, $PropertyDescriptor) = @_;
 
   my $Display = $self->SUPER::DisplayProperty($PropertyDescriptor);
-  if ($Display eq "rw" && ! $self->{Item}->GetIsNew() &&
-      $PropertyDescriptor->GetIsKey())
-  {
-    $Display = "";
-  }
-
-  return $Display;
+  return # Don't show autoincrement fields of new items: they don't have a
+         # value yet and cannot be edited anyway so there is no point.
+         ($PropertyDescriptor->GetClass() eq "Basic" and
+          $PropertyDescriptor->GetType() eq "S" and
+          $self->{Item}->GetIsNew()) ? "" :
+         # Don't allow editing key attributes of existing items. Furthermore
+         # the item is identified in the page title so hide them altogether.
+         ($PropertyDescriptor->GetIsKey() and !$self->{Item}->GetIsNew() and
+          $Display eq "rw") ? "" :
+         $Display;
 }
 
 sub GetActions($)




More information about the wine-cvs mailing list