summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-10-26 09:03:08 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-10-26 09:03:08 +0000
commitba083225b7403b826c634ca3d0ce777c8445daf0 (patch)
tree19048b22c351f853c2bef8a697378acad41e987e
parent7f22cc611311b403a04e1d54ce75a4b4357651c3 (diff)
downloadredmine-ba083225b7403b826c634ca3d0ce777c8445daf0.tar.gz
redmine-ba083225b7403b826c634ca3d0ce777c8445daf0.zip
Return to section anchor after wiki section edit (#15182).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12239 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/wiki_controller.rb7
-rw-r--r--app/helpers/application_helper.rb3
-rw-r--r--test/functional/wiki_controller_test.rb4
3 files changed, 9 insertions, 5 deletions
diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb
index 8c3011510..42a60efc5 100644
--- a/app/controllers/wiki_controller.rb
+++ b/app/controllers/wiki_controller.rb
@@ -144,7 +144,7 @@ class WikiController < ApplicationController
if params[:section].present? && Redmine::WikiFormatting.supports_section_edit?
@section = params[:section].to_i
@section_hash = params[:section_hash]
- @content.text = Redmine::WikiFormatting.formatter.new(@content.text).update_section(params[:section].to_i, @text, @section_hash)
+ @content.text = Redmine::WikiFormatting.formatter.new(@content.text).update_section(@section, @text, @section_hash)
else
@content.version = content_params[:version] if content_params[:version]
@content.text = @text
@@ -157,7 +157,10 @@ class WikiController < ApplicationController
call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page})
respond_to do |format|
- format.html { redirect_to project_wiki_page_path(@project, @page.title) }
+ format.html {
+ anchor = @section ? "section-#{@section}" : nil
+ redirect_to project_wiki_page_path(@project, @page.title, :anchor => anchor)
+ }
format.api {
if was_new_page
render :action => 'show', :status => :created, :location => project_wiki_page_path(@project, @page.title)
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index e5b75c4cf..2b37ad312 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -831,7 +831,8 @@ module ApplicationHelper
content_tag('div',
link_to(image_tag('edit.png'), options[:edit_section_links].merge(:section => @current_section)),
:class => 'contextual',
- :title => l(:button_edit_section)) + heading.html_safe
+ :title => l(:button_edit_section),
+ :id => "section-#{@current_section}") + heading.html_safe
else
heading
end
diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb
index 6bf93ea4f..9c59668c5 100644
--- a/test/functional/wiki_controller_test.rb
+++ b/test/functional/wiki_controller_test.rb
@@ -454,7 +454,7 @@ class WikiControllerTest < ActionController::TestCase
end
end
end
- assert_redirected_to '/projects/ecookbook/wiki/Page_with_sections'
+ assert_redirected_to '/projects/ecookbook/wiki/Page_with_sections#section-2'
assert_equal Redmine::WikiFormatting::Textile::Formatter.new(text).update_section(2, "New section content"), page.reload.content.text
end
@@ -477,7 +477,7 @@ class WikiControllerTest < ActionController::TestCase
end
end
end
- assert_redirected_to '/projects/ecookbook/wiki/Page_with_sections'
+ assert_redirected_to '/projects/ecookbook/wiki/Page_with_sections#section-2'
page.reload
assert_equal Redmine::WikiFormatting::Textile::Formatter.new(text).update_section(2, "New section content"), page.content.text
assert_equal 4, page.content.version