]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1381749 - Add keywords to new-bug
authorSebastin Santy <sebastinssanty@gmail.com>
Tue, 18 Jul 2017 16:05:42 +0000 (21:35 +0530)
committerDylan William Hardison <dylan@hardison.net>
Tue, 18 Jul 2017 16:05:42 +0000 (12:05 -0400)
extensions/BugModal/lib/WebService.pm
extensions/BugModal/web/new_bug.js
new_bug.cgi
template/en/default/bug/new_bug.html.tmpl

index 99d0383cc8fff59fdcebafb8e2b6f31ba3e8baba..b69d609dd4c9d29a9958c59b4711bf1644516049 100644 (file)
@@ -30,9 +30,9 @@ sub rest_resources {
     return [
         # return all the products accessible by the user.
         # required by new-bug
-        qr{^/bug_modal/products}, {
+        qr{^/bug_modal/initial_field_values}, {
             GET => {
-                method => 'products'
+                method => 'initial_field_values'
             },
         },
 
@@ -82,9 +82,12 @@ sub rest_resources {
     ]
 }
 
-sub products {
+sub initial_field_values {
     my $user = Bugzilla->user;
-    return { products => _name($user->get_enterable_products) };
+    return {
+        products => _name($user->get_enterable_products),
+        keywords => _name([Bugzilla::Keyword->get_all()]),
+    };
 }
 
 sub product_info {
@@ -103,8 +106,10 @@ sub product_info {
             description => $_->description,
         }
     } @{ $product->components };
-    my @versions = map { { name => $_->name } } grep { $_->is_active } @{ $product->versions };
-    return { components => \@components, versions => \@versions };
+    return {
+        components => \@components,
+        versions   => _name($product->versions),
+    };
 }
 
 # everything we need for edit mode in a single call, returning just the fields
index cd471fc2e8e66d83834ae1038be169ce22150459..d00770e3a7d05f2532c445f24d401729dc253907 100644 (file)
@@ -1,20 +1,18 @@
+var initial = {}
 var comp_desc = {}
 
-function load_products(query, callback) {
+$(document).ready(function() {
     bugzilla_ajax(
             {
-                url: 'rest/bug_modal/products'
+                url: 'rest/bug_modal/initial_field_values'
             },
             function(data) {
-                callback(data.products);
+                initial = data
             },
             function() {
-                callback();
+                alert("Network issues. Please refresh the page and try again");
             }
         );
-}
-
-$(document).ready(function() {
     var product_sel = $("#product").selectize({
         valueField: 'name',
         labelField: 'name',
@@ -22,7 +20,9 @@ $(document).ready(function() {
         options: [],
         preload: true,
         create: false,
-        load: load_products
+        load: function(query, callback) {
+            callback(initial.products);
+        }
     });
     var component_sel = $("#component").selectize({
         valueField: 'name',
@@ -38,6 +38,19 @@ $(document).ready(function() {
         options: [],
     });
 
+    var keywords_sel = $("#keywords").selectize({
+        delimiter: ', ',
+        valueField: 'name',
+        labelField: 'name',
+        searchField: 'name',
+        options: [],
+        preload: true,
+        create: false,
+        load: function(query, callback) {
+            callback(initial.keywords);
+        }
+    });
+
     product_sel.on("change", function () {
         $('#product-throbber').show();
         $('#component').attr('disabled', true);
@@ -46,7 +59,6 @@ $(document).ready(function() {
                     url: 'rest/bug_modal/product_info?product=' + encodeURIComponent($('#product').val())
                 },
                 function(data) {
-                    product_info = data;
                     $('#product-throbber').hide();
                     $('#component').attr('disabled', false);
                     $('#comp_desc').text('Select a component to read its description.');
index 8462bb6ff2b189da57abf44e116543f329783d69..2e903cfcebc691f14c9bbc1a08e0d91c8546dbf2 100644 (file)
@@ -42,13 +42,14 @@ use List::MoreUtils qw(uniq);
 
 my $user = Bugzilla->login(LOGIN_REQUIRED);
 
-my $cgi = Bugzilla->cgi;
+my $cgi      = Bugzilla->cgi;
 my $template = Bugzilla->template;
-my $vars = {};
+my $vars     = {};
 
 if (lc($cgi->request_method) eq 'post') {
      my $token = $cgi->param('token');
      check_hash_token($token, ['new_bug']);
+     my @keywords = $cgi->param('keywords');
      my $new_bug = Bugzilla::Bug->create({
                 short_desc   => scalar($cgi->param('short_desc')),
                 product      => scalar($cgi->param('product')),
@@ -57,7 +58,8 @@ if (lc($cgi->request_method) eq 'post') {
                 groups       => [],
                 op_sys       => 'Unspecified',
                 rep_platform => 'Unspecified',
-                version      => join(' ', split('_', scalar($cgi->param('version')))),
+                version      => scalar( $cgi->param('version')),
+                keywords     => \@keywords,
                 cc           => [],
                 comment      => scalar($cgi->param('comment')),
             });
index 274064be3077b46b1e8f8cf555623c51e518e385..5228ceb2d047d447d4643e9a44b8459cbd874736 100644 (file)
         edit_only = 1
         editable = 1
     %]
-    
+    [%# keywords %]
+    [% INCLUDE bug_modal/field.html.tmpl
+        field = bug_fields.keywords
+        field_type = constants.FIELD_TYPE_MULTI_SELECT
+        edit_only = 1
+        editable = 1
+        help = "describekeywords.cgi"
+    %]
  [% END %]
 [% END %]