Commit 7be8e232c154e8dc93f85e4a249e7a4406ff313b

Authored by MoisesMachado
1 parent 03f7cd2a

ActionItem4: added a filter by parent and navigaton


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@58 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/manage_tags_controller.rb
... ... @@ -5,7 +5,8 @@ class ManageTagsController < ApplicationController
5 5 end
6 6  
7 7 def list
8   - @tags = Tag.find_all
  8 + @parent = Tag.find(params[:parent]) if params[:parent]
  9 + @tags = Tag.find_all_by_parent_id(params[:parent])
9 10 end
10 11  
11 12 def new
... ...
app/views/manage_tags/_a_tag.rhtml
1 1 <li>
  2 +<%= a_tag.id %>
2 3 <%= a_tag.name %>
3 4 <%= link_to _('Edit'), {:action => 'edit', :id => a_tag } %>
4 5 <%= link_to _('Destroy'), {:action => 'destroy', :id => a_tag} %>
5   -<ul>
  6 +<%= link_to _('Filter by this tag'), {:action => 'list', :parent => a_tag} %><ul>
6 7 <%= render :partial => 'a_tag', :collection => a_tag.children %>
7 8 </ul>
8 9 </li>
... ...
app/views/manage_tags/list.rhtml
1 1 <h2> <%= _("Listing tags") %> </h2>
2 2  
3 3 <ul>
4   - <%= render :partial => 'a_tag', :collection => @tags.select{|t|!t.parent} %>
  4 + <%= render :partial => 'a_tag', :collection => @tags %>
5 5 </ul>
6 6  
  7 +<%= link_to _('Up'), {:action => 'list', :parent => @parent.parent} if @parent %>
7 8 <%= link_to _('New tag'), {:action => 'new'} %>
... ...
db/migrate/007_acts_as_taggable_migration.rb
... ... @@ -3,6 +3,7 @@ class ActsAsTaggableMigration &lt; ActiveRecord::Migration
3 3 create_table :tags do |t|
4 4 t.column :name, :string
5 5 t.column :parent_id, :integer
  6 + t.column :pending, :bool
6 7 end
7 8  
8 9 create_table :taggings do |t|
... ...