Browse Source

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

git-svn-id: http://svn.redmine.org/redmine/trunk@15601 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/3.4.0
Jean-Philippe Lang 8 years ago
parent
commit
0b16423104
4 changed files with 19 additions and 3 deletions
  1. 1
    1
      app/models/issue_query.rb
  2. 11
    0
      app/models/version.rb
  3. 5
    0
      public/javascripts/application.js
  4. 2
    2
      test/unit/query_test.rb

+ 1
- 1
app/models/issue_query.rb View File

@@ -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,

+ 11
- 0
app/models/version.rb View File

@@ -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',

+ 5
- 0
public/javascripts/application.js View File

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

+ 2
- 2
test/unit/query_test.rb View File

@@ -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

Loading…
Cancel
Save