diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index 3c815c7d8..a57b5f8a5 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -141,6 +141,23 @@ class AttachmentsController < ApplicationController
end
end
+ def update_file_dense
+ @attachment = Attachment.find(params[:attachmentid])
+ if @attachment != nil
+ filedense = params[:newtype].to_s
+ if filedense == "1"
+ @attachment.is_public = 1
+ else
+ @attachment.is_public = 0
+ end
+ @attachment.save
+ @newfiledense = filedense
+ end
+ respond_to do |format|
+ format.js
+ end
+ end
+
def thumbnail
if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size])
if stale?(:etag => thumbnail)
@@ -326,6 +343,35 @@ class AttachmentsController < ApplicationController
end
end
+ def add_exist_file_to_courses
+ file = Attachment.find(params[:file_id])
+ courses = params[:courses][:course]
+ courses.each do |course|
+ c = Course.find(course);
+ attach_copied_obj = file.copy
+ attach_copied_obj.tag_list.add(file.tag_list) # tag关联
+ attach_copied_obj.container = c
+ attach_copied_obj.created_on = Time.now
+ attach_copied_obj.author_id = User.current.id
+ attach_copied_obj.copy_from = file.copy_from.nil? ? file.id : file.copy_from
+ if attach_copied_obj.attachtype == nil
+ attach_copied_obj.attachtype = 4
+ end
+ @obj = c
+ @save_flag = attach_copied_obj.save
+ @save_message = attach_copied_obj.errors.full_messages
+ end
+ respond_to do |format|
+ format.js
+ end
+ rescue NoMethodError
+ @save_flag = false
+ @save_message = [] << l(:error_attachment_empty)
+ respond_to do |format|
+ format.js
+ end
+ end
+
private
def find_project
@attachment = Attachment.find(params[:id])
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index 91176efdf..6de800efc 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -22,22 +22,55 @@ class FilesController < ApplicationController
menu_item :files
before_filter :find_project_by_project_id#, :except => [:getattachtype]
- before_filter :authorize, :except => [:getattachtype]
+ before_filter :authorize, :except => [:getattachtype,:quote_resource_show,:search]
helper :sort
include SortHelper
helper :project_score
def show_attachments obj
- all_attachments = []
+ @all_attachments = []
obj.each do |container|
- all_attachments += container.attachments
+ @all_attachments += container.attachments
end
@limit = 10
- @feedback_count = all_attachments.count
+ @feedback_count = @all_attachments.count
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
@offset ||= @feedback_pages.offset
- @curse_attachments = all_attachments[@offset, @limit]
+ @curse_attachments_all = @all_attachments[@offset, @limit]
+ @curse_attachments = paginateHelper @all_attachments,10
+ end
+
+ def search
+ begin
+ @is_remote = true
+ q = "%#{params[:name].strip}%"
+ #(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
+ if params[:insite]
+ @result = find_public_attache q
+ @searched_attach = paginateHelper @result,10
+ else
+ @result = find_course_attache q,@course
+ @searched_attach = paginateHelper @result,10
+ end
+
+ rescue Exception => e
+ #render 'stores'
+ redirect_to stores_url
+ end
+ end
+
+ def find_course_attache keywords,course
+ resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ", like: "%#{keywords}%").
+ reorder("created_on DESC")
+ end
+
+ def find_public_attache keywords
+ # StoresController#search 将每条文件都查出来,再次进行判断过滤。---> resultSet.to_a.map
+ # 此时内容不多速度还可,但文件增长,每条判断多则进行3-4次表连接。
+ # 现在还木有思路 药丸
+ resultSet = Attachment.where("attachments.container_type IS NOT NULL AND (is_public = 1 OR author_id = #{User.current.id}) AND filename LIKE :like ", like: "%#{keywords}%").
+ reorder("created_on DESC")
end
def index
@@ -48,7 +81,9 @@ class FilesController < ApplicationController
'size' => "#{Attachment.table_name}.filesize",
'downloads' => "#{Attachment.table_name}.downloads"
sort = ""
-
+ @sort = ""
+ @order = ""
+ @is_remote = false
if params[:project_id]
@isproject = true
@@ -113,7 +148,8 @@ class FilesController < ApplicationController
when "created_on"
attribute = "created_on"
end
-
+ @sort = order_by[0]
+ @order = order_by[1]
if order_by.count == 1
sort += "#{Attachment.table_name}.#{attribute} asc "
elsif order_by.count == 2
@@ -134,6 +170,10 @@ class FilesController < ApplicationController
end
+ def quote_resource_show
+ @file = Attachment.find(params[:id])
+ end
+
def new
@versions = @project.versions.sort
@course_tag = @project.project_type
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index 9e9a34d55..f3c2b199c 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -17,7 +17,6 @@
class IssuesController < ApplicationController
layout 'base_projects'#Added by young
- menu_item :new_issue, :only => [:new, :create]
default_search_scope :issues
before_filter :find_issue, :only => [:show, :edit, :update]
diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb
index 9257888dd..aaa99e417 100644
--- a/app/controllers/memos_controller.rb
+++ b/app/controllers/memos_controller.rb
@@ -19,7 +19,7 @@ class MemosController < ApplicationController
@content = "#{ll(Setting.default_language, :text_user_wrote, @memo.author)}
"
@content << @memo.content.to_s.strip.gsub(%r{
((.|\s)*?)}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n") + "\n\n
" << @content + @content = "" << @content #@content = "> #{ll(Setting.default_language, :text_user_wrote, @memo.author)}\n> " #@content << @memo.content.to_s.strip.gsub(%r{((.|\s)*?)}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" #@content_html = textilizable(@content) diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index b64c18b33..5bd5fb0e3 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -14,12 +14,14 @@ class TagsController < ApplicationController include AttachmentsHelper include ContestsHelper include ActsAsTaggableOn::TagsHelper + include TagsHelper helper :projects helper :courses helper :tags include OpenSourceProjectsHelper before_filter :require_admin,:only => [:delete,:show_all] + before_filter :require_login,:only => [:tag_save] # $selected_tags = Array.new # $related_tags = Array.new @@ -187,6 +189,83 @@ class TagsController < ApplicationController # end 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] + @obj_flag = params[:tag_for_save][:object_flag] + + case @obj_flag + when '1' then + @obj = User.find_by_id(@obj_id) + when '2' then + @obj = Project.find_by_id(@obj_id) + when '3' then + @obj = Issue.find_by_id(@obj_id) + when '4' then + @obj = Bid.find_by_id(@obj_id) + when '5' then + @obj = Forum.find_by_id(@obj_id) + when '6' + @obj = Attachment.find_by_id(@obj_id) + when '7' then + @obj = Contest.find_by_id(@obj_id) + when '8' + @obj = OpenSourceProject.find_by_id(@obj_id) + when '9' + @obj = Course.find_by_id(@obj_id) + else + @obj = nil + end + unless @obj.nil? + @obj.tag_list.add(@tags.split(",")) + else + return + end + if @obj.save + logger.debug "#{__FILE__}:#{__LINE__} ===> #{@obj.to_json}" + else + logger.error "#{__FILE__}:#{__LINE__} ===> #{@obj.errors.try(:full_messages)}" + end + respond_to do |format| + format.js + format.html + end + end private # 这里用来刷新搜索结果的区域 @@ -307,5 +386,7 @@ class TagsController < ApplicationController return end end + + end diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index 7ea49dad2..3c882d393 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_helper.rb @@ -177,6 +177,8 @@ module AttachmentsHelper s.html_safe end + + # Modified by Longjun # 有参数的方法要加() def private_filter(resultSet) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index ac22ed412..178782da3 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -328,7 +328,7 @@ module CoursesHelper #当前用户是不是指定课程的学生 def is_cur_course_student course #course.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and members.user_id = #{User.current.id}", {:role_id => StudentRoles}).count != 0 - !(User.current.allowed_to?(:as_teacher,course)) + User.current.logged? && User.current.member_of_course?(course) && !(User.current.allowed_to?(:as_teacher,course)) #修改:能新建占位且不能新建任务的角色判定为学生 #is_student = false #@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current)) diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index 052aae468..9a0a1127f 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -44,6 +44,16 @@ module FilesHelper File.new(zipfile_name,'w+') end + def courses_check_box_tags(name,courses,current_course) + s = '' + courses.each do |course| + if course.id != current_course.id && is_course_teacher(User.current,course) + s << "
" + end + end + s.html_safe + end + # 判断指定的资源时候符合类型 def isTypeOk(attachment, type, contentType) result = false diff --git a/app/models/memo.rb b/app/models/memo.rb index 847795b4f..cfc509923 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -88,7 +88,7 @@ class Memo < ActiveRecord::Base def editable_by? user # user && user.logged? || (self.author == usr && usr.allowed_to?(:edit_own_messages, project)) - (user && self.author == user) || user.admin? + user.admin? || self.author == user end def destroyable_by? user diff --git a/app/views/account/register.html.erb b/app/views/account/register.html.erb index 32940d111..21bdd8fa7 100644 --- a/app/views/account/register.html.erb +++ b/app/views/account/register.html.erb @@ -22,12 +22,12 @@<%= f.password_field :password, :size => 25, :required => true %> <%= l(:text_caracters_minimum, :count => Setting.password_min_length) %>
-<%= f.password_field :password_confirmation, :size => 25, :required => true %>
+<%= f.password_field :password_confirmation, :size => 25, :required => true %>
<% end %><%= f.text_field :mail,:size => 25, :required => true %> - +
diff --git a/app/views/admin/search.html.erb b/app/views/admin/search.html.erb index 758c7b32f..320fce125 100644 --- a/app/views/admin/search.html.erb +++ b/app/views/admin/search.html.erb @@ -54,7 +54,7 @@
<%= change_status_link(user) %> - <%= delete_link user_path(user, :back_url => admin_users_path(params)) unless User.current == user %> + <%= delete_link user_path(user, :back_url => admin_search_path(params)) unless User.current == user %> <% end -%> diff --git a/app/views/attachments/add_exist_file_to_courses.js.erb b/app/views/attachments/add_exist_file_to_courses.js.erb new file mode 100644 index 000000000..23761647f --- /dev/null +++ b/app/views/attachments/add_exist_file_to_courses.js.erb @@ -0,0 +1,5 @@ +<% if !@save_flag%> + $("#error_show").html("<%= @save_message.join(', ') %>"); +<% else %> + closeModal(); +<% end %> diff --git a/app/views/attachments/update_file_dense.js.erb b/app/views/attachments/update_file_dense.js.erb new file mode 100644 index 000000000..d99481d08 --- /dev/null +++ b/app/views/attachments/update_file_dense.js.erb @@ -0,0 +1,2 @@ +$("#is_public_<%= @attachment.id %>").html("<%= escape_javascript(link_to (@attachment.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>@attachment.id,:newtype=>(@attachment.is_public? ? 0:1)), + :remote=>true,:class=>"f_l re_open",:method => :post) %>"); diff --git a/app/views/files/_arrow_show.erb b/app/views/files/_arrow_show.erb new file mode 100644 index 000000000..d8f094719 --- /dev/null +++ b/app/views/files/_arrow_show.erb @@ -0,0 +1,10 @@ + +<% if sort == current %> + <% if order =="asc" %> + ↑ + <% elsif order == "desc" %> + ↓ + <% else %> + + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/files/_attachement_list.html.erb b/app/views/files/_attachement_list.html.erb new file mode 100644 index 000000000..f65ba8d41 --- /dev/null +++ b/app/views/files/_attachement_list.html.erb @@ -0,0 +1,46 @@ ++ +<% if defined?(container) && container && container.saved_attachments %> + <% container.attachments.each_with_index do |attachment, i| %> + + + <% end %> +<% end %> ++ + +<%= file_field_tag 'attachments[dummy][file]', + :id => '_file', + :class => 'file_selector', + :multiple => true, + :onchange => 'addInputFiles(this);', + :style => 'display:none', + :data => { + :max_file_size => Setting.attachment_max_size.to_i.kilobytes, + :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), + :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, + :upload_path => uploads_path(:format => 'js'), + :description_placeholder => l(:label_optional_description) + } %> + + \ No newline at end of file diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb index 46a954746..49747ae11 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -2,84 +2,43 @@ <% sufixtypes = @course.contenttypes %> -<%= t(:label_user_course) %>资源共享区 +<%= stylesheet_link_tag 'resource', :media => 'all' %> + - <%= link_to(l(:label_upload_files), 'javascript:void(0);', :class => 'icon m5p5 button_submit', :onclick => "$('#relation_file_div').slideUp();$('#upload_file_div').slideToggle('slow');") if User.current.allowed_to?(:manage_files, @course) %> - <%= link_to(l(:label_relation_files), 'javascript:void(0);', :onclick => "$('#upload_file_div').slideUp();$('#relation_file_div').slideToggle();", :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @course) %> - - ++-<%= javascript_tag "observeSearchfield('attach_search', null, '#{ escape_javascript attachments_autocomplete_path(:course_id => @course.id, :format => 'js') }')" %> - -<% delete_allowed = User.current.allowed_to?(:manage_files, @course) %> - -+-+ <%= form_tag( search_course_files_path(@course), method: 'get',:class => "re_search f_l",:remote=>true) do %> + <%= text_field_tag 'name', params[:name], name: "name", :class => 're_schbox',:style=>"padding: 0px"%> + <%= submit_tag "课内搜索", :class => "re_schbtn b_dblue",:name => "incourse"%> + <%= submit_tag "全站搜索", :class => "re_schbtn b_lblue",:name => "insite" %> + <% end %> + <% if is_course_teacher(User.current,@course) %> + 上传资源 + <% end %> ++ - - -- - <% if attachmenttypes.any? %> - - - <%= select_tag "attachment_browse", content_tag(:option, l(:attachment_all), :value => '0' ) +options_from_collection_for_select(attachmenttypes, "id", "typeName", params[:type]), - - :onchange => "course_attachmenttypes_searchex(this.value)" %> - <% end %> - <% if sufixtypes.any? %> - - - <%= select_tag "attach_sufix_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_for_select(sufixtypes), - :onchange => "course_attachment_contenttypes_searchex(this.value)" %> - <% end %> -++<%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@curse_attachments} %> +- <%#= render :partial => 'course_show_all_attachment' %> - <% if (@attachtype==0 && @contenttype=='0') || (@attachtype.nil? && @contenttype.nil?) %> - - <%= render partial: "course_show_all_attachment"%> - - <%else%> - - <%= render partial: "course_sort_by_attachtypel"%> - - <%end%>- <% html_title(l(:label_attachment_plural)) -%> \ No newline at end of file diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb new file mode 100644 index 000000000..fa22c404d --- /dev/null +++ b/app/views/files/_course_list.html.erb @@ -0,0 +1,56 @@ +<% delete_allowed = User.current.allowed_to?(:manage_files, course) %> +++ +<% curse_attachments.each do |file| %> + <%if file.is_public == 0 && !User.current.member_of_course?(@course)%> + <%next%> + <%end%> +共有 <%= User.current.member_of_course?(course) ? all_attachments.count : 0 %> 个资源
+ +++<% end %> ++ <%= link_to_attachment file, :download => true,:text => truncate(file.filename,length: 35, omission: '...'), :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> + <% if is_course_teacher(User.current,@course) %> + <%= link_to "选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true %> + <% if delete_allowed && file.container_id == @course.id && file.container_type == "Course" %> + + <%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open",:method => :post %> + + <% else %> + <%= link_to (file.is_public? ? "公开":"私有"),"javascript:void(0)",:class=>"f_l re_open" %> + <% end %> + + <% else %> + <%= link_to (file.is_public? ? "公开":"私有"),"javascript:void(0)",:class=>"f_l re_open" %> + <% end %> ++ +++ +文件大小:<%= number_to_human_size(file.filesize) %>
+ <%= link_to( l(:button_delete), attachment_path(file), + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if delete_allowed && file.container_id == @course.id && file.container_type == "Course"%> +<%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %> | 下载<%= file.downloads %> | 引用0
++ <%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "6"} %> + <%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6"} %> ++ ++ <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => @is_remote, :flag => true%> +
+ \ No newline at end of file diff --git a/app/views/files/_show_quote_resource.html.erb b/app/views/files/_show_quote_resource.html.erb new file mode 100644 index 000000000..8041802a5 --- /dev/null +++ b/app/views/files/_show_quote_resource.html.erb @@ -0,0 +1,24 @@ +++ + \ No newline at end of file diff --git a/app/views/files/_upload_show.html.erb b/app/views/files/_upload_show.html.erb new file mode 100644 index 000000000..a979715de --- /dev/null +++ b/app/views/files/_upload_show.html.erb @@ -0,0 +1,26 @@ ++ ++将此课件引入我的课程资源库
+ + ++ + <% content_for :header_tags do %> + <%= javascript_include_tag 'attachments' %> + <% end %> ++ + \ No newline at end of file diff --git a/app/views/files/create.js.erb b/app/views/files/create.js.erb index 0eca9c1ed..90215c16c 100644 --- a/app/views/files/create.js.erb +++ b/app/views/files/create.js.erb @@ -27,6 +27,8 @@ $('#upload_file_div').slideToggle('slow'); $("#all_browse_div").html('<%= j(render partial: "show_all_attachment")%>'); <%elsif @course%> $("#all_browse_div").html('<%= j(render partial: "course_show_all_attachment")%>'); +closeModal(); +$("#resource_list").html('<%= j(render partial: "course_file" ,locals: {course: @course}) %>'); <%end%> <% end %> diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index 69b41fc28..fe04c4e3f 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -1,10 +1,11 @@ +<% if @isproject %> <%= render :partial => 'project_file', locals: {project: @project} %> <% else %> <%= render :partial => 'course_file', locals: {course: @course} %> <% end %> - +-<%= l(:label_attachment_plural) %>
- <%= render :partial => 'attachments/form' %> ++ <%= l(:label_attachment_plural) %> +
<%= f.submit value: l(:label_reply_plural), class: "replies" %> <% end %> \ No newline at end of file diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb index b7e5e2749..5222b466f 100644 --- a/app/views/memos/show.html.erb +++ b/app/views/memos/show.html.erb @@ -117,28 +117,34 @@
+ <%= render :partial => 'attachments/form' %>
-+
<% end %> -
<%= link_to image_tag(url_to_avatar(reply.author), :class => "avatar"), user_path(reply.author) %> -- <%=h sanitize(reply.content.html_safe) %>++ + <%=h sanitize(reply.content.html_safe) %> +<% if reply.attachments.any?%> - <% options = {:author => true, :deletable => reply.deleted_attach_able_by?(User.current) } %> - <%= render :partial => 'attachments/links', :locals => {:attachments => reply.attachments, :options => options} %> + <% options = {:author => true, :deletable => reply.deleted_attach_able_by?(User.current) } %> + <%= render :partial => 'attachments/links', :locals => {:attachments => reply.attachments, :options => options} %> <% end %>
- <%= authoring reply.created_at, reply.author %> ++ <%= authoring reply.created_at, reply.author %> + <%= pagination_links_full @reply_pages, @reply_count, :per_page_links => false %>++ <%= pagination_links_full @reply_pages, @reply_count, :per_page_links => false %> +<% if User.current.login? %> diff --git a/app/views/tags/_tag_add.html.erb b/app/views/tags/_tag_add.html.erb new file mode 100644 index 000000000..14f2dc965 --- /dev/null +++ b/app/views/tags/_tag_add.html.erb @@ -0,0 +1,13 @@ +<%= link_to '+ 添加标签', 'javascript:void(0);', + :class => "yellowBtn f_l", + :onclick=>"$('#add_tag_#{obj.id}').slideToggle();" if User.current.logged? %> + \ No newline at end of file diff --git a/app/views/tags/_tag_list.html.erb b/app/views/tags/_tag_list.html.erb new file mode 100644 index 000000000..c815d71f8 --- /dev/null +++ b/app/views/tags/_tag_list.html.erb @@ -0,0 +1,20 @@ +<% @tags = obj.reload.tag_list %> + +<% 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 '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 %> + <% end %> + <% end %> + + <% end %> +<% else %> + + <%= l(:label_tags_no) %> + +<% end %> \ No newline at end of file diff --git a/app/views/tags/_tag_new.html.erb b/app/views/tags/_tag_new.html.erb new file mode 100644 index 000000000..eb49005ae --- /dev/null +++ b/app/views/tags/_tag_new.html.erb @@ -0,0 +1,24 @@ + <%#begin + 1 代表是user类型 + 2 代表是project类型 + 3 代表是issue类型 + 4 代表是bid类型 + 5 代表是forum类型 + 6 代表是Attachment类型 + 7 代表是contest类型 + 8 代表是OpenSourceProject类型 + 9 代表是RelativeMemo类型 + #end%> + + <% if object_flag == '3' %> + + <% elsif object_flag == '6' %> + + + <% else %> + + <% end %> diff --git a/app/views/tags/remove_tag_new.js.erb b/app/views/tags/remove_tag_new.js.erb new file mode 100644 index 000000000..24d52a35f --- /dev/null +++ b/app/views/tags/remove_tag_new.js.erb @@ -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 %> \ No newline at end of file diff --git a/app/views/tags/tag_save.js.erb b/app/views/tags/tag_save.js.erb new file mode 100644 index 000000000..20ffb54cf --- /dev/null +++ b/app/views/tags/tag_save.js.erb @@ -0,0 +1,9 @@ +//本js使用的新的tag显示方法 +<% if @obj_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 => @obj_flag}) %>'); +//$("#put-tag-form-<%#=@obj.class%>-<%#=@obj.id%>").hide(); +$("#tags_name_<%= @obj.id%>").val(""); +//$('#put-tag-form').hide(); +<% end %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 1a2309c2c..1d28a9ae6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -558,11 +558,13 @@ RedmineApp::Application.routes.draw do match 'attachments/autocomplete', :to => 'attachments#autocomplete', :via => [:post] post 'attachments/relationfile', to: 'attachments#add_exist_file_to_project', as: 'attach_relation' post 'attachments/courserelationfile', to: 'attachments#add_exist_file_to_course', as: 'course_attach_relation' + post 'attachments/courserelationfiles', to: 'attachments#add_exist_file_to_courses', as: 'course_attach_relations' get 'attachments/renderTag/:attchmentId', :to => 'attachments#renderTag', :attchmentId => /\d+/ resources :attachments, :only => [:show, :destroy] do collection do match "updateType" , :via => [:get, :post] match "updateFileDense" , :via => [:get, :post] + match "update_file_dense", :via => [:post] match "renderTag" , :via => [:get, :post] match 'delete_softapplications', :via => [:get, :post] end @@ -652,6 +654,10 @@ RedmineApp::Application.routes.draw do resources :files, :only => [:index, :new, :create] do collection do match "getattachtype", :via => [:get, :post] + match "search",:via => [:post,:get] + end + member do + match "quote_resource_show", :via => [:get] end end resources :memberships, :shallow => true, :controller => 'members', :only => [:index, :show, :new, :create, :update, :destroy] do @@ -792,6 +798,8 @@ 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' diff --git a/db/migrate/20141120091234_add_column_copyfrom_to_attachment.rb b/db/migrate/20141120091234_add_column_copyfrom_to_attachment.rb new file mode 100644 index 000000000..cc8444f6d --- /dev/null +++ b/db/migrate/20141120091234_add_column_copyfrom_to_attachment.rb @@ -0,0 +1,5 @@ +class AddColumnCopyfromToAttachment < ActiveRecord::Migration + def change + add_column("attachments","copy_from",:integer) + end +end diff --git a/public/images/files/btn.png b/public/images/files/btn.png new file mode 100644 index 000000000..85cea7f5c Binary files /dev/null and b/public/images/files/btn.png differ diff --git a/public/images/files/close.png b/public/images/files/close.png new file mode 100644 index 000000000..301ba5e85 Binary files /dev/null and b/public/images/files/close.png differ diff --git a/public/images/files/inputBg.png b/public/images/files/inputBg.png new file mode 100644 index 000000000..243bbf7ec Binary files /dev/null and b/public/images/files/inputBg.png differ diff --git a/public/images/files/pic_open01.png b/public/images/files/pic_open01.png new file mode 100644 index 000000000..45552ae00 Binary files /dev/null and b/public/images/files/pic_open01.png differ diff --git a/public/images/files/pic_open02.png b/public/images/files/pic_open02.png new file mode 100644 index 000000000..b457f302f Binary files /dev/null and b/public/images/files/pic_open02.png differ diff --git a/public/images/files/pic_select01.png b/public/images/files/pic_select01.png new file mode 100644 index 000000000..4f3b294fe Binary files /dev/null and b/public/images/files/pic_select01.png differ diff --git a/public/images/files/pic_select02.png b/public/images/files/pic_select02.png new file mode 100644 index 000000000..e620fad1f Binary files /dev/null and b/public/images/files/pic_select02.png differ diff --git a/public/stylesheets/images/btn.png b/public/stylesheets/images/btn.png new file mode 100644 index 000000000..85cea7f5c Binary files /dev/null and b/public/stylesheets/images/btn.png differ diff --git a/public/stylesheets/images/inputBg.png b/public/stylesheets/images/inputBg.png new file mode 100644 index 000000000..243bbf7ec Binary files /dev/null and b/public/stylesheets/images/inputBg.png differ diff --git a/public/stylesheets/images/pic_open01.png b/public/stylesheets/images/pic_open01.png new file mode 100644 index 000000000..45552ae00 Binary files /dev/null and b/public/stylesheets/images/pic_open01.png differ diff --git a/public/stylesheets/images/pic_open02.png b/public/stylesheets/images/pic_open02.png new file mode 100644 index 000000000..b457f302f Binary files /dev/null and b/public/stylesheets/images/pic_open02.png differ diff --git a/public/stylesheets/images/pic_select01.png b/public/stylesheets/images/pic_select01.png new file mode 100644 index 000000000..4f3b294fe Binary files /dev/null and b/public/stylesheets/images/pic_select01.png differ diff --git a/public/stylesheets/images/pic_select02.png b/public/stylesheets/images/pic_select02.png new file mode 100644 index 000000000..e620fad1f Binary files /dev/null and b/public/stylesheets/images/pic_select02.png differ diff --git a/public/stylesheets/nyan.css b/public/stylesheets/nyan.css index cc5898e0d..50a1de7c4 100644 --- a/public/stylesheets/nyan.css +++ b/public/stylesheets/nyan.css @@ -15,7 +15,7 @@ span[id^=valid_user] { } .red { - color: red;margin-left: 10px;margin-right: 10px;text-align: right; + color: red;margin-right: 10px;text-align: right; } .green { diff --git a/public/stylesheets/resource.css b/public/stylesheets/resource.css new file mode 100644 index 000000000..1046429be --- /dev/null +++ b/public/stylesheets/resource.css @@ -0,0 +1,105 @@ +body{ font-size:12px; font-family:"微软雅黑","宋体"; line-height:1.9; background:#fff; font-style:normal;} +div,html,img,ul,li,p,body,h1,h2,h3,h4,p,a,table,tr,td,fieldset,input,form,span,textarea{ margin:0; padding:0;} +div,img,tr,td,textarea{ border:0;} +table,tr,td{border:0; cellspacing:0; cellpadding:0;} +ul,li{ list-style-type:none} +.cl{ clear:both; overflow:hidden; } +a{ text-decoration:none; text-align:center; } +a:hover{ text-decoration:underline;} +/**** 常用***/ +.f_l{ float:left;} +.f_r{ float:right;} +.b_lblue{ background:#64bdd9 !important;} +.b_dblue{ background:#55a1b9 !important; cursor:pointer !important;} +.f_b{ font-weight: bold !important;} +.c_blue{ color:#64bdd9;} +.c_grey{ color:#999999 !important;} +.c_grey02{ color:#666666 !important;} +.f_14{ font-size:14px ;} +.c_dblue{ color:#3e6d8e;} +.w90{width:90px;} +.ml10{margin-left:10px;} +.ml5{margin-left:5px;} +.b_grey{ background:#a3a3a3;} + + + +.container{ } + +/****搜索***/ +.resource{ width:693px;} +.re_top{width:688px; height:50px; margin-left:5px; background:#eaeaea;} +.re_top input{ float:left;} +.re_search{ margin:12px;} +.re_schbox{ width:240px; height:24px; border:1px solid #64bdd9 !important; color:#666666;} +.re_schbtn +{ + width:60px !important; + height:26px !important; + color:#fff !important; + margin-right:5px !important; + border:none !important; + margin-left:0px !important; + box-shadow: none !important; + padding: 0px !important; + border-radius: 0 !important; + text-shadow: none !important; +} +a.re_fabu { display:block; width:90px; height:35px; font-size:14px; color:#fff; text-align:center; padding-top:5px; margin:5px; } +a:hover.re_fabu{background:#55a1b9;} +/****列表***/ +.re_con{ margin:5px; width:683px;} +.re_con_top{color:#494949; } +.re_con_top span{ color:#999999; font-weight:bold;} +a.re_select{ display:block; width:88px; height:22px; background:url(images/pic_select01.png) 0 0 no-repeat; color:#fff; font-weight:bold; margin-left:10px;} +a:hover.re_select{background:url(images/pic_select02.png) 0 0 no-repeat;} +.re_open{display:block; width:46px; height:22px; background:url(images/pic_open01.png) 0 0 no-repeat; color:#fff; font-weight:bold; margin-left:10px;} +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;} +/****翻页***/ +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 +{ + height:21px !important; + border:0 !important; + cursor:pointer !important; + background:url(images/btn.png) no-repeat 0 0 !important; + width:42px !important; + margin-top:2px !important; + margin-left:3px !important; + border:none !important; + margin-left:0px !important; + box-shadow: none !important; + padding: 0px !important; + border-radius: 0 !important; + text-shadow: none !important; +} +.isTxt{background:#fbfbfb url(images/inputBg.png) repeat-x left top !important;height:22px !important;line-height:22px !important;border:1px solid #c1c1c1 !important;padding:0 5px !important;color:#666666 !important;} +.re_tag{ width: auto; padding:0 5px; height:22px; border:1px solid #f8df8c; background:#fffce6; margin-right:10px;} +.re_tag a{ color:#0d90c3;} +.tag_h span,.tag_h a{ margin-bottom:5px;} + +/***弹框***/ +.alert .close02{width:26px;height:26px;overflow:hidden;position:absolute;top:-10px;right:-490px;background:url(images/close.png) no-repeat;cursor:pointer;} +.upload_con { } +.upload_con h2{ display:block; background:#eaeaea; font-size:14px; color:#343333; height:31px; width: auto; margin-top:25px; padding-left:20px; padding-top:5px;} +.upload_box{ width:430px; margin:15px auto;} +a.upload_btn{ display:block; float:left; margin-top:15px; width:80px; height:30px; text-align: center; color:#fff; font-size:14px; background:#15bccf; margin-right:15px;} +a:hover.upload_btn{ background:#55a1b9;} +a.upload_btn_grey{background:#a3a3a3;} +a:hover.upload_btn_grey{background:#8a8a8a;} +.upload_con p{ color:#808181;} +.upload_con a:hover{ text-decoration:none;} +#upload_file_count #count { + color: #F00; + font-size: 1.1em; +} +