]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Byg 202463 - prefill 'assign to' with default component owner
authorbbaetz%acm.org <>
Sun, 27 Apr 2003 14:12:50 +0000 (14:12 +0000)
committerbbaetz%acm.org <>
Sun, 27 Apr 2003 14:12:50 +0000 (14:12 +0000)
patch by slamm@yahoo-inc.com (Steve Lamm)
r=bbaetz, a=justdave

enter_bug.cgi
template/en/default/bug/create/create.html.tmpl

index 9784b81a3f022a4b56541f17c1cbf741f4020578..8f736ff0396cc4493f9912c979df0ef9cc8fdb44 100755 (executable)
@@ -242,17 +242,19 @@ elsif (1 == @{$::components{$product}}) {
 }
 
 my @components;
-SendSQL("SELECT name, description FROM components " . 
-        "WHERE product_id = $product_id ORDER BY name");
+SendSQL("SELECT name, description, login_name, realname
+             FROM components, profiles
+             WHERE product_id = $product_id
+             AND initialowner=userid
+             ORDER BY name");
 while (MoreSQLData()) {
-    my ($name, $description) = FetchSQLData();
-
-    my %component;
-
-    $component{'name'} = $name;
-    $component{'description'} = $description;
-
-    push @components, \%component;
+    my ($name, $description, $login, $realname) = FetchSQLData();
+    push @components, {
+        name => $name,
+        description => $description,
+        default_login => $login,
+        default_realname => $realname,
+    };
 }
 
 my %default;
index fcc894e1e63cced466d8aac60243b9a37bc03323..4196f77bb9c1c9fb3bb25d9df8f0dd63cb6b7bdb 100644 (file)
 [% PROCESS global/header.html.tmpl
   title = "Enter Bug"
   h2 = "This page lets you enter a new bug into Bugzilla."
+  onload="set_assign_to();"
 %]
 
-<form method="post" action="post_bug.cgi">
+<script type="text/javascript" language="JavaScript">
+<!--
+
+var default_owners = new Array([% component_.size %]);
+var components = new Array([% component_.size %]);
+[% count = 0 %]
+[%- FOREACH c = component_ %]
+    components[[% count %]] = "[% c.name FILTER html %]";
+    default_owners[[% count %]] = "[% c.default_login FILTER html %]";
+    [% count = count + 1 %]
+[%- END %]
+var last_default_owner;
+function set_assign_to() {
+    // Based on the selected component, fill the "Assign To:" field
+    // with the default component owner.
+    var form = document.Create;
+    assigned_to = form.assigned_to.value
+    var index = -1;
+    if (form.component.type == 'select-one') {
+        index = form.component.selectedIndex;
+    } else if (form.component.type == 'hidden') {
+        // Assume there is only one component in the list
+        index = 0;
+    }
+    if (index != -1) {
+        var owner = default_owners[index];
+        var component = components[index];
+        if (assigned_to == last_default_owner
+            || assigned_to == owner
+            || assigned_to == ''
+            || confirm('Would you like to change\n\n' +
+                       '     "Assign To: ' + assigned_to + '"\n\n' +
+                       'to the default "' + component + '" owner:\n\n' +
+                       '     ' + owner + "?")) {
+            form.assigned_to.value = owner;
+            last_default_owner = owner;
+        }
+    }
+}
+-->
+</script>
+
+<form name="Create" id="Create" method="post" action="post_bug.cgi">
 <input type="hidden" name="product" value="[% product FILTER html %]">
 
 <table cellspacing="2" cellpadding="0" border="0">
       </strong>
     </td>
     <td>
-      <select name="component" size="5">
+      <select name="component" onchange="set_assign_to();" size="5">
         [%- FOREACH c = component_ %]
           <option value="[% c.name FILTER html %]"
             [% " selected=\"selected\"" IF c.name == default.component_ %]>
   <tr>
     <td align="right">
       <strong>
-        <a href="bug_status.html#assigned_to">Assigned To</a>:
+        <a href="bug_status.html#assigned_to">Assign To</a>:
       </strong>
     </td>
     <td colspan="3">
       <input name="assigned_to" size="32" 
              value="[% assigned_to FILTER html %]">
-      (Leave blank to assign to default component owner)
+      <noscript>(Leave blank to assign to default component owner)</noscript>
     </td>
   </tr>