Commit fac34d85c6834566370db394ee8c88a940ad2ef4

Authored by MoisesMachado
1 parent 1bbacb34

ActionItem4: adding pending tags


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@73 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/manage_tags_controller.rb
  1 +require 'extended_tag'
1 2 class ManageTagsController < ApplicationController
2 3 def index
3 4 list
... ... @@ -6,7 +7,8 @@ class ManageTagsController &lt; ApplicationController
6 7  
7 8 def list
8 9 @parent = Tag.find(params[:parent]) if params[:parent]
9   - @tags = Tag.find_all_by_parent_id(params[:parent])
  10 + @tags = Tag.find_all_by_parent_id(params[:parent]).select{|t|!t.pending?}
  11 + @pending_tags = Tag.find_all.select(&:pending?)
10 12 end
11 13  
12 14 def new
... ... @@ -18,6 +20,7 @@ class ManageTagsController &lt; ApplicationController
18 20 @tag = Tag.new
19 21 @tag.name = params[:tag][:name]
20 22 @tag.parent = Tag.find(params[:parent_id].to_i) if params[:parent_id] != "0"
  23 + @tag.pending = params[:tag][:pending]
21 24 if @tag.save
22 25 flash[:notice] = _('Tag was successfully created.')
23 26 redirect_to :action => 'list'
... ... @@ -28,8 +31,7 @@ class ManageTagsController &lt; ApplicationController
28 31  
29 32 def edit
30 33 @tag = Tag.find(params[:id])
31   - @parent_tags = Tag.find_all.select{|pt| !pt.ancestors.include?(@tag) and pt != @tag}
32   -
  34 + @parent_tags = Tag.find_all - @tag.descendents - [@tag]
33 35 end
34 36  
35 37 def update
... ...
app/views/manage_tags/_form.rhtml
1 1 Name: <%= text_field 'tag', 'name' %> <br>
2 2 Parent tag: <%= select_tag 'parent_id', ['<option value="0"></option>'] + @parent_tags.map {|pt|"<option value=\"#{pt.id}\" #{'selected="selected"' if @tag.parent == pt} >" + pt.name + '</option>'} %> <br>
  3 +Pending: <%= check_box 'tag', 'pending' %> <br>
... ...
app/views/manage_tags/list.rhtml
... ... @@ -4,5 +4,11 @@
4 4 <%= render :partial => 'a_tag', :collection => @tags %>
5 5 </ul>
6 6  
  7 +
  8 +<h3> <%= _('Pending Tags') %> </h3>
  9 +<ul>
  10 + <%= render :partial => 'a_tag', :collection => @pending_tags %>
  11 +</ul>
  12 +
7 13 <%= link_to _('Up'), {:action => 'list', :parent => @parent.parent} if @parent %>
8 14 <%= link_to _('New tag'), {:action => 'new'} %>
... ...