From 3ae73efc60d570fc3f0e918be3889f0ae5a9f263 Mon Sep 17 00:00:00 2001 From: Sebastin Santy Date: Tue, 4 Jul 2017 01:11:09 +0530 Subject: Bug 1365345 - Modal Bug Entry Prototype --- extensions/BugModal/lib/WebService.pm | 23 +- .../template/en/default/bug_modal/field.html.tmpl | 3 +- extensions/BugModal/web/new_bug.js | 105 ++++-- js/jquery/plugins/selectize/selectize-min.js | 3 + js/jquery/plugins/selectize/selectize.default.css | 394 +++++++++++++++++++++ new_bug.cgi | 23 +- template/en/default/bug/new_bug.html.tmpl | 31 +- 7 files changed, 537 insertions(+), 45 deletions(-) create mode 100644 js/jquery/plugins/selectize/selectize-min.js create mode 100644 js/jquery/plugins/selectize/selectize.default.css 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 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 e84327307..c54f7c257 100644 --- a/extensions/BugModal/template/en/default/bug_modal/field.html.tmpl +++ b/extensions/BugModal/template/en/default/bug_modal/field.html.tmpl @@ -28,6 +28,7 @@ # 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 @@ -218,7 +219,7 @@ END; [% CASE constants.FIELD_TYPE_FREETEXT %] [%# normal input field %] - + [% CASE constants.FIELD_TYPE_USER %] [% IF action && !action.hidden %] + [% PROCESS global/footer.html.tmpl %] \ No newline at end of file -- cgit v1.2.3-24-g4f1b