From a9288cc3bd998d7c179b080f56eccd6a56f59133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20FRERE?= Date: Thu, 24 Oct 2013 12:41:20 +0200 Subject: Adds a button to delete the displayed translation of a blog post --- app/assets/stylesheets/refinery/blog/backend.css.scss | 4 ++++ app/controllers/refinery/blog/admin/posts_controller.rb | 7 +++++++ app/views/refinery/blog/admin/posts/_form.html.erb | 9 ++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/assets/stylesheets/refinery/blog/backend.css.scss b/app/assets/stylesheets/refinery/blog/backend.css.scss index e14d92b..e4ff700 100644 --- a/app/assets/stylesheets/refinery/blog/backend.css.scss +++ b/app/assets/stylesheets/refinery/blog/backend.css.scss @@ -71,3 +71,7 @@ a#copy_body_link { margin-top: 0; padding-left: 20px; } +.form-actions a.confirm-delete, #content .form-actions a.confirm-delete { + position: relative; + right: auto; +} \ No newline at end of file diff --git a/app/controllers/refinery/blog/admin/posts_controller.rb b/app/controllers/refinery/blog/admin/posts_controller.rb index d01bba9..4eeffd0 100644 --- a/app/controllers/refinery/blog/admin/posts_controller.rb +++ b/app/controllers/refinery/blog/admin/posts_controller.rb @@ -75,6 +75,13 @@ module Refinery end end + def delete_translation + find_post + @post.translations.find_by_locale(params[:locale_to_delete]).destroy + flash[:notice] = ::I18n.t('delete_translation_success', :scope => 'refinery.blog.admin.posts.post') + redirect_to refinery.blog_admin_posts_path + end + private def post_params diff --git a/app/views/refinery/blog/admin/posts/_form.html.erb b/app/views/refinery/blog/admin/posts/_form.html.erb index 1d52c56..5cb061e 100644 --- a/app/views/refinery/blog/admin/posts/_form.html.erb +++ b/app/views/refinery/blog/admin/posts/_form.html.erb @@ -106,7 +106,14 @@ <%= render "/refinery/admin/form_actions", :f => f, :continue_editing => true, - :delete_title => t('delete', :scope => 'refinery.blog.admin.posts.post') %> + :delete_title => t('delete', :scope => 'refinery.blog.admin.posts.post'), + :before_delete_button => (link_to(t('delete_translation', :scope => 'refinery.blog.admin.posts.post'), + refinery.delete_translation_blog_admin_post_path(@post, :locale_to_delete => Globalize.locale), + :method => :post, + :data => { + :confirm => t('delete_translation_confirmation', :scope => 'refinery.blog.admin.posts.post') + }, + :class => "button confirm-delete") if Refinery::I18n.frontend_locales.many? && @post.translations.size > 1) %> <% end -%> <% content_for :stylesheets, stylesheet_link_tag('refinery/blog/backend') %> -- cgit v1.2.3