redmine_save_and_continue.diff

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

Download (2.82 KB)

View differences:

config/locales/en.yml (working copy)
682 682
  button_login: Login
683 683
  button_submit: Submit
684 684
  button_save: Save
685
  button_save_and_continue: Save and Continue
685 686
  button_check_all: Check all
686 687
  button_uncheck_all: Uncheck all
687 688
  button_delete: Delete
app/views/wiki/edit.rhtml (working copy)
7 7
<p><%= f.text_area :text, :cols => 100, :rows => 25, :class => 'wiki-edit', :accesskey => accesskey(:edit) %></p>
8 8
<p><label><%= l(:field_comments) %></label><br /><%= f.text_field :comments, :size => 120 %></p>
9 9
<p><%= submit_tag l(:button_save) %>
10
	 <%= submit_tag l(:button_save_and_continue) %>
10 11
   <%= link_to_remote l(:label_preview), 
11 12
                       { :url => { :controller => 'wiki', :action => 'preview', :id => @project, :page => @page.title },
12 13
                         :method => 'post',
13 14
                         :update => 'preview',
14 15
                         :with => "Form.serialize('wiki_form')",
15 16
                         :complete => "Element.scrollTo('preview')"
16
                       }, :accesskey => accesskey(:preview) %></p>
17
                       }, :accesskey => accesskey(:preview) %>
18
</p>
17 19
<%= wikitoolbar_for 'content_text' %>
18 20
<% end %>
19 21

  
app/controllers/wiki_controller.rb (working copy)
74 74
    else
75 75
      if !@page.new_record? && @content.text == params[:content][:text]
76 76
        # don't save if text wasn't changed
77
        redirect_to :action => 'index', :id => @project, :page => @page.title
77
				if params[:commit] == 'Save and Continue'
78
          redirect_to :action => 'edit', :id => @project, :page => @page.title
79
				else
80
        	redirect_to :action => 'index', :id => @project, :page => @page.title
81
        end
78 82
        return
79 83
      end
80 84
      #@content.text = params[:content][:text]
......
84 88
      # if page is new @page.save will also save content, but not if page isn't a new record
85 89
      if (@page.new_record? ? @page.save : @content.save)
86 90
        call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page})
87
        redirect_to :action => 'index', :id => @project, :page => @page.title
91
 				if params[:commit] == 'Save and Continue'
92
          redirect_to :action => 'edit', :id => @project, :page => @page.title
93
				else
94
        	redirect_to :action => 'index', :id => @project, :page => @page.title
95
        end
88 96
      end
89 97
    end
90 98
  rescue ActiveRecord::StaleObjectError