Project

General

Profile

Feature #2782 ยป redmine_save_and_continue.diff

Patch to add 'Save and Continue' button to Wiki edit form. - Ashley McKenzie, 2009-07-29 02:55

View differences:

config/locales/en.yml (working copy)
button_login: Login
button_submit: Submit
button_save: Save
button_save_and_continue: Save and Continue
button_check_all: Check all
button_uncheck_all: Uncheck all
button_delete: Delete
app/views/wiki/edit.rhtml (working copy)
<p><%= f.text_area :text, :cols => 100, :rows => 25, :class => 'wiki-edit', :accesskey => accesskey(:edit) %></p>
<p><label><%= l(:field_comments) %></label><br /><%= f.text_field :comments, :size => 120 %></p>
<p><%= submit_tag l(:button_save) %>
<%= submit_tag l(:button_save_and_continue) %>
<%= link_to_remote l(:label_preview),
{ :url => { :controller => 'wiki', :action => 'preview', :id => @project, :page => @page.title },
:method => 'post',
:update => 'preview',
:with => "Form.serialize('wiki_form')",
:complete => "Element.scrollTo('preview')"
}, :accesskey => accesskey(:preview) %></p>
}, :accesskey => accesskey(:preview) %>
</p>
<%= wikitoolbar_for 'content_text' %>
<% end %>
app/controllers/wiki_controller.rb (working copy)
else
if !@page.new_record? && @content.text == params[:content][:text]
# don't save if text wasn't changed
redirect_to :action => 'index', :id => @project, :page => @page.title
if params[:commit] == 'Save and Continue'
redirect_to :action => 'edit', :id => @project, :page => @page.title
else
redirect_to :action => 'index', :id => @project, :page => @page.title
end
return
end
#@content.text = params[:content][:text]
......
# if page is new @page.save will also save content, but not if page isn't a new record
if (@page.new_record? ? @page.save : @content.save)
call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page})
redirect_to :action => 'index', :id => @project, :page => @page.title
if params[:commit] == 'Save and Continue'
redirect_to :action => 'edit', :id => @project, :page => @page.title
else
redirect_to :action => 'index', :id => @project, :page => @page.title
end
end
end
rescue ActiveRecord::StaleObjectError
    (1-1/1)