Commit fac34d85c6834566370db394ee8c88a940ad2ef4
1 parent
1bbacb34
Exists in
master
and in
29 other branches
ActionItem4: adding pending tags
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@73 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
3 changed files
with
12 additions
and
3 deletions
Show diff stats
app/controllers/manage_tags_controller.rb
1 | +require 'extended_tag' | ||
1 | class ManageTagsController < ApplicationController | 2 | class ManageTagsController < ApplicationController |
2 | def index | 3 | def index |
3 | list | 4 | list |
@@ -6,7 +7,8 @@ class ManageTagsController < ApplicationController | @@ -6,7 +7,8 @@ class ManageTagsController < ApplicationController | ||
6 | 7 | ||
7 | def list | 8 | def list |
8 | @parent = Tag.find(params[:parent]) if params[:parent] | 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 | end | 12 | end |
11 | 13 | ||
12 | def new | 14 | def new |
@@ -18,6 +20,7 @@ class ManageTagsController < ApplicationController | @@ -18,6 +20,7 @@ class ManageTagsController < ApplicationController | ||
18 | @tag = Tag.new | 20 | @tag = Tag.new |
19 | @tag.name = params[:tag][:name] | 21 | @tag.name = params[:tag][:name] |
20 | @tag.parent = Tag.find(params[:parent_id].to_i) if params[:parent_id] != "0" | 22 | @tag.parent = Tag.find(params[:parent_id].to_i) if params[:parent_id] != "0" |
23 | + @tag.pending = params[:tag][:pending] | ||
21 | if @tag.save | 24 | if @tag.save |
22 | flash[:notice] = _('Tag was successfully created.') | 25 | flash[:notice] = _('Tag was successfully created.') |
23 | redirect_to :action => 'list' | 26 | redirect_to :action => 'list' |
@@ -28,8 +31,7 @@ class ManageTagsController < ApplicationController | @@ -28,8 +31,7 @@ class ManageTagsController < ApplicationController | ||
28 | 31 | ||
29 | def edit | 32 | def edit |
30 | @tag = Tag.find(params[:id]) | 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 | end | 35 | end |
34 | 36 | ||
35 | def update | 37 | def update |
app/views/manage_tags/_form.rhtml
1 | Name: <%= text_field 'tag', 'name' %> <br> | 1 | Name: <%= text_field 'tag', 'name' %> <br> |
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> | 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,5 +4,11 @@ | ||
4 | <%= render :partial => 'a_tag', :collection => @tags %> | 4 | <%= render :partial => 'a_tag', :collection => @tags %> |
5 | </ul> | 5 | </ul> |
6 | 6 | ||
7 | + | ||
8 | +<h3> <%= _('Pending Tags') %> </h3> | ||
9 | +<ul> | ||
10 | + <%= render :partial => 'a_tag', :collection => @pending_tags %> | ||
11 | +</ul> | ||
12 | + | ||
7 | <%= link_to _('Up'), {:action => 'list', :parent => @parent.parent} if @parent %> | 13 | <%= link_to _('Up'), {:action => 'list', :parent => @parent.parent} if @parent %> |
8 | <%= link_to _('New tag'), {:action => 'new'} %> | 14 | <%= link_to _('New tag'), {:action => 'new'} %> |