:values => lambda { subproject_values }
end
+ add_available_filter("project.status",
+ :type => :list,
+ :name => l(:label_attribute_of_project, :name => l(:field_status)),
+ :values => lambda { project_statuses_values }
+ ) if project.nil? || !project.leaf?
+
add_custom_fields_filters(issue_custom_fields)
add_associations_custom_fields_filters :project, :author, :assigned_to, :fixed_version
"(#{sql})"
end
+ def sql_for_project_status_field(field, operator, value, options={})
+ sql_for_field(field, operator, value, Project.table_name, "status")
+ end
+
def find_assigned_to_id_filter_values(values)
Principal.visible.where(:id => values).map {|p| [p.name, p.id.to_s]}
end
STATUS_CLOSED = 5
STATUS_ARCHIVED = 9
+ LABEL_BY_STATUS = {
+ 1 => l(:project_status_active),
+ 5 => l(:project_status_closed),
+ 9 => l(:project_status_archived),
+ }
+
# Maximum length for project identifiers
IDENTIFIER_MAX_LENGTH = 100
end
end
+ # Returns a scope of project statuses that are available as columns or filters
+ def project_statuses_values
+ project_statuses = Project::LABEL_BY_STATUS
+ # Remove archived status from filters
+ project_statuses.delete(9)
+ project_statuses.stringify_keys.invert.to_a
+ end
+
# Adds available filters
def initialize_available_filters
# implemented by sub-classes
+<div class="contextual">
+ «
+ <% unless @changeset.previous.nil? -%>
+ <%= link_to_revision(@changeset.previous, @repository,
+ :text => l(:label_previous), :accesskey => accesskey(:previous)) %>
+ <% else -%>
+ <%= l(:label_previous) %>
+ <% end -%>
+|
+ <% unless @changeset.next.nil? -%>
+ <%= link_to_revision(@changeset.next, @repository,
+ :text => l(:label_next), :accesskey => accesskey(:next)) %>
+ <% else -%>
+ <%= l(:label_next) %>
+ <% end -%>
+ »
+
+ <%= form_tag({:controller => 'repositories',
+ :action => 'revision',
+ :id => @project,
+ :repository_id => @repository.identifier_param,
+ :rev => nil},
+ :method => :get) do %>
+ <%= text_field_tag 'rev', @rev, :size => 8 %>
+ <%= submit_tag 'OK', :name => nil %>
+ <% end %>
+</div>
<% if @changeset && @changeset_to.nil? %>
<%= render :partial => 'changeset' %>
<% else %>
assert_equal [3, 5], issues_in_list.map(&:project_id).uniq.sort
end
+ def test_index_with_project_status_filter
+ project = Project.find(2)
+ project.close
+ project.save
+
+ get :index, :params => {
+ :set_filter => 1,
+ :f => ['project.status'],
+ :op => {'project.status' => '='},
+ :v => {'project.status' => ['1']}
+ }
+
+ assert_response :success
+
+ issues = issues_in_list.map(&:id).uniq.sort
+ assert_include 1, issues
+ assert_not_include 4, issues
+ end
+
def test_index_with_query
get :index, :params => {
:project_id => 1,
with_locale 'en' do
options = filters_options_for_select(IssueQuery.new)
assert_select_in options, 'optgroup[label=?]', 'Project', 1
- assert_select_in options, 'optgroup[label=?] > option', 'Project', 2
+ assert_select_in options, 'optgroup[label=?] > option', 'Project', 3
assert_select_in options, 'optgroup > option[value=?]', "project.cf_#{cf1.id}", :text => "Project's Foo"
end
end
assert_equal ['1','2','3','4','5','6'], query.available_filters['status_id'][:values].map(&:second)
end
+
+ def test_project_status_filter_should_be_available_in_global_queries
+ query = IssueQuery.new(:project => nil, :name => '_')
+ assert query.available_filters.has_key?('project.status')
+ end
+
+ def test_project_status_filter_should_be_available_when_project_has_subprojects
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
+ assert query.available_filters.has_key?('project.status')
+ end
+
+ def test_project_status_filter_should_not_be_available_when_project_is_leaf
+ query = IssueQuery.new(:project => Project.find(2), :name => '_')
+ assert !query.available_filters.has_key?('project.status')
+ end
+
+ def test_project_statuses_values_should_return_only_active_and_closed_statuses
+ query = IssueQuery.new(:project => nil, :name => '_')
+ project_status_filter = query.available_filters['project.status']
+ assert_not_nil project_status_filter
+
+ assert_equal [["active", "1"], ["closed", "5"]], project_status_filter[:values]
+ end
end