Commit 7be8e232c154e8dc93f85e4a249e7a4406ff313b
1 parent
03f7cd2a
Exists in
master
and in
29 other branches
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
Showing
4 changed files
with
7 additions
and
3 deletions
Show diff stats
app/controllers/manage_tags_controller.rb
| @@ -5,7 +5,8 @@ class ManageTagsController < ApplicationController | @@ -5,7 +5,8 @@ class ManageTagsController < ApplicationController | ||
| 5 | end | 5 | end |
| 6 | 6 | ||
| 7 | def list | 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 | end | 10 | end |
| 10 | 11 | ||
| 11 | def new | 12 | def new |
app/views/manage_tags/_a_tag.rhtml
| 1 | <li> | 1 | <li> |
| 2 | +<%= a_tag.id %> | ||
| 2 | <%= a_tag.name %> | 3 | <%= a_tag.name %> |
| 3 | <%= link_to _('Edit'), {:action => 'edit', :id => a_tag } %> | 4 | <%= link_to _('Edit'), {:action => 'edit', :id => a_tag } %> |
| 4 | <%= link_to _('Destroy'), {:action => 'destroy', :id => a_tag} %> | 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 | <%= render :partial => 'a_tag', :collection => a_tag.children %> | 7 | <%= render :partial => 'a_tag', :collection => a_tag.children %> |
| 7 | </ul> | 8 | </ul> |
| 8 | </li> | 9 | </li> |
app/views/manage_tags/list.rhtml
| 1 | <h2> <%= _("Listing tags") %> </h2> | 1 | <h2> <%= _("Listing tags") %> </h2> |
| 2 | 2 | ||
| 3 | <ul> | 3 | <ul> |
| 4 | - <%= render :partial => 'a_tag', :collection => @tags.select{|t|!t.parent} %> | 4 | + <%= render :partial => 'a_tag', :collection => @tags %> |
| 5 | </ul> | 5 | </ul> |
| 6 | 6 | ||
| 7 | +<%= link_to _('Up'), {:action => 'list', :parent => @parent.parent} if @parent %> | ||
| 7 | <%= link_to _('New tag'), {:action => 'new'} %> | 8 | <%= link_to _('New tag'), {:action => 'new'} %> |
db/migrate/007_acts_as_taggable_migration.rb
| @@ -3,6 +3,7 @@ class ActsAsTaggableMigration < ActiveRecord::Migration | @@ -3,6 +3,7 @@ class ActsAsTaggableMigration < ActiveRecord::Migration | ||
| 3 | create_table :tags do |t| | 3 | create_table :tags do |t| |
| 4 | t.column :name, :string | 4 | t.column :name, :string |
| 5 | t.column :parent_id, :integer | 5 | t.column :parent_id, :integer |
| 6 | + t.column :pending, :bool | ||
| 6 | end | 7 | end |
| 7 | 8 | ||
| 8 | create_table :taggings do |t| | 9 | create_table :taggings do |t| |