项目资源库 添加私有资源提示及局部过滤刷新

rep_quality
huang 9 years ago
parent e798381feb
commit fa25a78f62

@ -1,3 +1,4 @@
#encoding: utf-8
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2013 Jean-Philippe Lang # Copyright (C) 2006-2013 Jean-Philippe Lang
# #
@ -203,16 +204,49 @@ class AttachmentsController < ApplicationController
@attachment.save @attachment.save
@newfiledense = filedense @newfiledense = filedense
end end
if @project tip_attachment_update
elsif @course
end
respond_to do |format| respond_to do |format|
format.js format.js
end end
end end
def tip_attachment_update
if params[:course_id]
@tip_all_attachments = Attachment.where(:container_type => "Course", :container_id => params[:project_id])
@tip_all_public_attachments = Attachment.where(:container_type => "Course", :container_id => params[:project_id], :is_public => 1)
@tip_all_private_attachments = Attachment.where(:container_type => "Course", :container_id => params[:project_id], :is_public => 0)
@course = Course.find(params[:course_id])
elsif params[:project_id]
@tip_all_attachments = Attachment.where(:container_type => "Project", :container_id => params[:project_id])
@tip_all_public_attachments = Attachment.where(:container_type => "Project", :container_id => params[:project_id], :is_public => 1)
@tip_all_private_attachments = Attachment.where(:container_type => "Project", :container_id => params[:project_id], :is_public => 0)
@project = Project.find(params[:project_id])
end
@tag_name = params[:tag_name]
@other = params[:other]
unless @tag_name.blank?
if @other
if @project
@tip_all_attachments = @tip_all_attachments.select{|attachment| !attachment.tag_list.include?('软件版本') && !attachment.tag_list.include?('文档') && !attachment.tag_list.include?('代码') && !attachment.tag_list.include?('媒体') && !attachment.tag_list.include?('论文') }
@tip_all_public_attachments = @tip_all_public_attachments.select{|attachment| !attachment.tag_list.include?('软件版本') && !attachment.tag_list.include?('文档') && !attachment.tag_list.include?('代码') && !attachment.tag_list.include?('媒体') && !attachment.tag_list.include?('论文') }
@tip_all_private_attachments = @tip_all_private_attachments.select{|attachment| !attachment.tag_list.include?('软件版本') && !attachment.tag_list.include?('文档') && !attachment.tag_list.include?('代码') && !attachment.tag_list.include?('媒体') && !attachment.tag_list.include?('论文') }
elsif @course
@tip_all_attachments = @tip_all_attachments.select{|attachment| !attachment.tag_list.include?('课件') && !attachment.tag_list.include?('软件') && !attachment.tag_list.include?('媒体') && !attachment.tag_list.include?('代码') && !attachment.tag_list.include?('论文') }
@tip_all_public_attachments = @tip_all_public_attachments.select{|attachment| !attachment.tag_list.include?('课件') && !attachment.tag_list.include?('软件') && !attachment.tag_list.include?('媒体') && !attachment.tag_list.include?('代码') && !attachment.tag_list.include?('论文') }
@tip_all_private_attachments = @tip_all_private_attachments.select{|attachment| !attachment.tag_list.include?('课件') && !attachment.tag_list.include?('软件') && !attachment.tag_list.include?('媒体') && !attachment.tag_list.include?('代码') && !attachment.tag_list.include?('论文') }
end
else
@tip_all_attachments = @tip_all_attachments.select{|attachment| attachment.tag_list.include?(@tag_name)}
@tip_all_public_attachments = @tip_all_public_attachments.select{|attachment| attachment.tag_list.include?(@tag_name)}
@tip_all_private_attachments = @tip_all_private_attachments.select{|attachment| attachment.tag_list.include?(@tag_name)}
end
end
@tip_all_attachments = @tip_all_attachments.count
@tip_all_public_attachments = @tip_all_public_attachments.count
@tip_all_private_attachments = @tip_all_private_attachments.count
end
def thumbnail def thumbnail
if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size]) if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size])
if stale?(:etag => thumbnail) if stale?(:etag => thumbnail)
@ -281,6 +315,7 @@ class AttachmentsController < ApplicationController
@attachment.delete @attachment.delete
@flag = true @flag = true
end end
# tip_attachment_update
respond_to do |format| respond_to do |format|
format.js format.js
@ -591,6 +626,7 @@ class AttachmentsController < ApplicationController
def attachment_versions def attachment_versions
@attachment = Attachment.find(params[:id]) @attachment = Attachment.find(params[:id])
@attachment_histories = @attachment.attachment_histories @attachment_histories = @attachment.attachment_histories
@container_tip = Project.find(params[:project_id])
respond_to do |format| respond_to do |format|
format.js format.js
end end

