给管理员添加了tag删除功能

This commit is contained in:
william 2013-08-21 08:57:15 +08:00
parent 96dfe0a6da
commit 2f338b352a
4 changed files with 40 additions and 6 deletions

View File

@ -1,6 +1,7 @@
# This controller was added by william
class TagsController < ApplicationController
layout "base_tags"
before_filter :require_admin,:only => :show
include ProjectsHelper
include IssuesHelper
@ -8,11 +9,13 @@ class TagsController < ApplicationController
include BidsHelper
include ActsAsTaggableOn::TagsHelper
helper :projects
before_filter :require_admin,:only => [:delete,:show_all]
$selected_tags = Array.new
$related_tags = Array.new
def index
$selected_tags = []
$related_tags = []
$selected_tags << params[:q]
@ -93,9 +96,10 @@ class TagsController < ApplicationController
@show_flag = params[:show_flag]
$selected_tags << @tag
$related_tags.delete(@tag)
@obj_pages = nil
@numbers = Setting.tags_show_search_results
# @issues_results = get_issues_by_tag($selected_tags)
# @projects_results = get_projects_by_tag($selected_tags)
# @users_results = get_users_by_tag($selected_tags)
@ -151,6 +155,7 @@ class TagsController < ApplicationController
@obj_pages = nil
@numbers = Setting.tags_show_search_results
# @issues_results = get_issues_by_tag($selected_tags)
# @projects_results = get_projects_by_tag($selected_tags)
# @users_results = get_users_by_tag($selected_tags)
@ -201,8 +206,8 @@ class TagsController < ApplicationController
def count(name)
end
def show
def show_all
@tags = ActsAsTaggableOn::Tag.find(:all)
end
def for_pagination(results)
@ -212,5 +217,25 @@ class TagsController < ApplicationController
@offset ||= @obj_pages.offset
results = results.offset(@offset).limit(@limit).order('lft').all
end
def delete
if params[:q]
@tag = ActsAsTaggableOn::Tag.find_by_id(params[:q])
@tag.delete
@taggings = ActsAsTaggableOn::Tagging.find_all_by_tag_id(@tag.id)
@taggings.each do |tagging|
tagging.delete
end
end
end
private
def tagged_on_object(object)
end
end

View File

@ -0,0 +1 @@

View File

@ -1,5 +1,12 @@
<% content_for :content do %>
<h3 style="color: red;">总标签数:<%= @tags.size %>个</h3>
<hr />
<% i = 0 %>
<div id="show_all_tags">
<% for tag in @tags %>
<span id="tag">
<%= tag.name %>
<span id="tag" class="tag<%= tag.id %>">
<%= link_to tag.name,:remote=>true,:action=>"delete",:q => tag.id%>
</span>
<% end %>
<% end %>
</div>

View File

@ -455,6 +455,7 @@ RedmineApp::Application.routes.draw do
match 'tags/show_all',:to => 'tags#show_all'
match 'parise_tread/praise_plus',:to => 'parise_tread#praise_plus',:as=>"praise"
match 'parise_tread/tread_plus',:to => 'parise_tread#tread_plus',:as=>"tread"
match 'tags/delete',:to=>'tags#delete'
end