mirror of
https://github.com/redmine/redmine.git
synced 2025-11-02 19:36:00 +01:00
Enable filtering versions on Project -> Settings -> Versions (#22608).
git-svn-id: http://svn.redmine.org/redmine/trunk@15759 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -155,6 +155,10 @@ class ProjectsController < ApplicationController
|
|||||||
@issue_category ||= IssueCategory.new
|
@issue_category ||= IssueCategory.new
|
||||||
@member ||= @project.members.new
|
@member ||= @project.members.new
|
||||||
@trackers = Tracker.sorted.to_a
|
@trackers = Tracker.sorted.to_a
|
||||||
|
|
||||||
|
@version_status = params[:version_status] || 'open'
|
||||||
|
@version_name = params[:version_name]
|
||||||
|
@versions = @project.shared_versions.status(@version_status).like(@version_name)
|
||||||
@wiki ||= @project.wiki || Wiki.new(:project => @project)
|
@wiki ||= @project.wiki || Wiki.new(:project => @project)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ module ProjectsHelper
|
|||||||
tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural},
|
tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural},
|
||||||
{:name => 'modules', :action => :select_project_modules, :partial => 'projects/settings/modules', :label => :label_module_plural},
|
{:name => 'modules', :action => :select_project_modules, :partial => 'projects/settings/modules', :label => :label_module_plural},
|
||||||
{:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural},
|
{:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural},
|
||||||
{:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural},
|
{:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural,
|
||||||
|
:url => {:tab => 'versions', :version_status => params[:version_status], :version_name => params[:version_name]}},
|
||||||
{:name => 'categories', :action => :manage_categories, :partial => 'projects/settings/issue_categories', :label => :label_issue_category_plural},
|
{:name => 'categories', :action => :manage_categories, :partial => 'projects/settings/issue_categories', :label => :label_issue_category_plural},
|
||||||
{:name => 'wiki', :action => :manage_wiki, :partial => 'projects/settings/wiki', :label => :label_wiki},
|
{:name => 'wiki', :action => :manage_wiki, :partial => 'projects/settings/wiki', :label => :label_wiki},
|
||||||
{:name => 'repositories', :action => :manage_repository, :partial => 'projects/settings/repositories', :label => :label_repository_plural},
|
{:name => 'repositories', :action => :manage_repository, :partial => 'projects/settings/repositories', :label => :label_repository_plural},
|
||||||
|
|||||||
@@ -41,7 +41,18 @@ class Version < ActiveRecord::Base
|
|||||||
attr_protected :id
|
attr_protected :id
|
||||||
|
|
||||||
scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)}
|
scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)}
|
||||||
|
scope :like, lambda {|arg|
|
||||||
|
if arg.present?
|
||||||
|
pattern = "%#{arg.to_s.strip}%"
|
||||||
|
where("LOWER(#{Version.table_name}.name) LIKE :p", :p => pattern)
|
||||||
|
end
|
||||||
|
}
|
||||||
scope :open, lambda { where(:status => 'open') }
|
scope :open, lambda { where(:status => 'open') }
|
||||||
|
scope :status, lambda {|status|
|
||||||
|
if status.present?
|
||||||
|
where(:status => status.to_s)
|
||||||
|
end
|
||||||
|
}
|
||||||
scope :visible, lambda {|*args|
|
scope :visible, lambda {|*args|
|
||||||
joins(:project).
|
joins(:project).
|
||||||
where(Project.allowed_to_condition(args.first || User.current, :view_issues))
|
where(Project.allowed_to_condition(args.first || User.current, :view_issues))
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<div class="tabs">
|
<div class="tabs">
|
||||||
<ul>
|
<ul>
|
||||||
<% tabs.each do |tab| -%>
|
<% tabs.each do |tab| -%>
|
||||||
<li><%= link_to l(tab[:label]), { :tab => tab[:name] },
|
<li><%= link_to l(tab[:label]), (tab[:url] || { :tab => tab[:name] }),
|
||||||
:id => "tab-#{tab[:name]}",
|
:id => "tab-#{tab[:name]}",
|
||||||
:class => (tab[:name] != selected_tab ? nil : 'selected'),
|
:class => (tab[:name] != selected_tab ? nil : 'selected'),
|
||||||
:onclick => "showTab('#{tab[:name]}', this.href); this.blur(); return false;" %></li>
|
:onclick => "showTab('#{tab[:name]}', this.href); this.blur(); return false;" %></li>
|
||||||
|
|||||||
@@ -1,4 +1,15 @@
|
|||||||
<% if @project.shared_versions.any? %>
|
<%= form_tag(settings_project_path(@project, :tab => 'versions'), :method => :get) do %>
|
||||||
|
<fieldset><legend><%= l(:label_filter_plural) %></legend>
|
||||||
|
<label for='status'><%= l(:field_status) %> :</label>
|
||||||
|
<%= select_tag 'version_status', options_for_select([[l(:label_all), '']] + Version::VERSION_STATUSES.collect {|s| [l("version_status_#{s}"), s]}, @version_status), :onchange => "this.form.submit(); return false;" %>
|
||||||
|
<label for='name'><%= l(:label_version) %>:</label>
|
||||||
|
<%= text_field_tag 'version_name', @version_name, :size => 30 %>
|
||||||
|
<%= submit_tag l(:button_apply), :name => nil %>
|
||||||
|
<%= link_to l(:button_clear), settings_project_path(@project, :tab => 'versions'), :class => 'icon icon-reload' %>
|
||||||
|
</fieldset>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if @versions.present? %>
|
||||||
<table class="list versions">
|
<table class="list versions">
|
||||||
<thead><tr>
|
<thead><tr>
|
||||||
<th><%= l(:label_version) %></th>
|
<th><%= l(:label_version) %></th>
|
||||||
@@ -10,7 +21,7 @@
|
|||||||
<th style="width:15%"></th>
|
<th style="width:15%"></th>
|
||||||
</tr></thead>
|
</tr></thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<% for version in @project.shared_versions.sort %>
|
<% @versions.sort.each do |version| %>
|
||||||
<tr class="version <%= cycle 'odd', 'even' %> <%=h version.status %> <%= 'shared' if version.project != @project %>">
|
<tr class="version <%= cycle 'odd', 'even' %> <%=h version.status %> <%= 'shared' if version.project != @project %>">
|
||||||
<td class="name"><%= link_to_version version %></td>
|
<td class="name"><%= link_to_version version %></td>
|
||||||
<td class="date"><%= format_date(version.effective_date) %></td>
|
<td class="date"><%= format_date(version.effective_date) %></td>
|
||||||
@@ -33,7 +44,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="contextual">
|
<div class="contextual">
|
||||||
<% if @project.versions.any? %>
|
<% if @versions.any? %>
|
||||||
<%= link_to l(:label_close_versions), close_completed_project_versions_path(@project), :method => :put %>
|
<%= link_to l(:label_close_versions), close_completed_project_versions_path(@project), :method => :put %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -491,6 +491,36 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_settings_should_accept_version_status_filter
|
||||||
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
|
get :settings, :id => 'ecookbook', :tab => 'versions', :version_status => 'locked'
|
||||||
|
assert_response :success
|
||||||
|
|
||||||
|
assert_select 'select[name=version_status]' do
|
||||||
|
assert_select 'option[value=locked][selected=selected]'
|
||||||
|
end
|
||||||
|
assert_select 'table.versions tbody' do
|
||||||
|
assert_select 'tr', 1
|
||||||
|
assert_select 'td.name', :text => '1.0'
|
||||||
|
end
|
||||||
|
assert_select 'a#tab-versions[href=?]', '/projects/ecookbook/settings/versions?version_status=locked'
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_settings_should_accept_version_name_filter
|
||||||
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
|
get :settings, :id => 'ecookbook', :tab => 'versions', :version_status => '', :version_name => '.1'
|
||||||
|
assert_response :success
|
||||||
|
|
||||||
|
assert_select 'input[name=version_name][value=?]', '.1'
|
||||||
|
assert_select 'table.versions tbody' do
|
||||||
|
assert_select 'tr', 1
|
||||||
|
assert_select 'td.name', :text => '0.1'
|
||||||
|
end
|
||||||
|
assert_select 'a#tab-versions[href=?]', '/projects/ecookbook/settings/versions?version_name=.1&version_status='
|
||||||
|
end
|
||||||
|
|
||||||
def test_update
|
def test_update
|
||||||
@request.session[:user_id] = 2 # manager
|
@request.session[:user_id] = 2 # manager
|
||||||
post :update, :id => 1, :project => {:name => 'Test changed name',
|
post :update, :id => 1, :project => {:name => 'Test changed name',
|
||||||
|
|||||||
Reference in New Issue
Block a user