tag删除功能完成,翻页样式修改

course_group
z9hang 11 years ago
parent a7a6fbcd22
commit 0821320dfe

@ -14,6 +14,7 @@ class TagsController < ApplicationController
include AttachmentsHelper
include ContestsHelper
include ActsAsTaggableOn::TagsHelper
include TagsHelper
helper :projects
helper :courses
helper :tags
@ -189,6 +190,40 @@ class TagsController < ApplicationController
end
end
# 只删除某个对象的该tag
def remove_tag_new
@obj = nil
@object_flag = nil
if request.get?
# 获取传过来的tag_id taggable_id 和 taggable_type,通过2者确定要删除tag的对象
@tag_name = params[:tag_name]
@tag_id = (ActsAsTaggableOn::Tag.find_by_name(@tag_name)).id
@taggable_id = params[:taggable_id] # 当做参数传时对象会变成字符串
@taggable_type = numbers_to_object_type(params[:taggable_type])
@obj = get_object(@taggable_id,params[:taggable_type])
@object_flag = params[:taggable_type]
# if can_remove_tag?(User.current,@taggable_id,@taggable_type)
@taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,@taggable_id,@taggable_type)
unless @taggings.nil?
@taggings.delete
end
# 是否还有其他记录 引用了 tag_id
@tagging = ActsAsTaggableOn::Tagging.find_by_tag_id(@tag_id)
# 如果taggings表中记录已经不存在 那么检查tags表 作删除动作
if @tagging.nil?
@tag = ActsAsTaggableOn::Tag.find_by_id(@tag_id)
@tag.delete unless @tag.nil?
end
# end
end
end
def tag_save
@tags = params[:tag_for_save][:name]
@obj_id = params[:tag_for_save][:object_id]

@ -11,7 +11,7 @@
<input type="submit" value="课内搜索" class="re_schbtn b_dblue" />
<input type="submit" value="全站搜索" class="re_schbtn b_lblue" />
</form>
<a href="#" class="re_fabu f_r b_lblue">发布资源</a>
<a href="#" class="re_fabu f_r b_lblue">上传资源</a>
</div><!---re_top end-->
<div class="cl"></div>

@ -7,7 +7,7 @@
<% case object_flag %>
<% when '6' %>
<% if obj.author_id == User.current.id || User.current.admin?%>
<span class='del'> <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag,
<span class='del'> <%= link_to 'x', :controller => "tags", :action => "remove_tag_new", :remote => true, :tag_name => tag,
:taggable_id => obj.id, :taggable_type => object_flag %> </span>
<% end %>
<% end %>

@ -0,0 +1,6 @@
//本js使用的新的tag显示方法
<% if @object_flag == "6"%>
$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty();
$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").html('<%= escape_javascript(render :partial => 'tags/tag_list',
:locals => {:obj => @obj,:non_list_all => false,:object_flag => @object_flag}) %>');
<% end %>

@ -792,6 +792,7 @@ RedmineApp::Application.routes.draw do
match 'parise_tread/tread_plus', :as=>"tread"
match 'tags/delete'
match 'tags/remove_tag', :as=>"remove_tag"
match 'tags/remove_tag_new', :as=>"remove_tag_new"
match 'tags/tag_save', :as => "save_tag"
match 'words/add_brief_introdution'

@ -55,10 +55,12 @@ a:hover.re_open{background:url(images/pic_open02.png) 0 0 no-repeat;}
a.re_de{ color:#6883b6; margin-left:15px;}
.re_con_box{ border-bottom:1px dashed #dadada; padding:10px 0;}
/****翻页***/
.wlist{ margin-top:15px;}
.wlist a{ float:right; border:1px solid #15bccf; padding:0 5px; margin-left:3px; color:#15bccf;}
.wlist a:hover{border:1px solid #15bccf; background-color:#15bccf; color:#fff;}
.wlist_select a { background-color:#64bdd9; color:#fff;}
ul.wlist{ float:right; border-bottom:none; height:30px; margin-top:20px; }
.wlist li{float: left;}
.wlist span{ border:1px solid #15bccf; padding:0 5px; margin-left:3px;}
.wlist a{display: block; border:1px solid #15bccf; padding:0 5px; margin-left:3px;}
.wlist a:hover{ background:#15bccf; color:#fff; text-decoration:none;}
.wlist_select { background-color:#64bdd9; color:#fff; padding:0 5px; margin-left:3px; border:1px solid #64bdd9;}
/****标签***/
a.yellowBtn{ display:inline-block;color:#0d90c3; height:22px;}
.submit

Loading…
Cancel
Save