]> source.dussan.org Git - redmine.git/commitdiff
Adds a 'Create and continue' button on the spent time form (#9995).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 21 Jan 2012 10:37:19 +0000 (10:37 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 21 Jan 2012 10:37:19 +0000 (10:37 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8687 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/timelog_controller.rb
app/views/timelog/new.html.erb
test/functional/timelog_controller_test.rb

index 220954735e7868ac01a4242b42bb9959e5743a9d..e1895f5de311413c1e428590102e16f094031f4f 100644 (file)
@@ -127,8 +127,12 @@ class TimelogController < ApplicationController
     if @time_entry.save
       respond_to do |format|
         format.html {
-          flash[:notice] = l(:notice_successful_update)
-          redirect_back_or_default :action => 'index', :project_id => @time_entry.project
+          flash[:notice] = l(:notice_successful_create)
+          if params[:continue]
+            redirect_to :action => 'new', :project_id => @time_entry.project, :issue_id => @time_entry.issue
+          else
+            redirect_back_or_default :action => 'index', :project_id => @time_entry.project
+          end
         }
         format.api  { render :action => 'show', :status => :created, :location => time_entry_url(@time_entry) }
       end
index fe62777381cbbcfc2c66b8421443f22eb365ce47..6871c5f23b7eec73c7890adcc9edc9c2677d111f 100644 (file)
@@ -2,5 +2,6 @@
 
 <% labelled_form_for @time_entry, :url => project_time_entries_path(@time_entry.project) do |f| %>
   <%= render :partial => 'form', :locals => {:f => f} %>
-  <%= submit_tag l(:button_save) %>
+  <%= submit_tag l(:button_create) %>
+  <%= submit_tag l(:button_create_and_continue), :name => 'continue' %>
 <% end %>
index 09cf2b513fe260bbd6cb5d20f07707efc456f57a..4dd8fe0c6b5f11d6368511db46606c27fde5265d 100644 (file)
@@ -119,6 +119,28 @@ class TimelogControllerTest < ActionController::TestCase
     assert_equal 3, t.user_id
   end
 
+  def test_create_and_continue
+    @request.session[:user_id] = 2
+    post :create, :project_id => 1,
+                :time_entry => {:activity_id => '11',
+                                :issue_id => '',
+                                :spent_on => '2008-03-14',
+                                :hours => '7.3'},
+                :continue => '1'
+    assert_redirected_to '/projects/ecookbook/time_entries/new'
+  end
+
+  def test_create_and_continue_with_issue_id
+    @request.session[:user_id] = 2
+    post :create, :project_id => 1,
+                :time_entry => {:activity_id => '11',
+                                :issue_id => '1',
+                                :spent_on => '2008-03-14',
+                                :hours => '7.3'},
+                :continue => '1'
+    assert_redirected_to '/projects/ecookbook/issues/1/time_entries/new'
+  end
+
   def test_create_without_log_time_permission_should_be_denied
     @request.session[:user_id] = 2
     Role.find_by_name('Manager').remove_permission! :log_time