项目资源库 添加私有资源提示及局部过滤刷新
This commit is contained in:
parent
e798381feb
commit
fa25a78f62
|
@ -1,3 +1,4 @@
|
|||
#encoding: utf-8
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
|
@ -203,16 +204,49 @@ class AttachmentsController < ApplicationController
|
|||
@attachment.save
|
||||
@newfiledense = filedense
|
||||
end
|
||||
if @project
|
||||
tip_attachment_update
|
||||
|
||||
elsif @course
|
||||
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
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
|
||||
if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size])
|
||||
if stale?(:etag => thumbnail)
|
||||
|
@ -281,6 +315,7 @@ class AttachmentsController < ApplicationController
|
|||
@attachment.delete
|
||||
@flag = true
|
||||
end
|
||||
# tip_attachment_update
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
|
@ -591,6 +626,7 @@ class AttachmentsController < ApplicationController
|
|||
def attachment_versions
|
||||
@attachment = Attachment.find(params[:id])
|
||||
@attachment_histories = @attachment.attachment_histories
|
||||
@container_tip = Project.find(params[:project_id])
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
|
|
|
@ -325,7 +325,7 @@ class FilesController < ApplicationController
|
|||
@containers = [ Project.includes(:attachments).reorder(sort).find(@project.id)]
|
||||
|
||||
show_attachments @containers
|
||||
# get_attachment_for_tip(@all_attachments)
|
||||
get_attachment_for_tip(@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)]
|
||||
|
||||
show_attachments @containers
|
||||
# get_attachment_for_tip(@all_attachments)
|
||||
get_attachment_for_tip(@all_attachments)
|
||||
|
||||
@tag_list = attachment_tag_list @all_attachments
|
||||
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
<% 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) %>");
|
||||
$("#tip_attachment_count").html("<%= escape_javascript( render :partial => 'files/tip_attachment_count') %>");
|
||||
<% 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) %>");
|
||||
$("#tip_attachment_count").html("<%= escape_javascript( render :partial => 'files/tip_attachment_count') %>");
|
||||
|
||||
<% 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)),
|
||||
:remote=>true,:class=>"postOptionLink",:method => :post) %>");
|
||||
<% end %>
|
||||
<% if @attachment.is_public? %>
|
||||
$("#image_private_<%= @attachment.id%>").html('')
|
||||
<%else%>
|
||||
$("#image_private_<%= @attachment.id%>").html('<span class="img_private ml5">私有</span>')
|
||||
$("#image_private_<%= @attachment.id%>").html('<span class="img_private ml5">私有</span>')
|
||||
<% end %>
|
|
@ -115,22 +115,21 @@
|
|||
</div>
|
||||
<div class="cl"></div>
|
||||
<div class="re_con_top">
|
||||
<!--<p class="f_l fontBlue f_b f_14" id="tip_attachment_count">-->
|
||||
<!--<%#= render :partial => "files/tip_attachment_count" %>-->
|
||||
<!--</p>-->
|
||||
<p class="f_l fontBlue f_b f_14">共有 <span id="attachment_count"><%= @all_attachments.count%></span> 个资源</p>
|
||||
<p class="f_l fontBlue f_b f_14" id="tip_attachment_count">
|
||||
<%= render :partial => "files/tip_attachment_count" %>
|
||||
</p>
|
||||
<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} %>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<!--<div class="resource_tip_box fontGrey2">-->
|
||||
<!--<em></em>-->
|
||||
<!--<span></span>-->
|
||||
<!--<p class="mb5">私有资源:<br/>仅对本班级成员可见</p>-->
|
||||
<!--<p>公共资源:<br/>对所有用户可见</p>-->
|
||||
<!--</div>-->
|
||||
<div class="resource_tip_box fontGrey2">
|
||||
<em></em>
|
||||
<span></span>
|
||||
<p class="mb5">私有资源:<br/>仅对本班级成员可见</p>
|
||||
<p>公共资源:<br/>对所有用户可见</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="course_list">
|
||||
<%= 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 class="cl"></div>
|
||||
<div class="re_con_top">
|
||||
<!--<p class="f_l fontBlue f_b f_14" id="tip_attachment_count">-->
|
||||
<!--<%#= render :partial => "files/tip_attachment_count" %>-->
|
||||
<!--</p>-->
|
||||
<p class="f_l fontBlue f_b f_14">共有 <span id="attachment_count"><%= @all_attachments.count%></span> 个资源</p>
|
||||
<p class="f_l fontBlue f_b f_14" id="tip_attachment_count">
|
||||
<%= render :partial => "files/tip_attachment_count" %>
|
||||
</p>
|
||||
<p class="f_r" style="color: #808080">
|
||||
<% if @order == "asc" %>
|
||||
按 <%= 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"} %> /
|
||||
|
@ -103,14 +102,14 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<%# if !User.current.member_of?(@project) && show_attachment_tip(@project.id, "Project") %>
|
||||
<!--<div class="resource_tip_box fontGrey2">-->
|
||||
<!--<em></em>-->
|
||||
<!--<span></span>-->
|
||||
<!--<p class="mb5">私有资源:<br/>仅对本项目成员可见</p>-->
|
||||
<!--<p>公共资源:<br/>对所有用户可见</p>-->
|
||||
<!--</div>-->
|
||||
<%# end %>
|
||||
<% if !User.current.member_of?(@project) && show_attachment_tip(@project.id, "Project") %>
|
||||
<div class="resource_tip_box fontGrey2">
|
||||
<em></em>
|
||||
<span></span>
|
||||
<p class="mb5">私有资源:<br/>仅对本项目成员可见</p>
|
||||
<p>公共资源:<br/>对所有用户可见</p>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div id="course_list">
|
||||
<%= 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? %>
|
||||
<li>
|
||||
<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>
|
||||
</li>
|
||||
<%end%>
|
||||
|
|
|
@ -9,11 +9,20 @@
|
|||
<% else %>
|
||||
<li><%= link_to("发 送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send_hidden('#{file.id}','#{User.current.id}','file')") %></li>
|
||||
<% 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? %>
|
||||
<li>
|
||||
<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>
|
||||
</li>
|
||||
<% end %>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<% if @course %>
|
||||
$("#resource_list").html("<%= escape_javascript( render :partial => 'files/course_file',:locals => {course:@course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} )%>");
|
||||
$("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>');
|
||||
$("#resource_list").html("<%= escape_javascript( render :partial => 'files/course_file',:locals => {course:@course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} )%>");
|
||||
$("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>');
|
||||
<% 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}) %>");
|
||||
// $("#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 %>');
|
||||
$("#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') %>");
|
||||
$("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>');
|
||||
<% end %>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<%# course_model %>
|
||||
<% course_file_num = visable_attachemnts_incourse(@course).count%>
|
||||
<%# course_file_num = Attachment.where(:container_type => "Course", :container_id => @course.id).count %>
|
||||
<%# course_file_num = visable_attachemnts_incourse(@course).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)) %>
|
||||
<% homework_num = visable_course_homework @course %>
|
||||
|
||||
|
|
Loading…
Reference in New Issue