summaryrefslogtreecommitdiffstats
path: root/extensions/BugModal/lib
diff options
context:
space:
mode:
authorSebastin Santy <sebastinssanty@gmail.com>2017-07-03 21:41:09 +0200
committerDylan William Hardison <dylan@hardison.net>2017-07-07 00:19:20 +0200
commit3ae73efc60d570fc3f0e918be3889f0ae5a9f263 (patch)
treed8cfb21d3e5a8d2d3bce51949835b8b6e7686549 /extensions/BugModal/lib
parent6f68125893590fc9de60185f5535bae12adbcb54 (diff)
downloadbugzilla-3ae73efc60d570fc3f0e918be3889f0ae5a9f263.tar.gz
bugzilla-3ae73efc60d570fc3f0e918be3889f0ae5a9f263.tar.xz
Bug 1365345 - Modal Bug Entry Prototype
Diffstat (limited to 'extensions/BugModal/lib')
-rw-r--r--extensions/BugModal/lib/WebService.pm23
1 files changed, 14 insertions, 9 deletions
diff --git a/extensions/BugModal/lib/WebService.pm b/extensions/BugModal/lib/WebService.pm
index 556a2d7cc..99d0383cc 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/components}, {
+ qr{^/bug_modal/product_info}, {
GET => {
- method => 'components',
+ method => 'product_info',
params => sub {
return { product_name => Bugzilla->input_params->{product} }
},
@@ -87,19 +87,24 @@ sub products {
return { products => _name($user->get_enterable_products) };
}
-sub components {
+sub product_info {
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 => Bugzilla::Component->check({ product => $product, name => $_->name })->description} } @{ $product->components };
- return { components => \@components }
+ 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 };
}
# everything we need for edit mode in a single call, returning just the fields