Commit 951628c9 authored by jplang's avatar jplang

Group versions by status in issue filters (#10412).

git-svn-id: https://svn.redmine.org/redmine/trunk@15601 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 9a3459f0
...@@ -201,7 +201,7 @@ class IssueQuery < Query ...@@ -201,7 +201,7 @@ class IssueQuery < Query
add_available_filter "fixed_version_id", add_available_filter "fixed_version_id",
:type => :list_optional, :type => :list_optional,
:values => versions.sort.collect{|s| ["#{s.project.name} - #{s.name}", s.id.to_s] } :values => Version.sort_by_status(versions).collect{|s| ["#{s.project.name} - #{s.name}", s.id.to_s, l("version_status_#{s.status}")] }
add_available_filter "category_id", add_available_filter "category_id",
:type => :list_optional, :type => :list_optional,
......
...@@ -197,6 +197,17 @@ class Version < ActiveRecord::Base ...@@ -197,6 +197,17 @@ class Version < ActiveRecord::Base
end end
end end
# Sort versions by status (open, locked then closed versions)
def self.sort_by_status(versions)
versions.sort do |a, b|
if a.status == b.status
a <=> b
else
b.status <=> a.status
end
end
end
def css_classes def css_classes
[ [
completed? ? 'version-completed' : 'version-incompleted', completed? ? 'version-completed' : 'version-incompleted',
......
...@@ -175,6 +175,11 @@ function buildFilterRow(field, operator, values) { ...@@ -175,6 +175,11 @@ function buildFilterRow(field, operator, values) {
if ($.isArray(filterValue)) { if ($.isArray(filterValue)) {
option.val(filterValue[1]).text(filterValue[0]); option.val(filterValue[1]).text(filterValue[0]);
if ($.inArray(filterValue[1], values) > -1) {option.attr('selected', true);} if ($.inArray(filterValue[1], values) > -1) {option.attr('selected', true);}
if (filterValue.length == 3) {
var optgroup = select.find('optgroup').filter(function(){return $(this).attr('label') == filterValue[2]});
if (!optgroup.length) {optgroup = $('<optgroup>').attr('label', filterValue[2]);}
option = optgroup.append(option);
}
} else { } else {
option.val(filterValue).text(filterValue); option.val(filterValue).text(filterValue);
if ($.inArray(filterValue, values) > -1) {option.attr('selected', true);} if ($.inArray(filterValue, values) > -1) {option.attr('selected', true);}
......
...@@ -95,7 +95,7 @@ class QueryTest < ActiveSupport::TestCase ...@@ -95,7 +95,7 @@ class QueryTest < ActiveSupport::TestCase
Version.find(2).update_attribute :sharing, 'system' Version.find(2).update_attribute :sharing, 'system'
query = IssueQuery.new(:project => nil, :name => '_') query = IssueQuery.new(:project => nil, :name => '_')
assert query.available_filters.has_key?('fixed_version_id') assert query.available_filters.has_key?('fixed_version_id')
assert query.available_filters['fixed_version_id'][:values].detect {|v| v.last == '2'} assert query.available_filters['fixed_version_id'][:values].detect {|v| v[1] == '2'}
end end
def test_project_filter_in_global_queries def test_project_filter_in_global_queries
...@@ -146,7 +146,7 @@ class QueryTest < ActiveSupport::TestCase ...@@ -146,7 +146,7 @@ class QueryTest < ActiveSupport::TestCase
query = IssueQuery.new(:project => Project.find(1), :name => '_') query = IssueQuery.new(:project => Project.find(1), :name => '_')
filter = query.available_filters["fixed_version_id"] filter = query.available_filters["fixed_version_id"]
assert_not_nil filter assert_not_nil filter
assert_include subproject_version.id.to_s, filter[:values].map(&:last) assert_include subproject_version.id.to_s, filter[:values].map(&:second)
end end
def test_query_with_multiple_custom_fields def test_query_with_multiple_custom_fields
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment