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,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