]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 339437: Make flag requestee a select box and limit users to requestable only...
authorlpsolit%gmail.com <>
Thu, 5 Jul 2007 02:05:58 +0000 (02:05 +0000)
committerlpsolit%gmail.com <>
Thu, 5 Jul 2007 02:05:58 +0000 (02:05 +0000)
Bugzilla/FlagType.pm
skins/standard/global.css
template/en/default/attachment/edit.html.tmpl
template/en/default/flag/list.html.tmpl
template/en/default/global/userselect.html.tmpl

index 1504be87d3df981ca7cfa2537015c43df36e8545..ffa36863ef3c508d188ba5c944a4bb69db3fe086 100644 (file)
@@ -186,6 +186,11 @@ sub sortkey          { return $_[0]->{'sortkey'};          }
 
 =over
 
+=item C<grant_list>
+
+Returns a reference to an array of users who have permission to grant this flag type.
+The arrays are populated with hashrefs containing the login, identity and visibility of users.
+
 =item C<grant_group>
 
 Returns the group (as a Bugzilla::Group object) in which a user
@@ -214,6 +219,17 @@ explicitly excluded from the flagtype.
 
 =cut
 
+sub grant_list {
+    my $self = shift;
+    my @custusers;
+    my @allusers = @{Bugzilla->user->get_userlist};
+    foreach my $user (@allusers) {
+        my $user_obj = new Bugzilla::User({name => $user->{login}});
+        push(@custusers, $user) if $user_obj->can_set_flag($self);
+    }
+    return \@custusers;
+}
+
 sub grant_group {
     my $self = shift;
 
index 5c03f8832b583a23ee30e94a3efc42bbfe7be77f..b729b1aad6102e82968f891c72a69ed1b87ba007 100644 (file)
@@ -259,7 +259,7 @@ span.quote {
 
 table#flags th,
 table#flags td {
-    vertical-align: baseline;
+    vertical-align: middle;
     text-align: left;
 }
 
index 94581ab564b40c72f3d15bd9beeab0ec4f519d10..d0a75b3fd1122d86c00e54aa0cde0ad2a69a62ef 100644 (file)
@@ -40,8 +40,6 @@
     table.attachment_info th { text-align: right; vertical-align: top; }
     table.attachment_info td { text-align: left; vertical-align: top; }
     #noview { text-align: left; vertical-align: middle; }
-
-    table#flags th, table#flags td { font-size: small; vertical-align: baseline; text-align: left; }
   "
 %]
 
index 61ecf2dfafba7e461164b14bef1dafc755c7ba9e..308552d2529c28931ed4022ddaf50cd6545ec39b 100644 (file)
   function disableRequesteeFields()
   {
     var inputElements = document.getElementsByTagName("input");
+    var selectElements = document.getElementsByTagName("select");
+    //You cannot update Node lists, so you must create an array to combine the NodeLists
+    var allElements = [];
+    for( var i=0; i < inputElements.length; i++ ) {
+        allElements[allElements.length] = inputElements.item(i);
+    }
+    for( var i=0; i < selectElements.length; i++ ) { //Combine inputs with selects
+        allElements[allElements.length] = selectElements.item(i);
+    }
     var inputElement, id, flagField;
-    for ( var i=0 ; i<inputElements.length ; i++ )
+    for ( var i=0 ; i<allElements.length ; i++ )
     {
-      inputElement = inputElements.item(i);
+      inputElement = allElements[i];
       if (inputElement.name.search(/^requestee(_type)?-(\d+)$/) != -1)
       {
         // Convert the ID of the requestee field into the ID of its corresponding
           <td>
             [% IF type.is_active && type.is_requesteeble %]
               <span style="white-space: nowrap;">
-                (<input type="text" size="30" maxlength="255"
-                        id="requestee-[% flag.id %]" 
-                        name="requestee-[% flag.id %]"
-                        [% IF flag.status == "?" && flag.requestee %]
-                          value="[% flag.requestee.login FILTER html %]"
-                        [% END %]
-                 >)
+                [% IF Param('usemenuforusers') %]
+                  [% INCLUDE global/userselect.html.tmpl
+                             name     => "requestee-$flag.id"
+                             id       => "requestee-$flag.id"
+                             value    => flag.requestee.login
+                             multiple => 0
+                             emptyok  => 1
+                             custom_userlist => flag.type.grant_list
+                  %]
+                [% ELSE %]
+                  (<input type="text" size="30" maxlength="255"
+                          id="requestee-[% flag.id %]" 
+                          name="requestee-[% flag.id %]"
+                          [% IF flag.status == "?" && flag.requestee %]
+                            value="[% flag.requestee.login FILTER html %]"
+                          [% END %]>)
+                [% END %]
               </span>
             [% END %]
           </td>
           <td>
             [% IF type.is_requesteeble %]
               <span style="white-space: nowrap;">
-                (<input type="text" size="30" maxlength="255"
-                        id="requestee_type-[% type.id %]" 
-                        name="requestee_type-[% type.id %]">)
+                [% IF Param('usemenuforusers') %]
+                  [% INCLUDE global/userselect.html.tmpl
+                             name     => "requestee_type-$type.id"
+                             id       => "requestee_type-$type.id"
+                             multiple => type.is_multiplicable * 3
+                             emptyok  => !type.is_multiplicable
+                             custom_userlist => type.grant_list
+                  %]
+                [% ELSE %]
+                  (<input type="text" size="30" maxlength="255"
+                          id="requestee_type-[% type.id %]"
+                          name="requestee_type-[% type.id %]">)
+                [% END %]
               </span>
             [% END %]
           </td>
       [% IF any_flags_requesteeble %]
         <td>
           [% IF type.is_requesteeble %]
-              <span style="white-space: nowrap;">
+            <span style="white-space: nowrap;">
+              [% IF Param('usemenuforusers') %]
+                [% INCLUDE global/userselect.html.tmpl
+                           name     => "requestee_type-$type.id"
+                           id       => "requestee_type-$type.id"
+                           multiple => type.is_multiplicable * 3
+                           emptyok  => !type.is_multiplicable
+                           custom_userlist => type.grant_list
+                %]
+              [% ELSE %]
                 (<input type="text" size="30" maxlength="255"
                         id="requestee_type-[% type.id %]" 
                         name="requestee_type-[% type.id %]">)
-              </span>
+              [% END %]
+            </span>
           [% END %]
         </td>
       [% END %]
index 398300b5263cd7f2d4c279cc9e295163b13b6d80..8fa7e0360ac16df6624d6474839fdb16e42fae18 100644 (file)
@@ -25,6 +25,7 @@
   # emptyok: optional, select only;  if true, prepend menu option to start of select
   # multiple: optional, do multiselect box, value is size (height) of box
   # do_not_change: optional, contains the string meaning "do not alter this role"
+  # custom_userlist: optional, specify a limited list of users to use
   #%]
 
 [% IF Param("usemenuforusers") %]
     </option>
   [% END %]
 
-  [% FOREACH tmpuser = user.get_userlist %]
+  [% UNLESS custom_userlist %]
+    [% custom_userlist = user.get_userlist %]
+  [% END %]
+
+  [% FOREACH tmpuser = custom_userlist %]
     [% IF tmpuser.visible OR value.match("\\b$tmpuser.login\\b") %]
       <option value="[% tmpuser.login FILTER html %]"
         [% " selected=\"selected\"" IF value.match("\\b$tmpuser.login\\b") %]