Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
efa1199a
Commit
efa1199a
authored
Aug 21, 2012
by
Frédéric Buclin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 779747: The "Browse" link in the page header/footer doesn't sort products by classification
r=dkl a=LpSolit
parent
5a68f099
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
22 deletions
+54
-22
Classification.pm
Bugzilla/Classification.pm
+51
-1
describecomponents.cgi
describecomponents.cgi
+2
-1
enter_bug.cgi
enter_bug.cgi
+1
-20
No files found.
Bugzilla/Classification.pm
View file @
efa1199a
...
@@ -15,7 +15,8 @@ use Bugzilla::Util;
...
@@ -15,7 +15,8 @@ use Bugzilla::Util;
use
Bugzilla::
Error
;
use
Bugzilla::
Error
;
use
Bugzilla::
Product
;
use
Bugzilla::
Product
;
use
base
qw(Bugzilla::Field::ChoiceInterface Bugzilla::Object)
;
use
base
qw(Bugzilla::Field::ChoiceInterface Bugzilla::Object Exporter)
;
@
Bugzilla::Classification::
EXPORT
=
qw(sort_products_by_classification)
;
###############################
###############################
#### Initialization ####
#### Initialization ####
...
@@ -152,6 +153,38 @@ sub products {
...
@@ -152,6 +153,38 @@ sub products {
sub
description
{
return
$_
[
0
]
->
{
'description'
};
}
sub
description
{
return
$_
[
0
]
->
{
'description'
};
}
sub
sortkey
{
return
$_
[
0
]
->
{
'sortkey'
};
}
sub
sortkey
{
return
$_
[
0
]
->
{
'sortkey'
};
}
###############################
#### Helpers ####
###############################
# This function is a helper to sort products to be listed
# in global/choose-product.html.tmpl.
sub
sort_products_by_classification
{
my
$products
=
shift
;
my
$list
;
if
(
Bugzilla
->
params
->
{
'useclassification'
})
{
my
$class
=
{};
# Get all classifications with at least one product.
foreach
my
$product
(
@$products
)
{
$class
->
{
$product
->
classification_id
}
->
{
'object'
}
||=
new
Bugzilla::
Classification
(
$product
->
classification_id
);
# Nice way to group products per classification, without querying
# the DB again.
push
(
@
{
$class
->
{
$product
->
classification_id
}
->
{
'products'
}},
$product
);
}
$list
=
[
sort
{
$a
->
{
'object'
}
->
sortkey
<=>
$b
->
{
'object'
}
->
sortkey
||
lc
(
$a
->
{
'object'
}
->
name
)
cmp
lc
(
$b
->
{
'object'
}
->
name
)}
(
values
%
$class
)];
}
else
{
$list
=
[{
object
=>
undef
,
products
=>
$products
}];
}
return
$list
;
}
1
;
1
;
__END__
__END__
...
@@ -208,4 +241,21 @@ A Classification is a higher-level grouping of Products.
...
@@ -208,4 +241,21 @@ A Classification is a higher-level grouping of Products.
=back
=back
=head1 SUBROUTINES
=over
=item C<sort_products_by_classification>
Description: This is a helper which returns a list of products sorted
by classification in a form suitable to be passed to the
global/choose-product.html.tmpl template.
Params: An arrayref of product objects.
Returns: An arrayref of hashes suitable to be passed to
global/choose-product.html.tmpl.
=back
=cut
=cut
describecomponents.cgi
View file @
efa1199a
...
@@ -13,6 +13,7 @@ use Bugzilla;
...
@@ -13,6 +13,7 @@ use Bugzilla;
use
Bugzilla::
Constants
;
use
Bugzilla::
Constants
;
use
Bugzilla::
Util
;
use
Bugzilla::
Util
;
use
Bugzilla::
Error
;
use
Bugzilla::
Error
;
use
Bugzilla::
Classification
;
use
Bugzilla::
Product
;
use
Bugzilla::
Product
;
my
$user
=
Bugzilla
->
login
();
my
$user
=
Bugzilla
->
login
();
...
@@ -40,7 +41,7 @@ unless ($product && $user->can_access_product($product->name)) {
...
@@ -40,7 +41,7 @@ unless ($product && $user->can_access_product($product->name)) {
# product only, to not confuse the user with components of a
# product only, to not confuse the user with components of a
# product he didn't request.
# product he didn't request.
elsif
(
scalar
(
@products
)
>
1
||
$product_name
)
{
elsif
(
scalar
(
@products
)
>
1
||
$product_name
)
{
$vars
->
{
'classifications'
}
=
[{
object
=>
undef
,
products
=>
\
@products
}]
;
$vars
->
{
'classifications'
}
=
sort_products_by_classification
(
\
@products
)
;
$vars
->
{
'target'
}
=
"describecomponents.cgi"
;
$vars
->
{
'target'
}
=
"describecomponents.cgi"
;
# If an invalid product name is given, or the user is not
# If an invalid product name is given, or the user is not
# allowed to access that product, a message is displayed
# allowed to access that product, a message is displayed
...
...
enter_bug.cgi
View file @
efa1199a
...
@@ -25,11 +25,8 @@ use Bugzilla::Constants;
...
@@ -25,11 +25,8 @@ use Bugzilla::Constants;
use
Bugzilla::
Util
;
use
Bugzilla::
Util
;
use
Bugzilla::
Error
;
use
Bugzilla::
Error
;
use
Bugzilla::
Bug
;
use
Bugzilla::
Bug
;
use
Bugzilla::
User
;
use
Bugzilla::
Hook
;
use
Bugzilla::
Hook
;
use
Bugzilla::
Product
;
use
Bugzilla::
Classification
;
use
Bugzilla::
Classification
;
use
Bugzilla::
Keyword
;
use
Bugzilla::
Token
;
use
Bugzilla::
Token
;
use
Bugzilla::
Field
;
use
Bugzilla::
Field
;
use
Bugzilla::
Status
;
use
Bugzilla::
Status
;
...
@@ -67,23 +64,7 @@ if ($product_name eq '') {
...
@@ -67,23 +64,7 @@ if ($product_name eq '') {
my
@classifications
;
my
@classifications
;
unless
(
$classification
&&
$classification
ne
'__all'
)
{
unless
(
$classification
&&
$classification
ne
'__all'
)
{
if
(
Bugzilla
->
params
->
{
'useclassification'
})
{
@classifications
=
@
{
sort_products_by_classification
(
\
@enterable_products
)};
my
$class
;
# Get all classifications with at least one enterable product.
foreach
my
$product
(
@enterable_products
)
{
$class
->
{
$product
->
classification_id
}
->
{
'object'
}
||=
new
Bugzilla::
Classification
(
$product
->
classification_id
);
# Nice way to group products per classification, without querying
# the DB again.
push
(
@
{
$class
->
{
$product
->
classification_id
}
->
{
'products'
}},
$product
);
}
@classifications
=
sort
{
$a
->
{
'object'
}
->
sortkey
<=>
$b
->
{
'object'
}
->
sortkey
||
lc
(
$a
->
{
'object'
}
->
name
)
cmp
lc
(
$b
->
{
'object'
}
->
name
)}
(
values
%
$class
);
}
else
{
@classifications
=
({
object
=>
undef
,
products
=>
\
@enterable_products
});
}
}
}
unless
(
$classification
)
{
unless
(
$classification
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment