help-gnats
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removed lines in responsible


From: Lars Henriksen
Subject: Re: Removed lines in responsible
Date: Mon, 28 Oct 2002 09:37:28 +0100
User-agent: Mutt/1.4i

On Sun, Oct 27, 2002 at 10:48:14PM +0100, Yngve Svendsen wrote:
> At 13:25 24.10.2002 +0200, Lars Henriksen wrote:
> ... 
> Committed. there were some problems with hash references, but I cleaned it 
> up.

Oops. Sorry about that. Some of my local changes crept in here. I have found
that with many categories and many responsibles, it's nice to have the menues
alphabetically sorted (as they were in gnatsweb 2.9.3). I have been planning
to submit a patch so here it comes (see below).

> >It is a general solution for all unknown enumeration type values, not just
> >responsible. The solution leaves the gnatsweb query format unchanged, i.e.
> >enumeration values are still returned as integers.
> 
> In a longer perspective, we should probably look into stopping doing that. 
> Using integer values messes up the sorting system for instance, since you 
> do not get an alphabetical order of values when you sort query results on 
> an enumerated value field ("sort" should rather be called "group" for that 
> kind of field).

For some fields, e.g. "state", that is what I want: first the open PRs, then
the analyzed etc. and finally the closed. For responsible I keep the entries
in alphabetical order in the file.

> >The net effect is that for enumeration type values which are undefined,
> >"unknown" is displayed in query results and is preselected in drop-down 
> >menues
> >on the Edit page (thus forcing an explicit change).
> 
> I toyed with the idea of changing "unknown" to "Select value".
> 
> (snip)
> 
> >Finally, "unknown" is preselected as Category on the Create page. This is 
> >not
> >related to the other changes. It forces users to select a category. 
> >Experience
> >shows that users often forget to do so; the new PR is then created in the
> >default category (pending, the first category in the categories file).

You get the above effect for Category if you add an entry to the categories
file like

unknown:Select value:gnats-admin:

For responsible I use a similar thing.

Lars Henriksen

Index: gnatsweb.pl
===================================================================
RCS file: /cvsroot/gnatsweb/gnatsweb/gnatsweb.pl,v
retrieving revision 1.115
diff -u -r1.115 gnatsweb.pl
--- gnatsweb.pl 27 Oct 2002 22:33:18 -0000      1.115
+++ gnatsweb.pl 28 Oct 2002 08:33:07 -0000
@@ -1063,7 +1063,10 @@
     # Get default value(s).
     my $default = fieldinfo($_, 'default');
 
-    my $values = fieldinfo($_, 'values');
+    my @values = @{fieldinfo($_, 'values')};
+    if ($_ eq $CATEGORY_FIELD || $_ eq $SUBMITTER_ID_FIELD) {
+      @values = sort {lc($a) cmp lc($b)} @values;
+    }
 
     # The "intro" provides a way for the site callback to print something
     # at the top of a given field.
@@ -1084,13 +1087,13 @@
         push(@$values, "unknown") if (!grep /^unknown$/, @$values);
         $default = "unknown";
       }
-      print popup_or_scrolling_menu($_, $values, $default),
+      print popup_or_scrolling_menu($_, address@hidden, $default),
             "</td>\n</tr>\n";
     }
     elsif (fieldinfo ($_, 'fieldtype') eq 'multienum')
     {
       my $defaultsref = parse_multienum($default, $_);
-      print multiselect_menu($_, $values, $defaultsref),
+      print multiselect_menu($_, address@hidden, $defaultsref),
             "</td>\n</tr>\n";
     }
     elsif (fieldinfo($_, 'fieldtype') eq "multitext")
@@ -1563,7 +1566,12 @@
 
     $field_number++;
 
-    my $values = fieldinfo($_, 'values');
+    my @values = @{fieldinfo ($_, 'values')};
+    if ($_ eq $CATEGORY_FIELD ||
+        $_ eq $SUBMITTER_ID_FIELD ||
+        $_ eq $RESPONSIBLE_FIELD) {
+      @values = sort {lc($a) cmp lc($b)} @values;
+    }
 
     # The "intro" provides a way for the site callback to print something
     # at the top of a given field.
@@ -1576,18 +1584,18 @@
     {
       my $default = $fields{$_};
       # Check whether field value is a known enumeration value.
-      if (!(grep /^$default$/, @$values))
+      if (!(grep /^$default$/, @values))
       {
-       push(@$values, 'unknown') if (!grep /^unknown$/, @$values);
+       push(@values, 'unknown') if (!grep /^unknown$/, @values);
        $default = 'unknown';
       }
-      print popup_or_scrolling_menu($_, $values, $default),
+      print popup_or_scrolling_menu($_, address@hidden, $default),
             "</td>\n</tr>\n";
     }
     elsif (fieldinfo ($_, 'fieldtype') eq 'multienum')
     {
       my $defaultsref = parse_multienum($fields{$_}, $_);
-      print multiselect_menu($_, $values, $defaultsref),
+      print multiselect_menu($_, address@hidden, $defaultsref),
       "</td>\n</tr>\n";
     }
     elsif (fieldinfo ($_, 'fieldtype') eq 'multitext')
@@ -1867,8 +1875,11 @@
     if (fieldinfo($_, 'fieldtype') =~ /enum/)
     {
       print "<tr><td valign=top>$_:</td>\n<td>";
-      my $value_list=fieldinfo($_, 'values');
-      my @values=('any', @$value_list);
+      my @address@hidden($_, 'values')};
+      if ($_ eq $RESPONSIBLE_FIELD || $_ eq $CATEGORY_FIELD) {
+       @values=sort {lc($a) cmp lc($b)} @values;
+      }
+      @values=('any', @values);
       if (fieldinfo($_, 'fieldtype') eq 'enum')
       {
         print popup_or_scrolling_menu ($_, address@hidden, $values[0]);
@@ -2054,11 +2065,15 @@
     print "<td>";
     if (fieldinfo($_, 'fieldtype') =~ 'enum')
     {
-      my $ary_ref = fieldinfo($_, 'values');
+      my @values = @{fieldinfo($_, 'values')};
+      if ($_ eq $RESPONSIBLE_FIELD || $_ eq $CATEGORY_FIELD)
+      {
+        @values = sort {lc($a) cmp lc($b)} @values;
+      }
       my $size = scalar(@$ary_ref);
       $size = 4 if $size > 4;
       print $q->scrolling_list(-name=>$_,
-                               -values=>$ary_ref,
+                               -values=>address@hidden,
                                -multiple=>1,
                                -size=>$size);
     }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]