From a7a6fbcd2286ad6652f9d416b06a8346d732f1a0 Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 18 Nov 2014 18:02:01 +0800 Subject: [PATCH 01/18] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 9 ++- app/controllers/tags_controller.rb | 46 +++++++++++ app/views/files/_course_file.html.erb | 65 ++++++++++++++++ app/views/layouts/base_courses.html.erb | 2 +- app/views/tags/_tag_add.html.erb | 13 ++++ app/views/tags/_tag_list.html.erb | 20 +++++ app/views/tags/_tag_new.html.erb | 24 ++++++ app/views/tags/tag_save.js.erb | 9 +++ config/routes.rb | 1 + public/images/files/btn.png | Bin 0 -> 1308 bytes public/images/files/close.png | Bin 0 -> 1637 bytes public/images/files/inputBg.png | Bin 0 -> 958 bytes public/images/files/pic_open01.png | Bin 0 -> 215 bytes public/images/files/pic_open02.png | Bin 0 -> 215 bytes public/images/files/pic_select01.png | Bin 0 -> 225 bytes public/images/files/pic_select02.png | Bin 0 -> 225 bytes public/stylesheets/images/btn.png | Bin 0 -> 1308 bytes public/stylesheets/images/inputBg.png | Bin 0 -> 958 bytes public/stylesheets/images/pic_open01.png | Bin 0 -> 215 bytes public/stylesheets/images/pic_open02.png | Bin 0 -> 215 bytes public/stylesheets/images/pic_select01.png | Bin 0 -> 225 bytes public/stylesheets/images/pic_select02.png | Bin 0 -> 225 bytes public/stylesheets/resource.css | 84 +++++++++++++++++++++ 23 files changed, 268 insertions(+), 5 deletions(-) create mode 100644 app/views/tags/_tag_add.html.erb create mode 100644 app/views/tags/_tag_list.html.erb create mode 100644 app/views/tags/_tag_new.html.erb create mode 100644 app/views/tags/tag_save.js.erb create mode 100644 public/images/files/btn.png create mode 100644 public/images/files/close.png create mode 100644 public/images/files/inputBg.png create mode 100644 public/images/files/pic_open01.png create mode 100644 public/images/files/pic_open02.png create mode 100644 public/images/files/pic_select01.png create mode 100644 public/images/files/pic_select02.png create mode 100644 public/stylesheets/images/btn.png create mode 100644 public/stylesheets/images/inputBg.png create mode 100644 public/stylesheets/images/pic_open01.png create mode 100644 public/stylesheets/images/pic_open02.png create mode 100644 public/stylesheets/images/pic_select01.png create mode 100644 public/stylesheets/images/pic_select02.png create mode 100644 public/stylesheets/resource.css diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 91176efdf..75bf6fefd 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -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 diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index b64c18b33..27f7fe61d 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -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 @@ -187,6 +188,49 @@ class TagsController < ApplicationController # 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 +351,7 @@ class TagsController < ApplicationController return end end + + end diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb index 46a954746..8edd054be 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -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' %> +
+
+
+ + 发布资源 +
+
+ +
+
+

共有 <%= User.current.member_of_course?(@course) ? @all_attachments.count : 0 %> 个资源

+

按 时间 / 下载次数 / 引用次数 排序

+
+
+<% @curse_attachments.each do |file| %> + <%if file.is_public == 0 && !User.current.member_of_course?(@course)%> + <%next%> + <%end%> +
+
+ <%= 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" %> + 选入我的课程公开 +
+
+
+

文件大小:<%= 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 %> +

<%= 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"} %> +
+
+
+<% end %> +
    <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
