diff options
author | Dylan William Hardison <dylan@hardison.net> | 2017-07-04 01:48:52 +0200 |
---|---|---|
committer | Dylan William Hardison <dylan@hardison.net> | 2017-07-07 00:19:20 +0200 |
commit | a6f98de0d4e842351222b0173a1fff151da8738e (patch) | |
tree | 6d7b2b7885a750826655cf3896d7fd72791623b3 /extensions/BugModal | |
parent | 3ae73efc60d570fc3f0e918be3889f0ae5a9f263 (diff) | |
download | bugzilla-a6f98de0d4e842351222b0173a1fff151da8738e.tar.gz bugzilla-a6f98de0d4e842351222b0173a1fff151da8738e.tar.xz |
Revert "Bug 1365345 - Modal Bug Entry Prototype"
This reverts commit 8835db60a8d637fe3aec82c718bad8a8177a6acf.
Diffstat (limited to 'extensions/BugModal')
-rw-r--r-- | extensions/BugModal/lib/WebService.pm | 23 | ||||
-rw-r--r-- | extensions/BugModal/template/en/default/bug_modal/field.html.tmpl | 3 | ||||
-rw-r--r-- | extensions/BugModal/web/new_bug.js | 105 |
3 files changed, 42 insertions, 89 deletions
diff --git a/extensions/BugModal/lib/WebService.pm b/extensions/BugModal/lib/WebService.pm index 99d0383cc..556a2d7cc 100644 --- a/extensions/BugModal/lib/WebService.pm +++ b/extensions/BugModal/lib/WebService.pm @@ -38,9 +38,9 @@ sub rest_resources { # return all the components pertaining to the product. # required by new-bug - qr{^/bug_modal/product_info}, { + qr{^/bug_modal/components}, { GET => { - method => 'product_info', + method => 'components', params => sub { return { product_name => Bugzilla->input_params->{product} } }, @@ -87,24 +87,19 @@ sub products { return { products => _name($user->get_enterable_products) }; } -sub product_info { +sub components { my ( $self, $params ) = @_; if ( !ref $params->{product_name} ) { untaint( $params->{product_name} ); } else { - ThrowCodeError( 'params_required', { function => 'BugModal.components', params => ['product'] } ); + ThrowCodeError( 'params_required', + { function => 'BugModal.components', params => ['product'] } ); } - my $product = Bugzilla::Product->check( { name => $params->{product_name}, cache => 1 } ); - $product = Bugzilla->user->can_enter_product( $product, 1 ); - my @components = map { - { - name => $_->name, - description => $_->description, - } - } @{ $product->components }; - my @versions = map { { name => $_->name } } grep { $_->is_active } @{ $product->versions }; - return { components => \@components, versions => \@versions }; + my $product = Bugzilla::Product->check({ name => $params->{product_name}, cache => 1 }); + $product = Bugzilla->user->can_enter_product($product, 1); + my @components = map { { name => $_->name, description => Bugzilla::Component->check({ product => $product, name => $_->name })->description} } @{ $product->components }; + return { components => \@components } } # everything we need for edit mode in a single call, returning just the fields diff --git a/extensions/BugModal/template/en/default/bug_modal/field.html.tmpl b/extensions/BugModal/template/en/default/bug_modal/field.html.tmpl index c54f7c257..e84327307 100644 --- a/extensions/BugModal/template/en/default/bug_modal/field.html.tmpl +++ b/extensions/BugModal/template/en/default/bug_modal/field.html.tmpl @@ -28,7 +28,6 @@ # edit html instead of replacing it. forces edit_only (default: false); # default: (string) default value (eg. used as a placeholder in user fields) # help: (string) optional url that describes the field (requires a label to be defined and visible) - # required: (boolean) if the field is required. (At present, only implemented for FIELD_TYPE_FREETEXT) # action: (hash) show a button to the right of the edit field (user fields only currently). keys: # id: (string) optional button id # class: (string) optional button class @@ -219,7 +218,7 @@ END; [% CASE constants.FIELD_TYPE_FREETEXT %] [%# normal input field %] - <input name="[% name FILTER html %]" id="[% name FILTER html %]" value="[% value FILTER html %]" [% aria_labelledby_html FILTER none %] [% "required" IF required %]> + <input name="[% name FILTER html %]" id="[% name FILTER html %]" value="[% value FILTER html %]" [% aria_labelledby_html FILTER none %]> [% CASE constants.FIELD_TYPE_USER %] [% IF action && !action.hidden %] <button class="field-button minor [%= action.class FILTER html IF action.class %]" diff --git a/extensions/BugModal/web/new_bug.js b/extensions/BugModal/web/new_bug.js index cd471fc2e..cd1b16453 100644 --- a/extensions/BugModal/web/new_bug.js +++ b/extensions/BugModal/web/new_bug.js @@ -1,89 +1,48 @@ -var comp_desc = {} - -function load_products(query, callback) { +$(document).ready(function() { bugzilla_ajax( { url: 'rest/bug_modal/products' }, function(data) { - callback(data.products); + $('#product').empty() + $('#product').append($('<option>', { value: 'Select Product', text: 'Select Product' })); + // populate select menus + $.each(data.products, function(key, value) { + $('#product').append($('<option>', { value: value.name, text: value.name })); + }); }, - function() { - callback(); - } + function() {} ); -} - -$(document).ready(function() { - var product_sel = $("#product").selectize({ - valueField: 'name', - labelField: 'name', - searchField: 'name', - options: [], - preload: true, - create: false, - load: load_products - }); - var component_sel = $("#component").selectize({ - valueField: 'name', - labelField: 'name', - searchField: 'name', - options: [], - }); - var version_sel = $("#version").selectize({ - valueField: 'name', - labelField: 'name', - searchField: 'name', - options: [], - }); + $('#component').empty() + $('#component').append($('<option>', { value: 'Select Component', text: 'Select Component' })); - product_sel.on("change", function () { + $('#product') + .change(function(event) { $('#product-throbber').show(); $('#component').attr('disabled', true); + $("#product option[value='Select Product']").remove(); bugzilla_ajax( - { - 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.'); - var selectize = $("#component")[0].selectize; - selectize.clear(); - selectize.clearOptions(); - selectize.load(function(callback) { - callback(data.components) - }); - - for (var i in data.components) - comp_desc[data.components[i]["name"]] = data.components[i]["description"]; - - selectize = $("#version")[0].selectize; - selectize.clear(); - selectize.clearOptions(); - selectize.load(function(callback) { - callback(data.versions); - }); - }, - function() { - alert("Network issues. Please refresh the page and try again"); - } - ); + { + url: 'rest/bug_modal/components?product=' + encodeURIComponent($('#product').val()) + }, + function(data) { + $('#product-throbber').hide(); + $('#component').attr('disabled', false); + $('#component').empty(); + $('#component').append($('<option>', { value: 'Select Component', text: 'Select Component' })); + $('#comp_desc').text('Select a component to read its description.'); + $.each(data.components, function(key, value) { + $('#component').append('<option value=' + value.name + ' desc=' + value.description.split(' ').join('_') + '>' + value.name + '</option>'); + }); + }, + function() {} + ); }); - - component_sel.on("change", function () { - var selectize = $("#component")[0].selectize; - $('#comp_desc').text(comp_desc[selectize.getValue()]); + $('#component') + .change(function(event) { + $("#component option[value='Select Product']").remove(); + $('#comp_desc').text($('#component').find(":selected").attr('desc').split('_').join(' ')); }); - - $('.create-btn') - .click(function(event) { - event.preventDefault(); - if (document.newbugform.checkValidity && !document.newbugform.checkValidity()) - return; - this.form.submit() - }); }); |