GitLab steht Mittwoch, den 08. Juli, zwischen 09:00 und 13:00 Uhr aufgrund von Wartungsarbeiten nicht zur Verfügung.

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
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,
......
......@@ -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',
......
......@@ -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);}
......
......@@ -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
......
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