+
+
+ +
+ +
+ + + + + + + + + + + + + + <%= t(:label_user_course) %>资源共享区 diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 6cdc19471..bc665ea41 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -24,7 +24,7 @@ -<%= render :partial => 'courses/course_ad' %> +
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..092e0d898 --- /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", :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' %> +
+ <%= render :partial => "tags/tag_list",:locals => {:obj => obj,:object_flag => object_flag} %> +
+ + <% else %> + + <% end %> 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..35b7b6ca2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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' diff --git a/public/images/files/btn.png b/public/images/files/btn.png new file mode 100644 index 0000000000000000000000000000000000000000..85cea7f5c179b272cbe136f07f804ab663f8b161 GIT binary patch literal 1308 zcmV+%1>^dOP)(_`g8%^e{{R4h=>PzAFaQARU;qF*m;eA5Z<1fd zMgRZ=qDe$SRCwCVn9Xk!M;OL`Gv0iV0||8$5CI7)acRn@3Q^e;s^}&ELMv63s#L<> z9D3-fBJ{+i2XAs{sZ`7GQ#{@3QS<9h$;eUJbAan=E(kaBu&-wyuX&@6>PCV+0sN%jux zpc-yW1D`v9gVtmBYno62A{)A|E4W|Np!FEwNI(Jvs`p^Op3MIzzQ!y}(g6elbO)f< z-PR<>%4>-L?EbhNE3a|g&3E*Po5s+HZ~%l9Xl>qXwWH18H{5(;+dSLDZ@BqXA8p6q z0#r1x0XP=+o-7VBDcR8!?6v!#7_SCscepp*JV&g=H)9D*LgRBJrNn9doHQWg;0`x~ zA1<$P%gsm6w=DT@x#<_r;S^va>2(LBi_N5m%4;kpfU!ZDcZU*^FS_}}{?4j5A~x3) zXxY9TyxIt^B`vk-KX`Sm#m6p-Za!)!z3*1czV0+}qE&bCjgP5+dpqA!(P7!Cc?-_mCo=5lYv>`sVj5_kKPP1Y-MlUr3-2 z*ai#%{V&$qD>DUb0_(s(KwVTS72f&%C%JIo3yFPIDW}6v)O}im>bgM09wDN@2kMALY!MGhKZ`6&;n0J5x6%3xz^r z|NQ)XS7r)@LgZ(++xfI(Hq|y{g3Qm)x3mj|LQ82k*1WUZX+Xx0{gDz?{-zy|F*i3yp-_m%*)eR3$FqNMw=kMk z`eL!z^Yn-V>ovwpNpCayveu5#RM%y#HCidU{TQ{GFBXgVzK`$wQM;Wop6B8Fen(J= z(pyt9mGqwHwbVeAxSQD^+l{m1c9p&p)KV-GADYPC8$JUon)*|^*(rFi=EDfN2& zg892Z0M5d~!r8&W!HWm|{|*3=5ER6x SG$&F30000c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxKsVXI%s|1+P|wiV z#N6CmN5ROz&_Lh7NZ-&%*U;R`*vQJjKmiJrfVLH-q*(>IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8EkR}&8R-I5=oVMzl_XZ^<`pZ$OmImpPAEg{v+u2}(t{7puX=A(aKG z`a!A1`K3k4z=%sz23b{L$o& z6x?nx#;I2y=oo!av?4__ObD2EKuma|1#;lYJ~a=R){B6NI_pLIVFm`K+nz3tAr-gQ zOuL^QlqhlhyyfLPr%dmt)IW(4T9osmwcN90vVva(OPq*so8KOfkMf4^%N{>9(`EO1 zSPn6vJd`)|f?75E_KMy=V^jYrQ_2;$w&i~%C#6v}i z#fejg;d6t;4Awe^`v&=q{68e~Cos2MIG)c?+)^-y@%MpjJ4ZdmFYDh%WL){dX~W!i zlUrEC)v!LE?Hz;Gqx(rr7noxo7|*{TQXoD-@W1?udAbjl{BM|fE;pe~BL2=HH!Jlm z2iAFNh+Ohk5z3mOAGJ1Y=Kc5k&u#2ApXsDhc712T&X{Q_MlS_~B4c8vIv%1%9 z@#_++@(``7F=n$%H(dwvO(uG*nd-IFdH(tB)(V+ZI%XVtS?IPm?){CNZSGvHPRB%? zm2Tg@y}H%u;epp*FEQ=zmI`&{v|M{LXP%`@pRCF>ucdF)CTCVDX(2-lSe*I-< zs{*#UJp3CJ+1es>)QWfBv7PI;eTv`m`D{#$)0HFsingBDJa{3)WU`8GN;h(8G z#p~&sh8xvsy{q0_EwFgwq9oV<-15G7K=5L_;MG?@Wte0=tysz~G9&qs_J$VzL;Gh} zRaFUfx}0*FeLrt|wTW+d_1-x4Z97gzxhc87;atr;?YM>7J_i3^sfm31*y=3o*#uJ> zc;w#BS^P(MUQg7u02$NCJiG00I06v^1kLrQHXdPd6B=u;&Qx zy1iGj=yUvaqn=$)1L+-fWUdKhlK8rJJ;Fz?9lnwg|x0i%s@k9_h25P&b-;R=M!6Y*uC4J znkZDjL&O4!ckD+>qOuEJh0fD$o&^gCnW*epQa!T;G#nyO;)J{{lm$?R94r(iNxB6@ z0Sdez@=(k}NhyemAb{n=(rBSGRN8uD8H=t|c1%d1@O&J{TwLIAIO3r!%c+Ja<|!f{ z&3s}dc|Y3C6m%5Xp&Jkv`yf@c26#$TmS%c(1TR?0`q8pXv|xN<1w7=0^hg=dH2)9v zycIekZFHXRKZT?2EI@o4MR*$8v~k1TG*qByA+iV#yBHs5Rcwth!O<88K})Gp>&9sfT=$ zah-FnzLuLB!3$_)9fj^=4V%(B^E5dMBN( zOiLFl+asTPJ*1}Yeg1wzFGSJMYu)7Q;KAFY`#T%C{-tlfzg&LUzxL!M_vz>9>C@-; fK3sgQo0~g*=8t{Del5JIq&Lc_H}zNh{bzpx7X2%s literal 0 HcmV?d00001 diff --git a/public/images/files/pic_open01.png b/public/images/files/pic_open01.png new file mode 100644 index 0000000000000000000000000000000000000000..45552ae00bcd00a3bf353764b915e4c70a8b0511 GIT binary patch literal 215 zcmeAS@N?(olHy`uVBq!ia0vp^dO$43!3HGvPgwUINO2Z;L>4nJa0`PlBg3pY51MapOd5U}4UhMjHT;S(dy&t2 znTg-#!vSU(QU9>Wxj*cy+;m~72S6wO|If_8*TJi1ZM;|!Xc2>_tDnm{r-UW|7s)?b literal 0 HcmV?d00001 diff --git a/public/images/files/pic_open02.png b/public/images/files/pic_open02.png new file mode 100644 index 0000000000000000000000000000000000000000..b457f302f7b55e3c899afee2e2e091835cb635ec GIT binary patch literal 215 zcmeAS@N?(olHy`uVBq!ia0vp^dO$43!3HGvPgwUINO2Z;L>4nJa0`PlBg3pY5rkifktt>%r=h}o#S;-%_7-oFaYIxMbW^pc?c|~t(^S>|y z-46$t`E6jte{ntYFK=ES4z)+>iz|hdl!0_`wkbcR)P-?)y@G60U!DwdtNNjv*Dd-du7N zJfI+O;DC&ify326*&T-&Or7l4GQXSdal>=Xy&t!3YNlL=+`*s^wB!GOW(JidylT(Oq#psf N44$rjF6*2Ung9^~MY#X~ literal 0 HcmV?d00001 diff --git a/public/images/files/pic_select02.png b/public/images/files/pic_select02.png new file mode 100644 index 0000000000000000000000000000000000000000..e620fad1fde281e6a583d0430aa00ef6700eefd1 GIT binary patch literal 225 zcmeAS@N?(olHy`uVBq!ia0vp^5kM@)!3HE=ES4z)+>iz|hdl!0_`wkbcR)P-?)y@G60U!DwdtNNjv*Dd-du7N zJfI+O;DAir3Kp5bK#N5}2F~_tncq$KxZ!yw?&qx=8*fE01{^v2a_4$pfz9EC!rDR{ zIvY53HXKmfaDZtx7;)z?aqDcD%g85Ll$Ct6e!~gQ9Sr(FJO2M?W_YxLS8WRW=XF3X NgQu&X%Q~loCIFg}MBM-Y literal 0 HcmV?d00001 diff --git a/public/stylesheets/images/btn.png b/public/stylesheets/images/btn.png new file mode 100644 index 0000000000000000000000000000000000000000..85cea7f5c179b272cbe136f07f804ab663f8b161 GIT binary patch literal 1308 zcmV+%1>^dOP)(_`g8%^e{{R4h=>PzAFaQARU;qF*m;eA5Z<1fd zMgRZ=qDe$SRCwCVn9Xk!M;OL`Gv0iV0||8$5CI7)acRn@3Q^e;s^}&ELMv63s#L<> z9D3-fBJ{+i2XAs{sZ`7GQ#{@3QS<9h$;eUJbAan=E(kaBu&-wyuX&@6>PCV+0sN%jux zpc-yW1D`v9gVtmBYno62A{)A|E4W|Np!FEwNI(Jvs`p^Op3MIzzQ!y}(g6elbO)f< z-PR<>%4>-L?EbhNE3a|g&3E*Po5s+HZ~%l9Xl>qXwWH18H{5(;+dSLDZ@BqXA8p6q z0#r1x0XP=+o-7VBDcR8!?6v!#7_SCscepp*JV&g=H)9D*LgRBJrNn9doHQWg;0`x~ zA1<$P%gsm6w=DT@x#<_r;S^va>2(LBi_N5m%4;kpfU!ZDcZU*^FS_}}{?4j5A~x3) zXxY9TyxIt^B`vk-KX`Sm#m6p-Za!)!z3*1czV0+}qE&bCjgP5+dpqA!(P7!Cc?-_mCo=5lYv>`sVj5_kKPP1Y-MlUr3-2 z*ai#%{V&$qD>DUb0_(s(KwVTS72f&%C%JIo3yFPIDW}6v)O}im>bgM09wDN@2kMALY!MGhKZ`6&;n0J5x6%3xz^r z|NQ)XS7r)@LgZ(++xfI(Hq|y{g3Qm)x3mj|LQ82k*1WUZX+Xx0{gDz?{-zy|F*i3yp-_m%*)eR3$FqNMw=kMk z`eL!z^Yn-V>ovwpNpCayveu5#RM%y#HCidU{TQ{GFBXgVzK`$wQM;Wop6B8Fen(J= z(pyt9mGqwHwbVeAxSQD^+l{m1c9p&p)KV-GADYPC8$JUon)*|^*(rFi=EDfN2& zg892Z0M5d~!r8&W!HWm|{|*3=5ER6x SG$&F30000=yUvaqn=$)1L+-fWUdKhlK8rJJ;Fz?9lnwg|x0i%s@k9_h25P&b-;R=M!6Y*uC4J znkZDjL&O4!ckD+>qOuEJh0fD$o&^gCnW*epQa!T;G#nyO;)J{{lm$?R94r(iNxB6@ z0Sdez@=(k}NhyemAb{n=(rBSGRN8uD8H=t|c1%d1@O&J{TwLIAIO3r!%c+Ja<|!f{ z&3s}dc|Y3C6m%5Xp&Jkv`yf@c26#$TmS%c(1TR?0`q8pXv|xN<1w7=0^hg=dH2)9v zycIekZFHXRKZT?2EI@o4MR*$8v~k1TG*qByA+iV#yBHs5Rcwth!O<88K})Gp>&9sfT=$ zah-FnzLuLB!3$_)9fj^=4V%(B^E5dMBN( zOiLFl+asTPJ*1}Yeg1wzFGSJMYu)7Q;KAFY`#T%C{-tlfzg&LUzxL!M_vz>9>C@-; fK3sgQo0~g*=8t{Del5JIq&Lc_H}zNh{bzpx7X2%s literal 0 HcmV?d00001 diff --git a/public/stylesheets/images/pic_open01.png b/public/stylesheets/images/pic_open01.png new file mode 100644 index 0000000000000000000000000000000000000000..45552ae00bcd00a3bf353764b915e4c70a8b0511 GIT binary patch literal 215 zcmeAS@N?(olHy`uVBq!ia0vp^dO$43!3HGvPgwUINO2Z;L>4nJa0`PlBg3pY51MapOd5U}4UhMjHT;S(dy&t2 znTg-#!vSU(QU9>Wxj*cy+;m~72S6wO|If_8*TJi1ZM;|!Xc2>_tDnm{r-UW|7s)?b literal 0 HcmV?d00001 diff --git a/public/stylesheets/images/pic_open02.png b/public/stylesheets/images/pic_open02.png new file mode 100644 index 0000000000000000000000000000000000000000..b457f302f7b55e3c899afee2e2e091835cb635ec GIT binary patch literal 215 zcmeAS@N?(olHy`uVBq!ia0vp^dO$43!3HGvPgwUINO2Z;L>4nJa0`PlBg3pY5rkifktt>%r=h}o#S;-%_7-oFaYIxMbW^pc?c|~t(^S>|y z-46$t`E6jte{ntYFK=ES4z)+>iz|hdl!0_`wkbcR)P-?)y@G60U!DwdtNNjv*Dd-du7N zJfI+O;DC&ify326*&T-&Or7l4GQXSdal>=Xy&t!3YNlL=+`*s^wB!GOW(JidylT(Oq#psf N44$rjF6*2Ung9^~MY#X~ literal 0 HcmV?d00001 diff --git a/public/stylesheets/images/pic_select02.png b/public/stylesheets/images/pic_select02.png new file mode 100644 index 0000000000000000000000000000000000000000..e620fad1fde281e6a583d0430aa00ef6700eefd1 GIT binary patch literal 225 zcmeAS@N?(olHy`uVBq!ia0vp^5kM@)!3HE=ES4z)+>iz|hdl!0_`wkbcR)P-?)y@G60U!DwdtNNjv*Dd-du7N zJfI+O;DAir3Kp5bK#N5}2F~_tncq$KxZ!yw?&qx=8*fE01{^v2a_4$pfz9EC!rDR{ zIvY53HXKmfaDZtx7;)z?aqDcD%g85Ll$Ct6e!~gQ9Sr(FJO2M?W_YxLS8WRW=XF3X NgQu&X%Q~loCIFg}MBM-Y literal 0 HcmV?d00001 diff --git a/public/stylesheets/resource.css b/public/stylesheets/resource.css new file mode 100644 index 000000000..3c7ab35bb --- /dev/null +++ b/public/stylesheets/resource.css @@ -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;} + From 0821320dfefd4c7187dbdd7c65b5f329f3f89f97 Mon Sep 17 00:00:00 2001 From: z9hang Date: Wed, 19 Nov 2014 10:07:49 +0800 Subject: [PATCH 02/18] =?UTF-8?q?tag=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=AE=8C=E6=88=90=EF=BC=8C=E7=BF=BB=E9=A1=B5=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/tags_controller.rb | 35 +++++++++++++++++++++++++++ app/views/files/_course_file.html.erb | 2 +- app/views/tags/_tag_list.html.erb | 2 +- app/views/tags/remove_tag_new.js.erb | 6 +++++ config/routes.rb | 1 + public/stylesheets/resource.css | 10 +++++--- 6 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 app/views/tags/remove_tag_new.js.erb diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 27f7fe61d..5bd5fb0e3 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -14,6 +14,7 @@ class TagsController < ApplicationController include AttachmentsHelper include ContestsHelper include ActsAsTaggableOn::TagsHelper + include TagsHelper helper :projects helper :courses helper :tags @@ -189,6 +190,40 @@ class TagsController < ApplicationController 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] diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb index 8edd054be..603318cf6 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -11,7 +11,7 @@ - 发布资源 + 上传资源
diff --git a/app/views/tags/_tag_list.html.erb b/app/views/tags/_tag_list.html.erb index 092e0d898..c815d71f8 100644 --- a/app/views/tags/_tag_list.html.erb +++ b/app/views/tags/_tag_list.html.erb @@ -7,7 +7,7 @@ <% case object_flag %> <% when '6' %> <% if obj.author_id == User.current.id || User.current.admin?%> - <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag, + <%= link_to 'x', :controller => "tags", :action => "remove_tag_new", :remote => true, :tag_name => tag, :taggable_id => obj.id, :taggable_type => object_flag %> <% end %> <% 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/config/routes.rb b/config/routes.rb index 35b7b6ca2..3e2abce47 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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/remove_tag_new', :as=>"remove_tag_new" match 'tags/tag_save', :as => "save_tag" match 'words/add_brief_introdution' diff --git a/public/stylesheets/resource.css b/public/stylesheets/resource.css index 3c7ab35bb..f179b6683 100644 --- a/public/stylesheets/resource.css +++ b/public/stylesheets/resource.css @@ -55,10 +55,12 @@ 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;} +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 From eeda25add119adc937d1ef929bdadb2f3940a55e Mon Sep 17 00:00:00 2001 From: z9hang Date: Wed, 19 Nov 2014 11:03:23 +0800 Subject: [PATCH 03/18] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E5=85=AC=E5=BC=80=E4=B8=8E=E7=A7=81=E6=9C=89=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 17 +++++++++++++++++ app/views/attachments/update_file_dense.js.erb | 2 ++ app/views/files/_course_file.html.erb | 5 ++++- config/routes.rb | 1 + 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 app/views/attachments/update_file_dense.js.erb diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 3c815c7d8..5385956c1 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) 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/_course_file.html.erb b/app/views/files/_course_file.html.erb index 603318cf6..089eee8ac 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -28,7 +28,10 @@
<%= 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" %> - 选入我的课程公开 + 选入我的课程 + + <%= 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 %> +
diff --git a/config/routes.rb b/config/routes.rb index 3e2abce47..510872316 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -563,6 +563,7 @@ RedmineApp::Application.routes.draw 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 From 63b91e2cfb8ca2785b9fe2a24e781fe1645f1e7b Mon Sep 17 00:00:00 2001 From: z9hang Date: Wed, 19 Nov 2014 17:40:24 +0800 Subject: [PATCH 04/18] =?UTF-8?q?=E8=B5=84=E6=BA=90=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 10 ++++- app/views/files/_arrow_show.erb | 8 ++++ app/views/files/_attachement_list.html.erb | 46 ++++++++++++++++++++++ app/views/files/_course_file.html.erb | 22 +++++++++-- app/views/files/_upload_show.html.erb | 26 ++++++++++++ app/views/files/create.js.erb | 2 + app/views/files/index.html.erb | 3 +- app/views/files/upload_file_show.js.erb | 10 +++++ public/stylesheets/resource.css | 19 +++++++++ 9 files changed, 140 insertions(+), 6 deletions(-) create mode 100644 app/views/files/_arrow_show.erb create mode 100644 app/views/files/_attachement_list.html.erb create mode 100644 app/views/files/_upload_show.html.erb create mode 100644 app/views/files/upload_file_show.js.erb diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 75bf6fefd..2b65c1d78 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -49,7 +49,8 @@ class FilesController < ApplicationController 'size' => "#{Attachment.table_name}.filesize", 'downloads' => "#{Attachment.table_name}.downloads" sort = "" - + @sort = "" + @order = "" if params[:project_id] @isproject = true @@ -73,7 +74,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 @@ -135,6 +137,10 @@ class FilesController < ApplicationController end + def upload_file_show + + end + def new @versions = @project.versions.sort @course_tag = @project.project_type diff --git a/app/views/files/_arrow_show.erb b/app/views/files/_arrow_show.erb new file mode 100644 index 000000000..0fed13e60 --- /dev/null +++ b/app/views/files/_arrow_show.erb @@ -0,0 +1,8 @@ + +<% if sort == current %> + <% if order = "" || order =="asc" %> + ↑ + <% 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| %> + + <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%> + <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %> + <%= l(:field_is_public)%>: + <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => 'is_public')%> + <%= if attachment.id.nil? + #待补充代码 + else + link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') + end + %> + <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %> + + <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> + + <% 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 089eee8ac..d9546ce4e 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -2,6 +2,22 @@ <% sufixtypes = @course.contenttypes %> <% delete_allowed = User.current.allowed_to?(:manage_files, @course) %> <%= stylesheet_link_tag 'resource', :media => 'all' %> +
@@ -11,14 +27,14 @@ - 上传资源 + 上传资源

