summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-07-02 09:44:53 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-07-02 09:44:53 +0000
commit0b16423104f761beef651904855b8a37d0f2cd26 (patch)
treed50d1e6567415ea3d1d71bad8aadf8c3be30e9a9
parentd9a0084b764026af4c07de469810bbbedad08456 (diff)
downloadredmine-0b16423104f761beef651904855b8a37d0f2cd26.tar.gz
redmine-0b16423104f761beef651904855b8a37d0f2cd26.zip
Group versions by status in issue filters (#10412).
git-svn-id: http://svn.redmine.org/redmine/trunk@15601 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/issue_query.rb2
-rw-r--r--app/models/version.rb11
-rw-r--r--public/javascripts/application.js5
-rw-r--r--test/unit/query_test.rb4
4 files changed, 19 insertions, 3 deletions
diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb
index c4ab37d59..807c5cf0e 100644
--- a/app/models/issue_query.rb
+++ b/app/models/issue_query.rb
@@ -201,7 +201,7 @@ class IssueQuery < Query
add_available_filter "fixed_version_id",
: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",
:type => :list_optional,
diff --git a/app/models/version.rb b/app/models/version.rb
index bc71b72e9..86c4cb018 100644
--- a/app/models/version.rb
+++ b/app/models/version.rb
@@ -197,6 +197,17 @@ class Version < ActiveRecord::Base
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
[
completed? ? 'version-completed' : 'version-incompleted',
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index eedeae08b..64d3e8ea9 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -175,6 +175,11 @@ function buildFilterRow(field, operator, values) {
if ($.isArray(filterValue)) {
option.val(filterValue[1]).text(filterValue[0]);
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 {
option.val(filterValue).text(filterValue);
if ($.inArray(filterValue, values) > -1) {option.attr('selected', true);}
diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb
index 2515624d8..d6fa25481 100644
--- a/test/unit/query_test.rb
+++ b/test/unit/query_test.rb
@@ -95,7 +95,7 @@ class QueryTest < ActiveSupport::TestCase
Version.find(2).update_attribute :sharing, 'system'
query = IssueQuery.new(:project => nil, :name => '_')
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
def test_project_filter_in_global_queries
@@ -146,7 +146,7 @@ class QueryTest < ActiveSupport::TestCase
query = IssueQuery.new(:project => Project.find(1), :name => '_')
filter = query.available_filters["fixed_version_id"]
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
def test_query_with_multiple_custom_fields