parent
61e4021625
commit
2079c87362
@ -0,0 +1,43 @@
|
||||
module TagsHelper
|
||||
|
||||
# 通过 id和type获取对象
|
||||
def get_object(obj_id,obj_type)
|
||||
@obj = nil
|
||||
case obj_type
|
||||
when '1'
|
||||
@obj = User.find_by_id(obj_id)
|
||||
when '2'
|
||||
@obj = Project.find_by_id(obj_id)
|
||||
when '3'
|
||||
@obj = Issue.find_by_id(obj_id)
|
||||
when '4'
|
||||
@obj = Bid.find_by_id(obj_id)
|
||||
end
|
||||
return @obj
|
||||
end
|
||||
|
||||
# 判断登录用户是否可以对用户、项目、需求、问题中tag进行删除动作
|
||||
# 这里关于项目可以使用User.memeber_of?来做判断,这样可以提高该函数效率,但对满足需求有偏差
|
||||
# 返回值为true 或 false
|
||||
def can_remove_tag(user,obj_id,obj_type)
|
||||
@result = false
|
||||
case obj_type
|
||||
when '1' # 对用户 是否是本人
|
||||
@obj = User.find_by_id(obj_id)
|
||||
if user == @obj
|
||||
@result = true
|
||||
end
|
||||
when '2'
|
||||
@result = is_manager?(user.id,obj_id)
|
||||
when '3'
|
||||
@project_id = Issue.find_by_id(obj_id)
|
||||
@result = is_manager?(user.id,@project_id)
|
||||
when '4'
|
||||
if user.id == obj_id
|
||||
@result = true
|
||||
end
|
||||
end
|
||||
return @result
|
||||
end
|
||||
|
||||
end
|
@ -1,41 +1,84 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
// $(this).ready(function(){
|
||||
// $('.tag_show').hover(function() {
|
||||
// $(this).children("span").show();
|
||||
// }, function() {
|
||||
// $(this).children("span").hide();
|
||||
// });
|
||||
})
|
||||
</script>
|
||||
<!-- 1代表是user类型 2代表是project类型 3代表是issue类型 4代表需求-->
|
||||
<% @tags = obj.reload.tag_list %>
|
||||
|
||||
<% if non_list_all and (@tags.size > 0) %>
|
||||
<!-- 这里是显示的非主页的tag 所以当tag数量较多时 不必全部显示 用“更多”代替 -->
|
||||
<% if @tags.size > Setting.show_tags_length.to_i then %>
|
||||
<% i = 0 %>
|
||||
<% if @tags.size > Setting.show_tags_length.to_i then %>
|
||||
<% i = 0 %>
|
||||
|
||||
<% until i>Setting.show_tags_length.to_i do %>
|
||||
<div id="tag">
|
||||
<%= link_to @tags[i], :controller => "tags",:action => "index",:q => @tags[i],:object_flag => object_flag,:obj_id => obj.id %>
|
||||
</div>
|
||||
<% i += 1%>
|
||||
<% end %>
|
||||
<% until i>Setting.show_tags_length.to_i do %>
|
||||
<div id="tag">
|
||||
<%= link_to @tags[i], :controller => "tags",:action => "index",:q => @tags[i],:object_flag => object_flag,:obj_id => obj.id %>
|
||||
</div>
|
||||
<% i += 1%>
|
||||
<% end %>
|
||||
|
||||
<%= link_to l(:label_more_tags),:action => "show",:id => obj.id %>
|
||||
<%= link_to l(:label_more_tags),:action => "show",:id => obj.id %>
|
||||
|
||||
<% else %>
|
||||
<% else %>
|
||||
|
||||
<% @tags.each do |tag| %>
|
||||
<div id="tag">
|
||||
<%= link_to tag,:controller => "tags",:action => "index",:q=>tag,:object_flag => object_flag,:obj_id => obj.id %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% @tags.each do |tag| %>
|
||||
<div id="tag">
|
||||
<%= link_to tag,:controller => "tags",:action => "index",:q=>tag,:object_flag => object_flag,:obj_id => obj.id %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% else %>
|
||||
<!-- 用来显示三大对象的主页中的tag 故是全部显示 -->
|
||||
<% if @tags.size > 0 %>
|
||||
<% @tags.each do |tag| %>
|
||||
<div id="tag">
|
||||
<%= link_to tag,:controller => "tags",:action => "index",:q=>tag ,:object_flag => object_flag,:obj_id => obj.id %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<div style="color:#919294;"><%= l(:label_tags_no) %></div>
|
||||
<% end %>
|
||||
|
||||
<% if @tags.size > 0 %>
|
||||
<% @tags.each do |tag| %>
|
||||
<div id="tag">
|
||||
<span class="tag_show"> <%= link_to tag,:controller => "tags",:action => "index",:q=>tag ,:object_flag => object_flag,:obj_id => obj.id %>
|
||||
<!-- 对用户主页 是本人 ,对项目,需求,问题是管理员 -->
|
||||
<% case object_flag %>
|
||||
<% when '1'%>
|
||||
|
||||
<% if User.current.eql?(obj) %>
|
||||
<span class='del'> <%= link_to 'x',:controller => "tags",:action => "remove_tag",:remote => true,:tag_name => tag,
|
||||
:taggable_id => obj.id,:taggable_type => object_flag %> </span>
|
||||
<% end %>
|
||||
|
||||
<% when '2' %>
|
||||
|
||||
<% if (ProjectInfo.find_by_project_id(obj.id)).user_id == User.current.id %>
|
||||
<span class='del'> <%= link_to 'x',:controller => "tags",:action => "remove_tag",:remote => true,:tag_name => tag,
|
||||
:taggable_id => obj.id,:taggable_type => object_flag %> </span>
|
||||
<% end %>
|
||||
|
||||
<% when '3' %>
|
||||
|
||||
<% if (ProjectInfo.find_by_project_id(obj.project_id)).user_id == User.current.id %>
|
||||
<span class='del'> <%= link_to 'x',:controller => "tags",:action => "remove_tag",:remote => true,:tag_name => tag,
|
||||
:taggable_id => obj.id,:taggable_type => object_flag %> </span>
|
||||
<% end %>
|
||||
|
||||
<% when '4'%>
|
||||
<% if obj.author_id == User.current.id %>
|
||||
|
||||
<span class='del'> <%= link_to 'x',:controller => "tags",:action => "remove_tag",:remote => true,:tag_name => tag,
|
||||
:taggable_id => obj.id,:taggable_type => object_flag %> </span>
|
||||
|
||||
<% end %>
|
||||
<% end %>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<div style="color:#919294;">
|
||||
<%= l(:label_tags_no) %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
@ -1,14 +1,16 @@
|
||||
|
||||
|
||||
<% if @obj_flag == '3'%>
|
||||
|
||||
$('#tags_show_issue').html('<%= escape_javascript(render :partial => 'tags/tag_name',
|
||||
:locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>');
|
||||
$('#put-tag-form-issue').hide();
|
||||
$('#name-issue').val("");
|
||||
|
||||
<% else %>
|
||||
|
||||
$('#tags_show').html('<%= escape_javascript(render :partial => 'tags/tag_name',
|
||||
:locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>');
|
||||
$('#put-tag-form').hide();
|
||||
$('#name').val("");
|
||||
|
||||
<% end %>
|
||||
|
||||
|
Loading…
Reference in new issue