diff --git a/app/controllers/manage_tags_controller.rb b/app/controllers/manage_tags_controller.rb
index 97e9e55..7c69cae 100644
--- a/app/controllers/manage_tags_controller.rb
+++ b/app/controllers/manage_tags_controller.rb
@@ -9,7 +9,7 @@ class ManageTagsController < ApplicationController
end
def new
- @tags = Tag.find_all
+ @parent_tags = Tag.find_all
@tag = Tag.new
end
@@ -24,4 +24,27 @@ class ManageTagsController < ApplicationController
render :action => 'new'
end
end
+
+ def edit
+ @parent_tags = Tag.find_all
+ @tag = Tag.find(params[:id])
+ end
+
+ def update
+ @tag = Tag.find(params[:id])
+ @tag.name = params[:tag][:name]
+ @tag.parent = params[:parent_id] != "0" ? Tag.find(params[:parent_id].to_i) : nil
+ if @tag.save
+ flash[:notice] = _('Tag was successfully updated.')
+ redirect_to :action => 'list'
+ else
+ render :action => 'edit'
+ end
+ end
+
+ def destroy
+ @tag = Tag.find(params[:id])
+ @tag.destroy
+ redirect_to :action => 'list'
+ end
end
diff --git a/app/views/manage_tags/_form.rhtml b/app/views/manage_tags/_form.rhtml
index 2f9931a..3645947 100644
--- a/app/views/manage_tags/_form.rhtml
+++ b/app/views/manage_tags/_form.rhtml
@@ -1,3 +1,2 @@
-
Name: <%= text_field 'tag', 'name' %>
-Parent tag: <%= select_tag 'parent_id', [''] + @tags.map {|n|"'} %>
+Parent tag: <%= select_tag 'parent_id', [''] + @parent_tags.select{|pt| !pt.ancestors.include?(@tag) and pt != @tag}.map {|n|"'} %>
diff --git a/app/views/manage_tags/list.rhtml b/app/views/manage_tags/list.rhtml
index 4ab2e35..4c38493 100644
--- a/app/views/manage_tags/list.rhtml
+++ b/app/views/manage_tags/list.rhtml
@@ -1,9 +1,7 @@