]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 465589: Already selected user accounts are no longer displayed when usemenuforuse...
authorlpsolit%gmail.com <>
Mon, 29 Dec 2008 00:05:06 +0000 (00:05 +0000)
committerlpsolit%gmail.com <>
Mon, 29 Dec 2008 00:05:06 +0000 (00:05 +0000)
Bugzilla/Template.pm
t/008filter.t
template/en/default/admin/components/create.html.tmpl
template/en/default/bug/create/create.html.tmpl
template/en/default/bug/edit.html.tmpl
template/en/default/global/userselect.html.tmpl
template/en/default/list/edit-multiple.html.tmpl

index 8a322fae58708bb49310ab588a7515eeea2b46b4..68773d4e738a9c45aea3130193358cf1b732b3d6 100644 (file)
@@ -388,6 +388,13 @@ $Template::Stash::LIST_OPS->{ containsany } =
       return 0;
   };
 
+# Clone the array reference to leave the original one unaltered.
+$Template::Stash::LIST_OPS->{ clone } =
+  sub {
+      my $list = shift;
+      return [@$list];
+  };
+
 # Allow us to still get the scalar if we use the list operation ".0" on it,
 # as we often do for defaults in query.cgi and other places.
 $Template::Stash::SCALAR_OPS->{ 0 } = 
