课程资源界面修改

This commit is contained in:
z9hang 2014-11-18 18:02:01 +08:00
parent 4b5ad833b0
commit a7a6fbcd22
23 changed files with 268 additions and 5 deletions

View File

@ -29,15 +29,16 @@ class FilesController < ApplicationController
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 index

View File

@ -20,6 +20,7 @@ class TagsController < ApplicationController
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
@ -188,6 +189,49 @@ class TagsController < ApplicationController
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
# 这里用来刷新搜索结果的区域
# 函数的返回值 前2字段用来处理获取其他tag和分页 另外4个返回值为过滤结果
@ -308,4 +352,6 @@ class TagsController < ApplicationController
end
end
end

View File

@ -1,6 +1,71 @@
<% attachmenttypes = @course.attachmenttypes %>
<% sufixtypes = @course.contenttypes %>
<% delete_allowed = User.current.allowed_to?(:manage_files, @course) %>
<%= stylesheet_link_tag 'resource', :media => 'all' %>
<div class="container">
<div class="resource"><!--资源库内容开始--->
<div class="re_top">
<form class="re_search f_l ">
<input type="text" name="" class="re_schbox" style="padding: 0px" />
<input type="submit" value="课内搜索" class="re_schbtn b_dblue" />
<input type="submit" value="全站搜索" class="re_schbtn b_lblue" />
</form>
<a href="#" class="re_fabu f_r b_lblue">发布资源</a>
</div><!---re_top end-->
<div class="cl"></div>
<div class="re_con">
<div class="re_con_top">
<p class="f_l c_blue f_b f_14">共有&nbsp;<%= User.current.member_of_course?(@course) ? @all_attachments.count : 0 %>&nbsp;个资源</p>
<p class="f_r">按&nbsp;<a href="#" class="f_b c_grey">时间</a>&nbsp;/&nbsp;<a href="#" class="f_b c_grey">下载次数</a>&nbsp;/&nbsp;<a href="#" class="f_b c_grey">引用次数</a>&nbsp;排序</p>
</div>
<div class="cl"></div>
<% @curse_attachments.each do |file| %>
<%if file.is_public == 0 && !User.current.member_of_course?(@course)%>
<%next%>
<%end%>
<div class="re_con_box">
<div class=" ">
<%= link_to_attachment file, :download => true, :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" %>
<a href="#" class="f_l re_select">选入我的课程</a><a href="javascript:void(0)" class="f_l re_open">公开</a>
</div>
<div class="cl"></div>
<div class="">
<p class="f_l c_grey02">文件大小:<%= number_to_human_size(file.filesize) %></p>
<%= 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 %>
<p class="f_r c_grey02" ><%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>&nbsp;&nbsp;|&nbsp;&nbsp;下载<%= file.downloads %>&nbsp;&nbsp;|&nbsp;&nbsp;引用0 </p>
</div>
<div class="cl"></div>
<div class="tag_h">
<%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "6"} %>
<%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6"} %>
</div>
<div class="cl"></div>
</div><!---re_con_box end-->
<% end %>
<ul class="wlist"><%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%></ul>
<div class="cl"></div>
</div><!---re_con end-->
</div>
</div>
<!-- old code -->
<span class="borad-title"><%= t(:label_user_course) %>资源共享区</span>

View File

@ -24,7 +24,7 @@
</head>
<!--add by huang-->
<body class="<%= h body_css_classes %>">
<%= render :partial => 'courses/course_ad' %>
<!-- <#%= render :partial => 'courses/course_ad' %> -->
<div id="wrapper">
<div id="wrapper2">
<div id="wrapper3">

View File

@ -0,0 +1,13 @@
<%= link_to '+ 添加标签', 'javascript:void(0);',
:class => "yellowBtn f_l",
:onclick=>"$('#add_tag_#{obj.id}').slideToggle();" if User.current.logged? %> <!-- $('#put-tag-form-#{obj.class}-#{obj.id}').toggle(); readmore(this); -->
<span id="add_tag_<%= obj.id %>" style="display:none; vertical-align: middle;" class="ml10 f_l">
<%= form_for "tag_for_save",:remote=>true,:url => save_tag_path,
:update => "tags_show",
:complete => '$("#put-tag-form").hide();' do |f| %>
<%= f.text_field :name ,:id => "tags_name_#{obj.id}",:size=>"28",:require=>true,:maxlength => Setting.tags_max_length,:minlength=>Setting.tags_min_length,:class => "isTxt w90 f_l" %>
<%= f.text_field :object_id,:value=> obj.id,:style=>"display:none"%>
<%= f.text_field :object_flag,:value=> object_flag,:style=>"display:none"%>
<%= f.submit "",:class => "submit f_l" %>
<% end %>
</span>

View File

@ -0,0 +1,20 @@
<% @tags = obj.reload.tag_list %>
<% if @tags.size > 0 %>
<% @tags.each do |tag| %>
<span class="re_tag f_l"> <%= 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?%>
<span class='del'> <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag,
:taggable_id => obj.id, :taggable_type => object_flag %> </span>
<% end %>
<% end %>
</span>
<% end %>
<% else %>
<span style="color:#8c8a8a" class="f_l">
&nbsp;&nbsp;&nbsp;<%= l(:label_tags_no) %>
</span>
<% end %>

View File

@ -0,0 +1,24 @@
<%#begin
1 代表是user类型
2 代表是project类型
3 代表是issue类型
4 代表是bid类型
5 代表是forum类型
6 代表是Attachment类型
7 代表是contest类型
8 代表是OpenSourceProject类型
9 代表是RelativeMemo类型
#end%>
<!-- 3 代表的是issue 当是issue是 处理方式与前2个对象不同 -->
<% if object_flag == '3' %>
<% elsif object_flag == '6' %>
<div id="tags_show-<%=obj.class%>-<%=obj.id%>" style="display:inline; ">
<%= render :partial => "tags/tag_list",:locals => {:obj => obj,:object_flag => object_flag} %>
</div>
<div id="put-tag-form-<%=obj.class%>-<%=obj.id%>" style="display: none;height: 100px;">
<%= render :partial => "courses/course_resources_html", :locals => {:obj => obj ,:object_flag => object_flag } %>
</div>
<% else %>
<% end %>

View File

@ -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 %>

View File

@ -792,6 +792,7 @@ RedmineApp::Application.routes.draw do
match 'parise_tread/tread_plus', :as=>"tread"
match 'tags/delete'
match 'tags/remove_tag', :as=>"remove_tag"
match 'tags/tag_save', :as => "save_tag"
match 'words/add_brief_introdution'

BIN
public/images/files/btn.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 958 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 958 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

View File

@ -0,0 +1,84 @@
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;}
.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;}
/****翻页***/
.wlist{ margin-top:15px;}
.wlist a{ float:right; border:1px solid #15bccf; padding:0 5px; margin-left:3px; color:#15bccf;}
.wlist a:hover{border:1px solid #15bccf; background-color:#15bccf; color:#fff;}
.wlist_select a { background-color:#64bdd9; color:#fff;}
/****标签***/
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;}