共有 <%= User.current.member_of_course?(@course) ? @all_attachments.count : 0 %> 个资源

-

按 时间 / 下载次数 / 引用次数 排序

+

按 <%= link_to "时间",course_files_path(@course,:sort=>"created_on"),:class => "f_b c_grey" %><%= render partial: 'arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %> / <%= link_to "下载次数",course_files_path(@course,:sort=>"downloads:desc"),:class => "f_b c_grey" %><%= render partial: 'arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %> / 引用次数 排序

<% @curse_attachments.each do |file| %> @@ -82,7 +98,7 @@ <%= 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) %>


- +
- - +
<%= 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 %> +
<% end %> - +
<% if User.current.login? %> From f2da5704efb01f5964067cf8aa7b27c985b5de8b Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 20 Nov 2014 17:44:30 +0800 Subject: [PATCH 09/18] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E5=8A=9F=E8=83=BD=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 29 ++++++++++++++++++ app/controllers/files_controller.rb | 12 ++++---- app/helpers/attachments_helper.rb | 2 ++ app/helpers/files_helper.rb | 10 +++++++ .../add_exist_file_to_courses.js.erb | 5 ++++ app/views/files/_arrow_show.erb | 8 +++-- app/views/files/_course_file.html.erb | 30 ++++++++++++++----- app/views/files/_show_quote_resource.html.erb | 24 +++++++++++++++ app/views/files/quote_resource_show.js.erb | 5 ++++ config/routes.rb | 4 +++ db/schema.rb | 3 +- 11 files changed, 115 insertions(+), 17 deletions(-) create mode 100644 app/views/attachments/add_exist_file_to_courses.js.erb create mode 100644 app/views/files/_show_quote_resource.html.erb create mode 100644 app/views/files/quote_resource_show.js.erb diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 5385956c1..83bba0d52 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -343,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 2b65c1d78..57fc44f5c 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -22,7 +22,7 @@ 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] helper :sort include SortHelper @@ -74,8 +74,7 @@ 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 @@ -116,7 +115,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 @@ -137,8 +137,8 @@ class FilesController < ApplicationController end - def upload_file_show - + def quote_resource_show + @file = Attachment.find(params[:id]) end def new 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/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/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/files/_arrow_show.erb b/app/views/files/_arrow_show.erb index 0fed13e60..d8f094719 100644 --- a/app/views/files/_arrow_show.erb +++ b/app/views/files/_arrow_show.erb @@ -1,8 +1,10 @@ <% if sort == current %> - <% if order = "" || order =="asc" %> - ↑ + <% if order =="asc" %> + ↑ + <% elsif order == "desc" %> + ↓ <% else %> - ↓ + <% end %> <% end %> \ 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 d9546ce4e..78fdd3fc5 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -1,17 +1,18 @@ <% attachmenttypes = @course.attachmenttypes %> <% sufixtypes = @course.contenttypes %> <% delete_allowed = User.current.allowed_to?(:manage_files, @course) %> + <%= stylesheet_link_tag 'resource', :media => 'all' %> \ No newline at end of file diff --git a/app/views/files/quote_resource_show.js.erb b/app/views/files/quote_resource_show.js.erb new file mode 100644 index 000000000..3acfeb988 --- /dev/null +++ b/app/views/files/quote_resource_show.js.erb @@ -0,0 +1,5 @@ +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'show_quote_resource',:locals => {:course => @course,:file => @file}) %>'); +showModal('ajax-modal', '513px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before(""); +$('#ajax-modal').parent().css("top","5").css("left","511"); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 510872316..5784185d6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -558,6 +558,7 @@ 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 @@ -654,6 +655,9 @@ RedmineApp::Application.routes.draw do collection do match "getattachtype", :via => [:get, :post] 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 collection do diff --git a/db/schema.rb b/db/schema.rb index f6fc138af..54ef46a70 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20141105012624) do +ActiveRecord::Schema.define(:version => 20141120091234) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -52,6 +52,7 @@ ActiveRecord::Schema.define(:version => 20141105012624) do t.string "disk_directory" t.integer "attachtype", :default => 1 t.integer "is_public", :default => 1 + t.integer "copy_from" end add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id" From 81420df6b93a32a0610fb1b72796995a13217a16 Mon Sep 17 00:00:00 2001 From: gonglexin <18008490802@163.com> Date: Thu, 20 Nov 2014 22:04:16 +0800 Subject: [PATCH 10/18] =?UTF-8?q?Fix=20#1523=20=E6=96=B0=E5=BB=BA=E7=BC=BA?= =?UTF-8?q?=E9=99=B7=E6=97=B6=E9=AB=98=E4=BA=AE=E6=98=BE=E7=A4=BA=20TAB=20?= =?UTF-8?q?=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/issues_controller.rb | 1 - 1 file changed, 1 deletion(-) 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] From 32157865381f1cb219bda6490b8801eadbf41f65 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 21 Nov 2014 11:33:11 +0800 Subject: [PATCH 11/18] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=9D=9E=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E6=88=90=E5=91=98=E8=83=BD=E7=9C=8B=E5=88=B0=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E4=BD=9C=E4=B8=9A=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)) From 68505239f9cd42c59049d0743dc90d5f1bbe2dc5 Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 21 Nov 2014 11:38:53 +0800 Subject: [PATCH 12/18] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=9A=82=E6=97=B6?= =?UTF-8?q?=E5=B1=8F=E8=94=BD=E6=8E=92=E5=BA=8F=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 2 +- app/controllers/files_controller.rb | 35 ++++- app/views/files/_course_file.html.erb | 157 ++-------------------- app/views/files/_course_list.html.erb | 51 +++++++ app/views/files/search.js.erb | 1 + config/routes.rb | 1 + 6 files changed, 96 insertions(+), 151 deletions(-) create mode 100644 app/views/files/_course_list.html.erb create mode 100644 app/views/files/search.js.erb diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 83bba0d52..a57b5f8a5 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -353,7 +353,7 @@ class AttachmentsController < ApplicationController 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 + 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 diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 57fc44f5c..ca7f8e040 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -22,7 +22,7 @@ class FilesController < ApplicationController menu_item :files before_filter :find_project_by_project_id#, :except => [:getattachtype] - before_filter :authorize, :except => [:getattachtype,:quote_resource_show] + before_filter :authorize, :except => [:getattachtype,:quote_resource_show,:search] helper :sort include SortHelper @@ -41,6 +41,38 @@ class FilesController < ApplicationController @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 filename LIKE :like ", like: "%#{keywords}%"). + reorder("created_on DESC") + end + def index #sort_init 'filename', 'asc' sort_init 'created_on', 'desc' @@ -51,6 +83,7 @@ class FilesController < ApplicationController sort = "" @sort = "" @order = "" + @is_remote = false if params[:project_id] @isproject = true diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb index 78fdd3fc5..49747ae11 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -1,6 +1,6 @@ <% attachmenttypes = @course.attachmenttypes %> <% sufixtypes = @course.contenttypes %> -<% delete_allowed = User.current.allowed_to?(:manage_files, @course) %> + <%= stylesheet_link_tag 'resource', :media => 'all' %>