index d999e200858762ae2b97fe5bb745ec79f2b412a8..9a53ced93a8bc1d3d25c20a14e70e79c551e7087 100644 (file)
@@ -211,7 +211,7 @@ sub directive_ok {
     return 1 if $directive =~ /^(time2str|url)\(/;
 
     # Safe Template Toolkit virtual methods
-    return 1 if $directive =~ /\.(length$|size$|push\()/;
+    return 1 if $directive =~ /\.(length$|size$|push\(|delete\()/;
 
     # Special Template Toolkit loop variable
     return 1 if $directive =~ /^loop\.(index|count)$/;
index 86411adad961e814b7d1dd2d94a6f22da5822a65..0949837fc61fa764853db907f1f74efa191c2bc1 100644 (file)
@@ -52,7 +52,6 @@
         [% INCLUDE global/userselect.html.tmpl
            name => "initialowner"
            id => "initialowner"
-           value => ""
            size => 64
          %]
       </td>
@@ -65,7 +64,6 @@
         [% INCLUDE global/userselect.html.tmpl
            name => "initialqacontact"
            id => "initialqacontact"
-           value => ""
            size => 64
            emptyok => 1
          %]
@@ -80,7 +78,6 @@
         [% INCLUDE global/userselect.html.tmpl
            name => "initialcc"
            id => "initialcc"
-           value => ""
            size => 64
            multiple => 5
         %]
index aaf2de5a6b7738b56e9c46aebabe35265807426a..ee819a2aae56bbf0327a7b0edfb6b960989861d1 100644 (file)
@@ -198,11 +198,23 @@ function handleWantsAttachment(wants_attachment) {
     </th>
     <td>
       <select name="component" onchange="set_assign_to();" size="7">
+        [%# Build the lists of assignees and QA contacts if "usemenuforusers" is enabled. %]
+        [% IF Param("usemenuforusers") %]
+          [% assignees_list = user.get_userlist.clone %]
+          [% qa_contacts_list = user.get_userlist.clone %]
+        [% END %]
+
         [%- FOREACH c = product.components %]
           <option value="[% c.name FILTER html %]"
             [% " selected=\"selected\"" IF c.name == default.component_ %]>
             [% c.name FILTER html -%]
           </option>
+          [% IF Param("usemenuforusers") %]
+            [% INCLUDE build_userlist default_user = c.default_assignee,
+                                      userlist = assignees_list %]
+            [% INCLUDE build_userlist default_user = c.default_qa_contact,
+                                      userlist = qa_contacts_list %]
+          [% END %]
         [%- END %]
       </select>
     </td>
@@ -342,6 +354,7 @@ function handleWantsAttachment(wants_attachment) {
          disabled => assigned_to_disabled
          size => 30
          emptyok => 1
+         custom_userlist => assignees_list
        %]
       <noscript>(Leave blank to assign to component's default assignee)</noscript>
     </td>
@@ -357,6 +370,7 @@ function handleWantsAttachment(wants_attachment) {
          disabled => qa_contact_disabled
          size => 30
          emptyok => 1
+         custom_userlist => qa_contacts_list
        %]
         <noscript>(Leave blank to assign to default qa contact)</noscript>
       </td>
@@ -630,3 +644,21 @@ function handleWantsAttachment(wants_attachment) {
     </select>
   </td>
 [% END %]
+
+[% BLOCK build_userlist %]
+  [% user_found = 0 %]
+  [% default_login = default_user.login %]
+  [% RETURN UNLESS default_login %]
+
+  [% FOREACH user = userlist %]
+    [% IF user.login == default_login %]
+      [% user_found = 1 %]
+      [% LAST %]
+    [% END %]
+  [% END %]
+
+  [% userlist.push({login    => default_login,
+                    identity => default_user.identity,
+                    visible  => 1})
+     UNLESS user_found %]
+[% END %]
index 3f519bfa9abf79ac32f5528f375e006d944947c7..9923f004948b805c172360938d29287b41936208 100644 (file)
             [% INCLUDE global/userselect.html.tmpl
                 id => "newcc"
                 name => "newcc"
-                value => ""
                 size => 30
                 multiple => 5
               %]
index e27ca0d6ff2867a82f096b03d37dab687814d6e8..35075ef9de7b9fd8d5862babc88d511566126fed 100644 (file)
@@ -11,6 +11,7 @@
   # The Original Code is the Bugzilla Bug Tracking System.
   #
   # Contributor(s): Byron Jones <bugzilla@glob.com.au>
+  #                 Frédéric Buclin <LpSolit@gmail.com>
   #%]
 
 [%# INTERFACE:
@@ -23,7 +24,6 @@
   # size: optional, input only; size attribute value
   # 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
   #%]
 
     <option value=""></option>
   [% END %]
 
-  [% IF do_not_change %]
-    <option value="[% do_not_change FILTER html %]">
-      [% do_not_change FILTER html %]
-    </option>
-  [% END %]
-
   [% UNLESS custom_userlist %]
     [% custom_userlist = user.get_userlist %]
   [% END %]
 
   [% SET selected = {} %]
-  [% FOREACH selected_value IN value.split(', ') %]
-    [% SET selected.$selected_value = 1 %]
+  [% IF value.defined %]
+    [% FOREACH selected_value IN value.split(', ') %]
+      [% SET selected.$selected_value = 1 %]
+    [% END %]
   [% END %]
+
   [% FOREACH tmpuser = custom_userlist %]
     [% IF tmpuser.visible OR selected.${tmpuser.login} == 1 %]
       <option value="[% tmpuser.login FILTER html %]"
-        [% " selected=\"selected\"" IF selected.${tmpuser.login} == 1 %]
+        [% IF selected.${tmpuser.login} == 1 %]
+          selected="selected"
+          [%# A user account appears only once. Remove it from the list, so that
+            # we know if there are some selected accounts which have not been listed. %]
+          [% selected.delete(tmpuser.login) %]
+        [% END %]
       >[% tmpuser.identity FILTER html %]</option>
     [% END %]
   [% END %]
+
+  [%# If the list is not empty, this means some accounts have not been mentioned yet. %]
+  [% FOREACH selected_user = selected.keys %]
+    <option value="[% selected_user FILTER html %]" selected="selected">[% selected_user FILTER html %]</option>
+  [% END %]
 </select>
 [% ELSE %]
 <input
index 190628fa9d950186d0f1be1dc25d4d028291124d..7c152e928ad1c1ecadc59f4c88550dbd3b7b1762 100644 (file)
            id => "assigned_to"
            name => "assigned_to"
            value => dontchange
-           do_not_change => dontchange
            size => 32
       %]
       <input type="checkbox" id="set_default_assignee" name="set_default_assignee" value="1">
              id => "qa_contact"
              name => "qa_contact"
              value => dontchange
-             do_not_change => dontchange
              size => 32
         %]
         <input type="checkbox" id="set_default_qa_contact" name="set_default_qa_contact" value="1">