From ddecd61926ff7720ffc7d5af6ed1ef6bd2810014 Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 26 Mar 2015 20:17:47 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=B5=84=E6=BA=90=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=A0=87=E7=AD=BE=E6=97=B6=E6=97=A0=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/tags_controller.rb | 2 + app/views/files/_course_list.html.erb | 4 +- .../tags/_course_attachment_tag_name.erb | 56 +++++++++++++++++++ app/views/tags/_tag_list.html.erb | 7 ++- app/views/tags/_tag_new.html.erb | 7 +++ app/views/tags/tag_save.js.erb | 6 ++ 6 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 app/views/tags/_course_attachment_tag_name.erb diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 6738d2135..2a0d0445d 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -248,6 +248,8 @@ class TagsController < ApplicationController @obj = OpenSourceProject.find_by_id(@obj_id) when '9' @obj = Course.find_by_id(@obj_id) + when '10' + @obj = Attachment.find_by_id(@obj_id) else @obj = nil end diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index 8af369558..7dc047c5e 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -44,8 +44,8 @@
- <%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "6"} %> - <%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6"} %> + <%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "10"} %> + <%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "10"} %>
diff --git a/app/views/tags/_course_attachment_tag_name.erb b/app/views/tags/_course_attachment_tag_name.erb new file mode 100644 index 000000000..699f7208f --- /dev/null +++ b/app/views/tags/_course_attachment_tag_name.erb @@ -0,0 +1,56 @@ + + +<% @tags = obj.reload.tag_list %> +<% if non_list_all and (@tags.size > 0) %> + + <% if @tags.size > Setting.show_tags_length.to_i then %> + <% i = 0 %> + <% until i>Setting.show_tags_length.to_i do %> +
+ <%= link_to @tags[i], :controller => "tags", :action => "index", :q => @tags[i], :object_flag => object_flag, :obj_id => obj.id %> +
+ <% i += 1 %> + <% end %> + <%= more_tags(obj.id,object_flag)%> + <% else %> + <% @tags.each do |tag| %> +
+ <%= link_to tag, :controller => "tags", :action => "index", :q => tag, :object_flag => object_flag, :obj_id => obj.id %> +
+ <% end %> + <% end %> +<% else %> + + <% if @tags.size > 0 %> + <% @tags.each do |tag| %> +
+ + <%= link_to tag, :controller => "tags", :action => "index", :q => tag, :object_flag => object_flag, :obj_id => obj.id %> + + <% case object_flag %> + <% when '10' %> + <%# if (User.current.logged? && + User.current.admin? + # && (@project && User.current.member_of?(@project)) + ) + %> + <% if obj.author_id == User.current.id || User.current.admin?%> + + <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag, + :taggable_id => obj.id, :taggable_type => object_flag %> + + <% end %> + <% end %> + +
+ <% end %> + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/tags/_tag_list.html.erb b/app/views/tags/_tag_list.html.erb index 549ed1751..e18dafd7d 100644 --- a/app/views/tags/_tag_list.html.erb +++ b/app/views/tags/_tag_list.html.erb @@ -5,7 +5,12 @@ <%= link_to tag, :controller => "tags", :action => "index", :q => tag, :object_flag => object_flag, :obj_id => obj.id %> <% case object_flag %> - <% when '6' %> + <% when '10' %> + <% if obj.author_id == User.current.id || User.current.admin?%> + <%= link_to 'x', :controller => "tags", :action => "remove_tag_new", :remote => true, :tag_name => tag, + :taggable_id => obj.id, :taggable_type => object_flag %> + <% end %> + <% when '6' %> <% if obj.author_id == User.current.id || User.current.admin?%> <%= link_to 'x', :controller => "tags", :action => "remove_tag_new", :remote => true, :tag_name => tag, :taggable_id => obj.id, :taggable_type => object_flag %> diff --git a/app/views/tags/_tag_new.html.erb b/app/views/tags/_tag_new.html.erb index eb49005ae..0d5d371e3 100644 --- a/app/views/tags/_tag_new.html.erb +++ b/app/views/tags/_tag_new.html.erb @@ -12,6 +12,13 @@ <% if object_flag == '3' %> + <% elsif object_flag == '10' %> +
+ <%= render :partial => "tags/tag_list",:locals => {:obj => obj,:object_flag => object_flag} %> +
+ <% elsif object_flag == '6' %>
<%= render :partial => "tags/tag_list",:locals => {:obj => obj,:object_flag => object_flag} %> diff --git a/app/views/tags/tag_save.js.erb b/app/views/tags/tag_save.js.erb index b4866bb89..2bef1a3a3 100644 --- a/app/views/tags/tag_save.js.erb +++ b/app/views/tags/tag_save.js.erb @@ -14,6 +14,12 @@ $("#put-tag-form-<%=@obj.class%>-<%=@obj.id%> #name").val(""); $('#tags_show').html('<%= escape_javascript(render :partial => 'tags/new_tag_name', :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); $('#tags_name').val(""); +<% elsif @obj_flag == '10'%> +$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty(); +$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").html('<%= escape_javascript(render :partial => 'tags/course_attachment_tag_name', + :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); +//$("#put-tag-form-<%#=@obj.class%>-<%#=@obj.id%>").hide(); +$("#tags_name_<%=@obj.id%>").val(""); <% else%> $('#tags_show').html('<%= escape_javascript(render :partial => 'tags/tag_name', :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>');