@ -325,7 +325,7 @@ class FilesController < ApplicationController
@containers = [ Project.includes(:attachments).reorder(sort).find(@project.id)] @containers = [ Project.includes(:attachments).reorder(sort).find(@project.id)]
show_attachments @containers show_attachments @containers
# get_attachment_for_tip(@all_attachments) get_attachment_for_tip(@all_attachments)
@tag_list = attachment_tag_list @all_attachments @tag_list = attachment_tag_list @all_attachments
@ -378,7 +378,7 @@ class FilesController < ApplicationController
@containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)] @containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)]
show_attachments @containers show_attachments @containers
# get_attachment_for_tip(@all_attachments) get_attachment_for_tip(@all_attachments)
@tag_list = attachment_tag_list @all_attachments @tag_list = attachment_tag_list @all_attachments

@ -1,9 +1,11 @@
<% if @attachment.container_type == 'Course' %> <% if @attachment.container_type == 'Course' %>
$("#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)), $("#is_public_<%= @attachment.id %>").html("<%= escape_javascript(link_to (@attachment.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>@attachment.id, :course_id => @attachment.container_id, :tag_name => @tag_name, :other => @other,:newtype=>(@attachment.is_public? ? 0:1)),
:remote=>true,:class=>"postOptionLink",:method => :post) %>"); :remote=>true,:class=>"postOptionLink",:method => :post) %>");
$("#tip_attachment_count").html("<%= escape_javascript( render :partial => 'files/tip_attachment_count') %>");
<% elsif @attachment.container_type == 'Project' %> <% elsif @attachment.container_type == 'Project' %>
$("#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)), $("#is_public_<%= @attachment.id %>").html("<%= escape_javascript(link_to (@attachment.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid => @attachment.id, :project_id => @attachment.container_id, :tag_name => @tag_name, :other => @other ,:newtype => (@attachment.is_public? ? 0:1)),
:remote => true, :class => "postOptionLink", :method => :post) %>"); :remote => true, :class => "postOptionLink", :method => :post) %>");
$("#tip_attachment_count").html("<%= escape_javascript( render :partial => 'files/tip_attachment_count') %>");
<% else %> <% else %>
$("#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)), $("#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)),

@ -115,22 +115,21 @@
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<div class="re_con_top"> <div class="re_con_top">
<!--<p class="f_l fontBlue f_b f_14" id="tip_attachment_count">--> <p class="f_l fontBlue f_b f_14" id="tip_attachment_count">
<!--<%#= render :partial => "files/tip_attachment_count" %>--> <%= render :partial => "files/tip_attachment_count" %>
<!--</p>--> </p>
<p class="f_l fontBlue f_b f_14">共有&nbsp;<span id="attachment_count"><%= @all_attachments.count%></span>&nbsp;个资源</p>
<p class="f_r" style="color: #808080" id="course_filter_order"> <p class="f_r" style="color: #808080" id="course_filter_order">
<%= render :partial => 'course_file_filter_order', :locals => {:remote => @is_remote, :sort => @sort, :order => @order} %> <%= render :partial => 'course_file_filter_order', :locals => {:remote => @is_remote, :sort => @sort, :order => @order} %>
</p> </p>
</div> </div>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<!--<div class="resource_tip_box fontGrey2">--> <div class="resource_tip_box fontGrey2">
<!--<em></em>--> <em></em>
<!--<span></span>--> <span></span>
<!--<p class="mb5">私有资源:<br/>仅对本班级成员可见</p>--> <p class="mb5">私有资源:<br/>仅对本班级成员可见</p>
<!--<p>公共资源:<br/>对所有用户可见</p>--> <p>公共资源:<br/>对所有用户可见</p>
<!--</div>--> </div>
</div> </div>
<div id="course_list"> <div id="course_list">
<%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} %> <%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} %>

@ -85,10 +85,9 @@
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<div class="re_con_top"> <div class="re_con_top">
<!--<p class="f_l fontBlue f_b f_14" id="tip_attachment_count">--> <p class="f_l fontBlue f_b f_14" id="tip_attachment_count">
<!--<%#= render :partial => "files/tip_attachment_count" %>--> <%= render :partial => "files/tip_attachment_count" %>
<!--</p>--> </p>
<p class="f_l fontBlue f_b f_14">共有&nbsp;<span id="attachment_count"><%= @all_attachments.count%></span>&nbsp;个资源</p>
<p class="f_r" style="color: #808080"> <p class="f_r" style="color: #808080">
<% if @order == "asc" %> <% if @order == "asc" %>
按&nbsp;<%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %>&nbsp;/&nbsp; 按&nbsp;<%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %>&nbsp;/&nbsp;
@ -103,14 +102,14 @@
</div> </div>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<%# if !User.current.member_of?(@project) && show_attachment_tip(@project.id, "Project") %> <% if !User.current.member_of?(@project) && show_attachment_tip(@project.id, "Project") %>
<!--<div class="resource_tip_box fontGrey2">--> <div class="resource_tip_box fontGrey2">
<!--<em></em>--> <em></em>
<!--<span></span>--> <span></span>
<!--<p class="mb5">私有资源:<br/>仅对本项目成员可见</p>--> <p class="mb5">私有资源:<br/>仅对本项目成员可见</p>
<!--<p>公共资源:<br/>对所有用户可见</p>--> <p>公共资源:<br/>对所有用户可见</p>
<!--</div>--> </div>
<%# end %> <% end %>
</div> </div>
<div id="course_list"> <div id="course_list">
<%= render :partial => 'project_list',:locals => {project: @project, all_attachments: @all_attachments, sort:@sort, order:@order, project_attachments:@obj_attachments} %> <%= render :partial => 'project_list',:locals => {project: @project, all_attachments: @all_attachments, sort:@sort, order:@order, project_attachments:@obj_attachments} %>

