diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index 50dd79a08..2e07421f8 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_helper.rb @@ -34,6 +34,16 @@ module AttachmentsHelper :locals => {:attachments => container.attachments, :options => options, :thumbnails => (options[:thumbnails] && Setting.thumbnails_enabled?)} end end + + def link_to_attachments_course(container, options = {}) + options.assert_valid_keys(:author, :thumbnails) + + if container.attachments.any? + options = {:deletable => container.attachments_deletable?, :author => true}.merge(options) + render :partial => 'attachments/course_file_links', + :locals => {:attachments => container.attachments, :options => options, :thumbnails => (options[:thumbnails] && Setting.thumbnails_enabled?)} + end + end def attach_delete(project) if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0) || project.user_id == User.current.id) diff --git a/app/views/attachments/_course_file_links.html.erb b/app/views/attachments/_course_file_links.html.erb new file mode 100644 index 000000000..d32025787 --- /dev/null +++ b/app/views/attachments/_course_file_links.html.erb @@ -0,0 +1,72 @@ +
+ <% is_float ||= false %> + <% for attachment in attachments %> +

+ <%if is_float%> +

+ <% end%> + + <% if options[:length] %> + <%= link_to_short_attachment attachment, :class => ' link_file_board', :download => true,:length => options[:length] -%> + <% else %> + <%= link_to_short_attachment attachment, :class => ' link_file_board', :download => true -%> + <% end %> + + <%if is_float%> +
+ <% end%> + + <% if attachment.is_text? %> + <%= link_to image_tag('magnifier.png'), + :controller => 'attachments', + :action => 'show', + :id => attachment, + :filename => attachment.filename%> + <% end %> + + <%= h(truncate(" - #{attachment.description}", length: options[:length] ? options[:length]:15, omission: '...')) unless attachment.description.blank? %> + + ( + <%= number_to_human_size attachment.filesize %>) + + <% if options[:deletable] %> + <% if attachment.container_type == 'HomeworkAttach' %> + <%= link_to image_tag('delete.png'), {:controller => 'attachments', :action => 'delete_homework', :id => attachment.id}, + :data => {:confirm => l(:text_are_you_sure)}, + :method => :delete, + :class => 'delete delete-homework-icon', + :remote => true, + :title => l(:button_delete) %> + <% else %> + <%= link_to image_tag('delete.png'), attachment_path(attachment), + :data => {:confirm => l(:text_are_you_sure)}, + :method => :delete, + :class => 'delete', + #:remote => true, + #:id => "attachments_" + attachment.id.to_s, + :title => l(:button_delete) %> + <% end %> + <% end %> + <% if options[:wrap] %> +
+   + <% end %> + <% if options[:author] %> + + <%= link_to h(truncate(attachment.author.name, length: 10, omission: '...')),user_path(attachment.author) %>, + <%= format_time(attachment.created_on) %> + + <% end %> +

+ <% end %> + <% if defined?(thumbnails) && thumbnails %> + <% images = attachments.select(&:thumbnailable?) %> + <% if images.any? %> +
+ <% images.each do |attachment| %> +
<%= thumbnail_tag(attachment) %>
+ <% end %> +
+ <% end %> + <% end %> +
diff --git a/app/views/messages/_course_new.html.erb b/app/views/messages/_course_new.html.erb index ba83b271e..ad2db8281 100644 --- a/app/views/messages/_course_new.html.erb +++ b/app/views/messages/_course_new.html.erb @@ -7,7 +7,8 @@ <%= form_for @message, :url => {:action => 'new'}, :html => {:multipart => true, :id => 'message-form'} do |f| %> <%= render :partial => 'form_course', :locals => {:f => f,:is_new => true} %> <%= l(:button_submit)%> - <%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form' ,target='preview',{:class => 'blue_btn grey_btn fl c_white'} )%> + <%#= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form' ,target='preview',{:class => 'blue_btn grey_btn fl c_white'} )%> + <%= link_to l(:button_cancel), course_boards_path(@course), :class => "blue_btn grey_btn fl c_white"%> <% end %> diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb index 2d849481e..613444c15 100644 --- a/app/views/messages/_course_show.html.erb +++ b/app/views/messages/_course_show.html.erb @@ -81,7 +81,7 @@ ) if @message.course_destroyable_by?(User.current) %>
<%= textilizable(@topic, :content) %>
-
<%= link_to_attachments @topic, :author => false %>
+
<%= link_to_attachments_course @topic, :author => false %>
<% if User.current.logged? %> @@ -109,7 +109,7 @@ <%= format_time(message.created_on) %>
<%= textilizable message,:content,:attachments => message.attachments %> - <%= link_to_attachments message, :author => false %> + <%= link_to_attachments_course message, :author => false %>
<%= link_to( diff --git a/app/views/messages/_form_course.html.erb b/app/views/messages/_form_course.html.erb index ba8abcfaa..e6dc99995 100644 --- a/app/views/messages/_form_course.html.erb +++ b/app/views/messages/_form_course.html.erb @@ -34,8 +34,8 @@
  • - - <%= render :partial => 'attachments/form_course', :locals => {:container => @message,:isReply => @isReply} %> + + <%= render :partial => 'attachments/new_form', :locals => {:container => @message,:isReply => @isReply} %>
  • diff --git a/app/views/messages/edit.html.erb b/app/views/messages/edit.html.erb index b37619b19..9a9ab3640 100644 --- a/app/views/messages/edit.html.erb +++ b/app/views/messages/edit.html.erb @@ -21,7 +21,7 @@ <%= link_to l(:button_cancel), board_message_url(@message.board, @message.root, :r => (@message.parent_id && @message.id)), :class => "ButtonColor m3p10" %> <% end %> <% elsif @message.course %> - <%= course_board_breadcrumb(@message) %> + <%#= course_board_breadcrumb(@message) %>
      <%= form_for @message, { diff --git a/app/views/news/_course_show.html.erb b/app/views/news/_course_show.html.erb index 46746fdbe..9ea8159bd 100644 --- a/app/views/news/_course_show.html.erb +++ b/app/views/news/_course_show.html.erb @@ -85,7 +85,7 @@ <%= delete_link(news_path(@news),:class => 'talk_edit fr') if User.current.allowed_to?(:manage_news, @course) %>
      <%= textilizable(@news, :description) %>
      <%= l(:label_create_time) %> : <%= format_time(@news.created_on) %>
      - <%= link_to_attachments @news %> + <%= link_to_attachments_course @news %>
    diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 249c566dc..11d94e9b2 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -371,7 +371,8 @@ span.add_attachment {font-size: 80%;line-height: 2.5em;} .ui-widget-header{border:1px solid #628db6;background:#759fcf url(jquery/images/ui-bg_gloss-wave_35_759fcf_500x100.png) 50% 50% repeat-x;color:#fff;font-weight:bold} .ui-corner-left,.ui-corner-tl{-moz-border-radius-topleft:4px;-webkit-border-top-left-radius:4px;-khtml-border-top-left-radius:4px;border-top-left-radius:4px} .link_file{ background:url(../images/pic_file.png) 0 7px no-repeat !important; padding-left:20px !important; color:#64bdd9 !important; } - +a:hover.link_file_board{ background:url(../images/pic_file.png) 0 -25px no-repeat; color:#3ca5c6;} +a.link_file_board{ background:url(../images/pic_file.png) 0 3px no-repeat !important; padding-left:20px !important; color:#64bdd9 !important; } /* colorbox *******************************************************************************/