@@ -155,6 +155,10 class ProjectsController < ApplicationController | |||
|
155 | 155 | @issue_category ||= IssueCategory.new |
|
156 | 156 | @member ||= @project.members.new |
|
157 | 157 | @trackers = Tracker.sorted.to_a |
|
158 | ||
|
159 | @version_status = params[:version_status] || 'open' | |
|
160 | @version_name = params[:version_name] | |
|
161 | @versions = @project.shared_versions.status(@version_status).like(@version_name) | |
|
158 | 162 | @wiki ||= @project.wiki || Wiki.new(:project => @project) |
|
159 | 163 | end |
|
160 | 164 |
@@ -22,7 +22,8 module ProjectsHelper | |||
|
22 | 22 | tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural}, |
|
23 | 23 | {:name => 'modules', :action => :select_project_modules, :partial => 'projects/settings/modules', :label => :label_module_plural}, |
|
24 | 24 | {:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural}, |
|
25 |
{:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural |
|
|
25 | {:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural, | |
|
26 | :url => {:tab => 'versions', :version_status => params[:version_status], :version_name => params[:version_name]}}, | |
|
26 | 27 | {:name => 'categories', :action => :manage_categories, :partial => 'projects/settings/issue_categories', :label => :label_issue_category_plural}, |
|
27 | 28 | {:name => 'wiki', :action => :manage_wiki, :partial => 'projects/settings/wiki', :label => :label_wiki}, |
|
28 | 29 | {:name => 'repositories', :action => :manage_repository, :partial => 'projects/settings/repositories', :label => :label_repository_plural}, |
@@ -41,7 +41,18 class Version < ActiveRecord::Base | |||
|
41 | 41 | attr_protected :id |
|
42 | 42 | |
|
43 | 43 | scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)} |
|
44 | scope :like, lambda {|arg| | |
|
45 | if arg.present? | |
|
46 | pattern = "%#{arg.to_s.strip}%" | |
|
47 | where("LOWER(#{Version.table_name}.name) LIKE :p", :p => pattern) | |
|
48 | end | |
|
49 | } | |
|
44 | 50 | scope :open, lambda { where(:status => 'open') } |
|
51 | scope :status, lambda {|status| | |
|
52 | if status.present? | |
|
53 | where(:status => status.to_s) | |
|
54 | end | |
|
55 | } | |
|
45 | 56 | scope :visible, lambda {|*args| |
|
46 | 57 | joins(:project). |
|
47 | 58 | where(Project.allowed_to_condition(args.first || User.current, :view_issues)) |
@@ -1,7 +1,7 | |||
|
1 | 1 | <div class="tabs"> |
|
2 | 2 | <ul> |
|
3 | 3 | <% tabs.each do |tab| -%> |
|
4 | <li><%= link_to l(tab[:label]), { :tab => tab[:name] }, | |
|
4 | <li><%= link_to l(tab[:label]), (tab[:url] || { :tab => tab[:name] }), | |
|
5 | 5 | :id => "tab-#{tab[:name]}", |
|
6 | 6 | :class => (tab[:name] != selected_tab ? nil : 'selected'), |
|
7 | 7 | :onclick => "showTab('#{tab[:name]}', this.href); this.blur(); return false;" %></li> |
@@ -1,4 +1,15 | |||
|
1 | <% if @project.shared_versions.any? %> | |
|
1 | <%= form_tag(settings_project_path(@project, :tab => 'versions'), :method => :get) do %> | |
|
2 | <fieldset><legend><%= l(:label_filter_plural) %></legend> | |
|
3 | <label for='status'><%= l(:field_status) %> :</label> | |
|
4 | <%= 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;" %> | |
|
5 | <label for='name'><%= l(:label_version) %>:</label> | |
|
6 | <%= text_field_tag 'version_name', @version_name, :size => 30 %> | |
|
7 | <%= submit_tag l(:button_apply), :name => nil %> | |
|
8 | <%= link_to l(:button_clear), settings_project_path(@project, :tab => 'versions'), :class => 'icon icon-reload' %> | |
|
9 | </fieldset> | |
|
10 | <% end %> | |
|
11 | ||
|
12 | <% if @versions.present? %> | |
|
2 | 13 | <table class="list versions"> |
|
3 | 14 | <thead><tr> |
|
4 | 15 | <th><%= l(:label_version) %></th> |
@@ -10,7 +21,7 | |||
|
10 | 21 | <th style="width:15%"></th> |
|
11 | 22 | </tr></thead> |
|
12 | 23 | <tbody> |
|
13 | <% for version in @project.shared_versions.sort %> | |
|
24 | <% @versions.sort.each do |version| %> | |
|
14 | 25 | <tr class="version <%= cycle 'odd', 'even' %> <%=h version.status %> <%= 'shared' if version.project != @project %>"> |
|
15 | 26 | <td class="name"><%= link_to_version version %></td> |
|
16 | 27 | <td class="date"><%= format_date(version.effective_date) %></td> |
@@ -33,7 +44,7 | |||
|
33 | 44 | <% end %> |
|
34 | 45 | |
|
35 | 46 | <div class="contextual"> |
|
36 |
<% if @ |
|
|
47 | <% if @versions.any? %> | |
|
37 | 48 | <%= link_to l(:label_close_versions), close_completed_project_versions_path(@project), :method => :put %> |
|
38 | 49 | <% end %> |
|
39 | 50 | </div> |
@@ -491,6 +491,36 class ProjectsControllerTest < Redmine::ControllerTest | |||
|
491 | 491 | end |
|
492 | 492 | end |
|
493 | 493 | |
|
494 | def test_settings_should_accept_version_status_filter | |
|
495 | @request.session[:user_id] = 2 | |
|
496 | ||
|
497 | get :settings, :id => 'ecookbook', :tab => 'versions', :version_status => 'locked' | |
|
498 | assert_response :success | |
|
499 | ||
|
500 | assert_select 'select[name=version_status]' do | |
|
501 | assert_select 'option[value=locked][selected=selected]' | |
|
502 | end | |
|
503 | assert_select 'table.versions tbody' do | |
|
504 | assert_select 'tr', 1 | |
|
505 | assert_select 'td.name', :text => '1.0' | |
|
506 | end | |
|
507 | assert_select 'a#tab-versions[href=?]', '/projects/ecookbook/settings/versions?version_status=locked' | |
|
508 | end | |
|
509 | ||
|
510 | def test_settings_should_accept_version_name_filter | |
|
511 | @request.session[:user_id] = 2 | |
|
512 | ||
|
513 | get :settings, :id => 'ecookbook', :tab => 'versions', :version_status => '', :version_name => '.1' | |
|
514 | assert_response :success | |
|
515 | ||
|
516 | assert_select 'input[name=version_name][value=?]', '.1' | |
|
517 | assert_select 'table.versions tbody' do | |
|
518 | assert_select 'tr', 1 | |
|
519 | assert_select 'td.name', :text => '0.1' | |
|
520 | end | |
|
521 | assert_select 'a#tab-versions[href=?]', '/projects/ecookbook/settings/versions?version_name=.1&version_status=' | |
|
522 | end | |
|
523 | ||
|
494 | 524 | def test_update |
|
495 | 525 | @request.session[:user_id] = 2 # manager |
|
496 | 526 | post :update, :id => 1, :project => {:name => 'Test changed name', |
General Comments 0
You need to be logged in to leave comments.
Login now