@ -70,7 +70,11 @@
<% if @course.is_public? %> <% if @course.is_public? %>
<li> <li>
<span id="is_public_<%= file.id %>"> <span id="is_public_<%= file.id %>">
<%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"postOptionLink",:method => :post %> <% if params[:tag_name].blank? %>
<%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid => file.id, :newtype=>(file.is_public? ? 0:1), :course_id => course.id), :remote=>true,:class=>"postOptionLink",:method => :post %>
<% else %>
<%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid => file.id, :newtype=>(file.is_public? ? 0:1), :tag_name => params[:tag_name].force_encoding("UTF-8"), :course_id => course.id, :other => params[:other]), :remote=>true,:class=>"postOptionLink",:method => :post %>
<% end %>
</span> </span>
</li> </li>
<%end%> <%end%>

@ -9,11 +9,20 @@
<% else %> <% else %>
<li><%= link_to("发&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send_hidden('#{file.id}','#{User.current.id}','file')") %></li> <li><%= link_to("发&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send_hidden('#{file.id}','#{User.current.id}','file')") %></li>
<% end %> <% end %>
<li><%= link_to '更新版本',attachments_versions_path(file),:class => "postOptionLink",:remote=>true %></li> <% if params[:tag_name].blank? %>
<li><%= link_to '更新版本',attachments_versions_path(file, :project_id => project.id), :class => "postOptionLink", :remote => true %></li>
<% else %>
<li><%= link_to '更新版本',attachments_versions_path(file, :tag_name => params[:tag_name].force_encoding("UTF-8"), :project_id => project.id, :other => params[:other]),:class => "postOptionLink",:remote=>true %></li>
<% end %>
<% if project.is_public? %> <% if project.is_public? %>
<li> <li>
<span id="is_public_<%= file.id %>"> <span id="is_public_<%= file.id %>">
<%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid => file.id, :newtype=>(file.is_public? ? 0:1)), :remote=>true,:class=>"postOptionLink",:method => :post %> <% if params[:tag_name].blank? %>
<%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid => file.id, :newtype=>(file.is_public? ? 0:1), :project_id => project.id), :remote=>true,:class=>"postOptionLink",:method => :post %>
<% else %>
<%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid => file.id, :newtype=>(file.is_public? ? 0:1), :tag_name => params[:tag_name].force_encoding("UTF-8"), :project_id => project.id, :other => params[:other]), :remote=>true,:class=>"postOptionLink",:method => :post %>
<% end %>
</span> </span>
</li> </li>
<% end %> <% end %>

@ -3,6 +3,6 @@
$("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>'); $("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>');
<% else %> <% else %>
$("#resource_list").html("<%= escape_javascript( render :partial => 'files/project_file',:locals => {project:@project, all_attachments:@all_attachments, sort:@sort, order:@order, project_attachments:@obj_attachments}) %>"); $("#resource_list").html("<%= escape_javascript( render :partial => 'files/project_file',:locals => {project:@project, all_attachments:@all_attachments, sort:@sort, order:@order, project_attachments:@obj_attachments}) %>");
// $("#tip_attachment_count").html("<%#= escape_javascript( render :partial => 'files/tip_attachment_count') %>"); $("#tip_attachment_count").html("<%= escape_javascript( render :partial => 'files/tip_attachment_count') %>");
$("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>'); $("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>');
<% end %> <% end %>

@ -1,6 +1,6 @@
<%# course_model %> <%# course_model %>
<% course_file_num = visable_attachemnts_incourse(@course).count%> <%# course_file_num = visable_attachemnts_incourse(@course).count%>
<%# course_file_num = Attachment.where(:container_type => "Course", :container_id => @course.id).count %> <% course_file_num = Attachment.where(:container_type => "Course", :container_id => @course.id).count %>
<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %> <% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %>
<% homework_num = visable_course_homework @course %> <% homework_num = visable_course_homework @course %>

Loading…
Cancel
Save