From 64b41e23d7dc0cfb29349422e5d310fc968c3101 Mon Sep 17 00:00:00 2001 From: Braulio Bhavamitra Date: Fri, 9 Aug 2013 12:04:39 -0300 Subject: [PATCH] Add button to delete content on edition --- app/controllers/my_profile/cms_controller.rb | 2 +- app/views/cms/edit.rhtml | 6 ++++++ public/stylesheets/application.css | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index 0bfa632..a54c2f3 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -183,7 +183,7 @@ class CmsController < MyProfileController @article.destroy session[:notice] = _("\"#{@article.name}\" was removed.") referer = ActionController::Routing::Routes.recognize_path URI.parse(request.referer).path rescue nil - if referer and referer[:controller] == 'cms' + if referer and referer[:controller] == 'cms' and referer[:action] != 'edit' redirect_to referer elsif @article.parent redirect_to @article.parent.url diff --git a/app/views/cms/edit.rhtml b/app/views/cms/edit.rhtml index 566ae87..1e6087e 100644 --- a/app/views/cms/edit.rhtml +++ b/app/views/cms/edit.rhtml @@ -38,6 +38,7 @@ <% button_bar do %> <%= submit_button :save, _('Save') %> + <% if @back_to %> <%= button :cancel, _('Cancel'), @back_to %> <% elsif @parent_id || @article.parent %> @@ -45,6 +46,11 @@ <% else %> <%= button :cancel, _('Cancel'), :action => 'index' %> <% end %> + + <% unless @article.new_record? %> + <%= button :delete, _('Delete'), {:controller => :cms, :action => :destroy, :id => @article}, + :method => :post, :confirm => delete_article_message(@article) %> + <% end %> <% end %> <% end %> diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 4f215df..379ee99 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -3158,6 +3158,10 @@ table.cms-articles .icon:hover { max-width: 100%; } +.controller-cms .button-bar .icon-delete { + float: right; +} + /************* external blog options *****************/ .controller-cms #fetch-external-feed { -- libgit2 0.21.2