Commit ec04a68dbfda9a261d69766c23467aeb1585a67f
Committed by
Antonio Terceiro
1 parent
8acd760e
Exists in
master
and in
28 other branches
Add "Save and continue" button in edit screen.
This code was written at LinguÁgil 2010 <http://www.linguagil.com.br/>, during the "Noosfero Coding Dojo" session on September 17th, 2010. The following people contributed: * Fabrício * Márcio Albuquerque * João Paulo * Luiz Cláudio * Guto Maia * Alexandre Gomes * Ivan * Serge Rehem * Bruno Porkaria * Antonio Terceiro * Rodrigo Souto * Daniela Feitosa (ActionItem1394)
Showing
4 changed files
with
17 additions
and
2 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
| @@ -88,14 +88,16 @@ class CmsController < MyProfileController | @@ -88,14 +88,16 @@ class CmsController < MyProfileController | ||
| 88 | @article = profile.articles.find(params[:id]) | 88 | @article = profile.articles.find(params[:id]) |
| 89 | @parent_id = params[:parent_id] | 89 | @parent_id = params[:parent_id] |
| 90 | @type = params[:type] || @article.class.to_s | 90 | @type = params[:type] || @article.class.to_s |
| 91 | + continue = params[:continue] | ||
| 91 | 92 | ||
| 92 | refuse_blocks | 93 | refuse_blocks |
| 93 | record_coming | 94 | record_coming |
| 94 | if request.post? | 95 | if request.post? |
| 95 | @article.last_changed_by = user | 96 | @article.last_changed_by = user |
| 96 | if @article.update_attributes(params[:article]) | 97 | if @article.update_attributes(params[:article]) |
| 97 | - redirect_to @article.view_url | ||
| 98 | - return | 98 | + if !continue |
| 99 | + redirect_to @article.view_url | ||
| 100 | + end | ||
| 99 | end | 101 | end |
| 100 | end | 102 | end |
| 101 | end | 103 | end |
app/views/cms/edit.rhtml
| @@ -20,6 +20,7 @@ | @@ -20,6 +20,7 @@ | ||
| 20 | 20 | ||
| 21 | <% button_bar do %> | 21 | <% button_bar do %> |
| 22 | <%= submit_button :save, _('Save') %> | 22 | <%= submit_button :save, _('Save') %> |
| 23 | + <%= submit_button :save, _('Save and continue'), :name => "continue" %> | ||
| 23 | <% end %> | 24 | <% end %> |
| 24 | 25 | ||
| 25 | <div style='float: right'> | 26 | <div style='float: right'> |
features/edit_article.feature
| @@ -114,3 +114,11 @@ Feature: edit article | @@ -114,3 +114,11 @@ Feature: edit article | ||
| 114 | When I follow "Cancel" within ".no-boxes" | 114 | When I follow "Cancel" within ".no-boxes" |
| 115 | And I should be on /joaosilva/my-folder | 115 | And I should be on /joaosilva/my-folder |
| 116 | 116 | ||
| 117 | + Scenario: save and continue | ||
| 118 | + Given I am on /joaosilva/save-the-whales | ||
| 119 | + And I follow "Edit" | ||
| 120 | + When I fill in "Text" with "new text" | ||
| 121 | + And I press "Save and continue" | ||
| 122 | + Then show me the page | ||
| 123 | + Then the "Text" field should contain "new text" | ||
| 124 | + And I should be on "Save the whales" edit page |
features/support/paths.rb
| @@ -51,6 +51,10 @@ module NavigationHelpers | @@ -51,6 +51,10 @@ module NavigationHelpers | ||
| 51 | when /^(.+)'s cms/ | 51 | when /^(.+)'s cms/ |
| 52 | '/myprofile/%s/cms' % Profile.find_by_name($1).identifier | 52 | '/myprofile/%s/cms' % Profile.find_by_name($1).identifier |
| 53 | 53 | ||
| 54 | + when /^"(.+)" edit page/ | ||
| 55 | + article = Article.find_by_name($1) | ||
| 56 | + '/myprofile/%s/cms/edit/%s' % [article.profile.identifier, article.id] | ||
| 57 | + | ||
| 54 | when /^(.+)'s members management/ | 58 | when /^(.+)'s members management/ |
| 55 | '/myprofile/%s/profile_members' % Profile.find_by_name($1).identifier | 59 | '/myprofile/%s/profile_members' % Profile.find_by_name($1).identifier |
| 56 | 60 |