forked from publify/publify
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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)
- Loading branch information
Frédéric de Villamil
committed
Aug 26, 2013
1 parent
0eecd27
commit 1904984
Showing
4 changed files
with
58 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<% @page_heading = _('Manage tags') %> | ||
|
||
<div> | ||
<div class='span4'> | ||
<%= form_tag :action=>"edit", :id => @tag.id do %> | ||
<%= error_messages_for 'tag' %> | ||
<label for="tag_display_name"><%= _("Name")%>:</label> | ||
<%= text_field 'tag', 'display_name', :class => 'medium' %> | ||
<div class='form-actions'> | ||
<%= cancel_or_save %> | ||
</div> | ||
<% end %> | ||
</div> | ||
<div class='span8'> | ||
<table class="table table-striped"> | ||
<thead> | ||
<tr class='noborder'> | ||
<th><%= _("Display Name") %></th> | ||
<th><%= _("Name") %></th> | ||
<th><%= _("Articles") %></th> | ||
</tr> | ||
</thead> | ||
<%= render_void_table(@tags.size, 3) %> | ||
<% for tag in @tags %> | ||
<tr <%= alternate_class %>> | ||
<td> | ||
<%= link_to_edit tag.display_name, tag %> | ||
<%= show_tag_actions tag %> | ||
</td> | ||
<td><%= tag.name %></td> | ||
<td><%= tag.published_articles.count.to_s %></td> | ||
</tr> | ||
<% end %> | ||
<%= display_pagination(@tags, 3)%> | ||
</table> | ||
|
||
</div> | ||
</div> | ||
|