Moves ProjectsController#add_version to VersionsController#new.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3548 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2010-03-06 18:25:01 +00:00
parent 2af97616f7
commit 729bea1cf3
9 changed files with 74 additions and 77 deletions
-33
View File
@@ -266,39 +266,6 @@ class ProjectsController < ApplicationController
end
end
end
# Add a new version to @project
def add_version
@version = @project.versions.build
if params[:version]
attributes = params[:version].dup
attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing'])
@version.attributes = attributes
end
if request.post?
if @version.save
respond_to do |format|
format.html do
flash[:notice] = l(:notice_successful_create)
redirect_to :action => 'settings', :tab => 'versions', :id => @project
end
format.js do
# IE doesn't support the replace_html rjs method for select box options
render(:update) {|page| page.replace "issue_fixed_version_id",
content_tag('select', '<option></option>' + version_options_for_select(@project.shared_versions.open, @version), :id => 'issue_fixed_version_id', :name => 'issue[fixed_version_id]')
}
end
end
else
respond_to do |format|
format.html
format.js do
render(:update) {|page| page.alert(@version.errors.full_messages.join('\n')) }
end
end
end
end
end
def add_file
if request.post?
+34 -2
View File
@@ -17,8 +17,8 @@
class VersionsController < ApplicationController
menu_item :roadmap
before_filter :find_version, :except => :close_completed
before_filter :find_project, :only => :close_completed
before_filter :find_version, :except => [:new, :close_completed]
before_filter :find_project, :only => [:new, :close_completed]
before_filter :authorize
helper :custom_fields
@@ -27,6 +27,38 @@ class VersionsController < ApplicationController
def show
end
def new
@version = @project.versions.build
if params[:version]
attributes = params[:version].dup
attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing'])
@version.attributes = attributes
end
if request.post?
if @version.save
respond_to do |format|
format.html do
flash[:notice] = l(:notice_successful_create)
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
end
format.js do
# IE doesn't support the replace_html rjs method for select box options
render(:update) {|page| page.replace "issue_fixed_version_id",
content_tag('select', '<option></option>' + version_options_for_select(@project.shared_versions.open, @version), :id => 'issue_fixed_version_id', :name => 'issue[fixed_version_id]')
}
end
end
else
respond_to do |format|
format.html
format.js do
render(:update) {|page| page.alert(@version.errors.full_messages.join('\n')) }
end
end
end
end
end
def edit
if request.post? && params[:version]
attributes = params[:version].dup
+2 -2
View File
@@ -23,9 +23,9 @@
<%= prompt_to_remote(image_tag('add.png', :style => 'vertical-align: middle;'),
l(:label_version_new),
'version[name]',
{:controller => 'projects', :action => 'add_version', :id => @project},
{:controller => 'versions', :action => 'new', :project_id => @project},
:title => l(:label_version_new),
:tabindex => 200) if authorize_for('projects', 'add_version') %>
:tabindex => 200) if authorize_for('versions', 'new') %>
</p>
<% end %>
</div>
+1 -1
View File
@@ -38,4 +38,4 @@
<% end %>
</div>
<p><%= link_to_if_authorized l(:label_version_new), :controller => 'projects', :action => 'add_version', :id => @project %></p>
<p><%= link_to_if_authorized l(:label_version_new), :controller => 'versions', :action => 'new', :project_id => @project %></p>
@@ -1,6 +1,6 @@
<h2><%=l(:label_version_new)%></h2>
<% labelled_tabular_form_for :version, @version, :url => { :action => 'add_version' } do |f| %>
<% labelled_tabular_form_for :version, @version, :url => { :action => 'new' } do |f| %>
<%= render :partial => 'versions/form', :locals => { :f => f } %>
<%= submit_tag l(:button_create) %>
<% end %>