Skip to content

Commit

Permalink
Added save & continue editing button for pages and wired this in crud…
Browse files Browse the repository at this point in the history
….rb so anyone can follow a similar approach. May be added to more core plugins in the future.
  • Loading branch information
parndt committed Nov 16, 2009
1 parent 177d7b4 commit ad05cd7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
9 changes: 8 additions & 1 deletion vendor/plugins/pages/app/views/admin/pages/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@
</div>
<div class='form-actions'>
<%= f.submit 'Save', :id => "submit_button", :class => "wymupdate" %>
or
or
<%= hidden_field_tag :continue_editing, false %>
<%= f.submit 'Save &amp; Continue Editing', :id => "submit_continue_button", :class => "wymupdate" %>
or
<%= link_to "Cancel", admin_pages_url, :title => "Cancelling will lose all changes you've made to this page", :id => "cancel_button", :class => "close_dialog" %>
</div>
<div id='new_page_part_dialog' style='display: none'>
Expand Down Expand Up @@ -160,6 +163,10 @@
}
});

$('submit_continue_button').observe("click", function(e) {
$('continue_editing').value = true;
});

<% if RefinerySetting.find_or_set(:new_page_parts, false) %>
$('add_page_part').observe('click', function(e) {
tb_show('Create Content Section', '#?auto_size_content=true&draggable=true&titlebar=true&inlineId=new_page_part_dialog&TB_inline=true&modal=true');
Expand Down
12 changes: 10 additions & 2 deletions vendor/plugins/refinery/lib/crud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ def create
@#{singular_name} = #{class_name}.create(params[:#{singular_name}])
if @#{singular_name}.valid?
flash[:notice] = "'\#{@#{singular_name}.#{options[:title_attribute]}}' was successfully created."
redirect_to :action => 'index'
unless params[:continue_editing] =~ /true|on|1/
redirect_to admin_#{plural_name}_url
else
redirect_to :back
end
else
render :action => 'new'
end
Expand All @@ -51,7 +55,11 @@ def update
@#{singular_name}.update_attributes(params[:#{singular_name}])
if @#{singular_name}.valid?
flash[:notice] = "'\#{@#{singular_name}.#{options[:title_attribute]}}' was successfully updated."
redirect_to admin_#{plural_name}_url
unless params[:continue_editing] =~ /true|on|1/
redirect_to admin_#{plural_name}_url
else
redirect_to :back
end
else
render :action => 'edit'
end
Expand Down

0 comments on commit ad05cd7

Please sign in to comment.