]> source.dussan.org Git - redmine.git/commitdiff
Set the parent page when creating a new wiki page from the "Add page" link (#26043).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 8 Jul 2017 13:51:18 +0000 (13:51 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 8 Jul 2017 13:51:18 +0000 (13:51 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@16774 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/wiki_controller.rb
app/views/wiki/_new_modal.html.erb
app/views/wiki/show.html.erb
test/functional/wiki_controller_test.rb

index 5496fbbdd79abfa8cec8eec320b03840d72bfa70..8064cd64fb42fba74f89e60edf2e4ad5c9b08ced 100644 (file)
@@ -70,7 +70,7 @@ class WikiController < ApplicationController
       @page.title = '' unless editable?
       @page.validate
       if @page.errors[:title].blank?
-        path = project_wiki_page_path(@project, @page.title)
+        path = project_wiki_page_path(:project_id => @project, :id => @page.title, :parent => params[:parent])
         respond_to do |format|
           format.html { redirect_to path }
           format.js   { render :js => "window.location = #{path.to_json}" }
index 52a87b751ad72ea43ab4b44920056226e502065a..472bbd63f2d912b1dd84c9df8d30f254755456a9 100644 (file)
@@ -1,7 +1,7 @@
 <h3 class="title"><%=l(:label_wiki_page_new)%></h3>
 
 <%= labelled_form_for :page, @page,
-            :url => new_project_wiki_page_path(@project),
+            :url => new_project_wiki_page_path(:project_id => @project, :parent => params[:parent]),
             :method => 'post',
             :remote => true do |f| %>
 
index 1cbfcbc656468ecb65d92eda423c8acdb1476df5..a77421afa728a063444dad141b7a803105d10831 100644 (file)
@@ -1,6 +1,6 @@
 <div class="contextual">
 <% if User.current.allowed_to?(:edit_wiki_pages, @project) %>
-<%= link_to l(:label_wiki_page_new), new_project_wiki_page_path(@project), :remote => true, :class => 'icon icon-add' %>
+<%= link_to l(:label_wiki_page_new), new_project_wiki_page_path(:project_id => @project, :parent => @page.title), :remote => true, :class => 'icon icon-add' %>
 <% end %>
 <% if @editable %>
 <% if @content.current_version? %>
index dd28fb6b72d01ca610905647576fd305b0564e7b..98d076cbdf2fac0496bbcf442a2f31c9e2b751c0 100644 (file)
@@ -208,6 +208,13 @@ class WikiControllerTest < Redmine::ControllerTest
     assert_equal 'window.location = "/projects/ecookbook/wiki/New_Page"', response.body
   end
 
+  def test_post_new_should_redirect_to_edit_with_parent
+    @request.session[:user_id] = 2
+
+    post :new, :params => {:project_id => 'ecookbook', :title => 'New_Page', :parent => 'Child_1'}
+    assert_redirected_to '/projects/ecookbook/wiki/New_Page?parent=Child_1'
+  end
+
   def test_post_new_with_invalid_title_should_display_errors
     @request.session[:user_id] = 2