From 19049841c5f2b05217a88f49f3437dd0207e4f1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20de=20Villamil?= Date: Mon, 26 Aug 2013 02:20:09 +0200 Subject: [PATCH] Making tags edition like other data type edition. I wonder when this was last updated since all the code was ported on the new system ages ago (git says at least 2 years ago) --- app/controllers/admin/tags_controller.rb | 32 +++++++++++-------- app/views/admin/tags/edit.html.erb | 12 -------- app/views/admin/tags/index.html.erb | 23 -------------- app/views/admin/tags/new.html.erb | 39 ++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 48 deletions(-) delete mode 100644 app/views/admin/tags/edit.html.erb delete mode 100644 app/views/admin/tags/index.html.erb create mode 100644 app/views/admin/tags/new.html.erb diff --git a/app/controllers/admin/tags_controller.rb b/app/controllers/admin/tags_controller.rb index bb0ec01854..f4e4570bb7 100644 --- a/app/controllers/admin/tags_controller.rb +++ b/app/controllers/admin/tags_controller.rb @@ -1,29 +1,35 @@ class Admin::TagsController < Admin::BaseController cache_sweeper :blog_sweeper - def index - @tags = Tag.order('display_name').page(params[:page]).per(this_blog.admin_display_elements) + def index; redirect_to action: 'new' ; end + def new; new_or_edit; end + def edit; new_or_edit; end + + def destroy + destroy_a(Tag) end - def edit - @tag = Tag.find(params[:id]) - @tag.attributes = params[:tag] + private + + def new_or_edit + @tags = Tag.order('display_name').page(params[:page]).per(this_blog.admin_display_elements) + @tag = case params[:id] + when nil + Tag.new + else + Tag.find(params[:id]) + end + @tag.attributes = params[:tag] if request.post? - old_name = @tag.name + old_name = @tag.name if @tag.id if @tag.save - # Create a redirection to ensure nothing nasty happens in the future Redirect.create(:from_path => "/tag/#{old_name}", :to_path => @tag.permalink_url(nil, true)) - flash[:notice] = _('Tag was successfully updated.') - redirect_to :action => 'index' end end - end - - def destroy - destroy_a(Tag) + render 'new' end end diff --git a/app/views/admin/tags/edit.html.erb b/app/views/admin/tags/edit.html.erb deleted file mode 100644 index eeb54446c0..0000000000 --- a/app/views/admin/tags/edit.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -<% @page_heading = _("Editing tag ") + " #{h @tag.display_name}" %> - -<%= form_tag :action=>"edit", :id => @tag.id do %> -<%= error_messages_for 'tag' %> - -
- <%= text_field 'tag', 'display_name', :class => 'medium' %> -
-
- <%= cancel_or_save %> -
-<% end %> diff --git a/app/views/admin/tags/index.html.erb b/app/views/admin/tags/index.html.erb deleted file mode 100644 index cb785abcf0..0000000000 --- a/app/views/admin/tags/index.html.erb +++ /dev/null @@ -1,23 +0,0 @@ -<% @page_heading = _('Manage tags') %> - - - - - - - - - - <%= render_void_table(@tags.size, 3) %> - <% for tag in @tags %> - > - - - - - <% end %> - <%= display_pagination(@tags, 3)%> -
<%= _("Display Name") %><%= _("Name") %><%= _("Articles") %>
- <%= link_to_edit tag.display_name, tag %> - <%= show_tag_actions tag %> - <%= tag.name %><%= tag.published_articles.count.to_s %>
diff --git a/app/views/admin/tags/new.html.erb b/app/views/admin/tags/new.html.erb new file mode 100644 index 0000000000..e09f42f627 --- /dev/null +++ b/app/views/admin/tags/new.html.erb @@ -0,0 +1,39 @@ +<% @page_heading = _('Manage tags') %> + +
+
+ <%= form_tag :action=>"edit", :id => @tag.id do %> + <%= error_messages_for 'tag' %> + + <%= text_field 'tag', 'display_name', :class => 'medium' %> +
+ <%= cancel_or_save %> +
+ <% end %> +
+
+ + + + + + + + + <%= render_void_table(@tags.size, 3) %> + <% for tag in @tags %> + > + + + + + <% end %> + <%= display_pagination(@tags, 3)%> +
<%= _("Display Name") %><%= _("Name") %><%= _("Articles") %>
+ <%= link_to_edit tag.display_name, tag %> + <%= show_tag_actions tag %> + <%= tag.name %><%= tag.published_articles.count.to_s %>
+ +
+
+