diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 031f78277..ef6e20644 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -45,11 +45,45 @@ class FilesController < ApplicationController 'filename' => "#{Attachment.table_name}.filename", 'size' => "#{Attachment.table_name}.filesize", 'downloads' => "#{Attachment.table_name}.downloads" + sort = "" if params[:project_id] @isproject = true - @containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] - @containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort + + if params[:sort] + params[:sort].split(",").each do |sort_type| + order_by = sort_type.split(":") + + case order_by[0] + when "filename" + attribute = "filename" + when "size" + attribute = "filesize" + when "attach_type" + attribute = "attachtype" + when "content_type" + attribute = "created_on" + when "field_file_dense" + attribute = "is_public" + when "downloads" + attribute = "downloads" + when "created_on" + attribute = "created_on" + end + + if order_by.count == 1 + sort += "#{Attachment.table_name}.#{attribute} desc " + elsif order_by.count == 2 + sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} " + end + if sort_type != params[:sort].split(",").last + sort += "," + end + end + end + + @containers = [ Project.includes(:attachments).reorder(sort).find(@project.id)] + @containers += @project.versions.includes(:attachments).reorder(sort).all.sort show_attachments @containers @@ -57,7 +91,6 @@ class FilesController < ApplicationController elsif params[:course_id] @isproject = false - sort = "" if params[:sort] params[:sort].split(",").each do |sort_type| order_by = sort_type.split(":") diff --git a/app/views/news/_form.html.erb b/app/views/news/_form.html.erb index f92559903..35d8da952 100644 --- a/app/views/news/_form.html.erb +++ b/app/views/news/_form.html.erb @@ -3,9 +3,11 @@ <%= @project ? l(:label_news_new) : l(:bale_news_notice) %>
-

<%= f.text_field :title, :required => true, :size => 60, :style => "width:488px;" %>

+

<%= f.text_field :title, :required => true, :size => 60, :style => "width:488px;", :onblur => "regexTitle();" %>

+

(60个字符以内)

-

<%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:490px;" %>

+

<%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:490px;", :onblur => "regexDescription();" %>

+

<%= render :partial => 'attachments/form', :locals => {:container => @news} %>

diff --git a/app/views/news/_project_news.html.erb b/app/views/news/_project_news.html.erb index cdef33e34..e9a912c5c 100644 --- a/app/views/news/_project_news.html.erb +++ b/app/views/news/_project_news.html.erb @@ -1,3 +1,56 @@ + + <% if @project.project_type == Project::ProjectType_course btn_tips = l(:label_news_notice) @@ -22,7 +75,9 @@ <%= labelled_form_for @news, :url => project_news_index_path(@project), :html => {:id => 'news-form', :multipart => true} do |f| %> <%= render :partial => 'news/form', :locals => {:f => f} %> - <%= submit_tag l(:button_create), :class => 'whiteButton m3p10 h30', :name => nil %> | + <%#= submit_tag l(:button_create), :class => 'whiteButton m3p10 h30', :name => nil %> + <%= link_to l(:button_create), "#", :onclick => 'submitNews();', :class => 'whiteButton m3p10' %> + | <%= preview_link preview_news_path(:project_id => @project), 'news-form', target='preview', {:class => 'whiteButton m3p10'} %> | <%= link_to l(:button_cancel), "#", :onclick => '$("#add-news").hide()', :class => 'whiteButton m3p10' %> diff --git a/app/views/news/_project_show.html.erb b/app/views/news/_project_show.html.erb index c8a8c5767..ecae672b6 100644 --- a/app/views/news/_project_show.html.erb +++ b/app/views/news/_project_show.html.erb @@ -1,3 +1,55 @@ +
<%= watcher_link(@news, User.current) %> <%= link_to(l(:button_edit), @@ -15,9 +67,10 @@ <%= labelled_form_for :news, @news, :url => news_path(@news), :html => { :id => 'news-form', :multipart => true, :method => :put } do |f| %> <%= render :partial => 'form', :locals => { :f => f } %> - <%= submit_tag l(:button_save) %> - <%= preview_link preview_news_path(:project_id => @project, :id => @news), 'news-form',target='preview',{:class => ''} %> | - <%= link_to l(:button_cancel), "#", :onclick => '$("#edit-news").hide(); return false;' %> + <%#= submit_tag l(:button_save) %> + <%= link_to l(:button_save), "#", :onclick => 'submitNews();',:class => 'whiteButton m3p10' %> + <%= preview_link preview_news_path(:project_id => @project, :id => @news), 'news-form',target='preview',{:class => 'whiteButton m3p10'} %> | + <%= link_to l(:button_cancel), "#", :onclick => '$("#edit-news").hide(); return false;',:class => 'whiteButton m3p10' %> <% end %>
diff --git a/app/views/users/user_fanslist.html.erb b/app/views/users/user_fanslist.html.erb index 984cdf352..f16e6d397 100644 --- a/app/views/users/user_fanslist.html.erb +++ b/app/views/users/user_fanslist.html.erb @@ -20,27 +20,18 @@

- <% unless user.memberships.empty? %> - <% cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" %> - <% memberships = user.memberships.all(:conditions => cond) %> - <%= l(:label_x_contribute_to, :count => memberships.count) %> - <% for member in memberships %> - <%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : ',' %> - <% end %> - <% else %> - <%= l(:label_x_contribute_to, :count => 0) %> + <% cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" %> + <% memberships = user.memberships.all(:conditions => cond) %> + <%= l(:label_x_contribute_to, :count => memberships.count) %> + <% for member in memberships %> + <%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : ',' %> <% end %>

- <% unless user.memberships.empty? %> - <% cond = Project.visible_condition(User.current) + " AND projects.project_type = 1" %> - <% memberships = user.memberships.all(:conditions => cond) %> - <%= l(:label_x_course_contribute_to, :count => memberships.count) %> - <% for member in memberships %> - <%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : ',' %> - <% end %> - <% else %> - <%= l(:label_x_course_contribute_to, :count => 0) %> + <% user_courses = user_courses_list(user) %> + <%= l(:label_x_course_contribute_to, :count => user_courses.count) %> + <% for course in user_courses %> + <%= link_to course.name,{:controller => 'courses',:action => 'show',id:course.id, host: Setting.course_domain} %><%= (user_courses.last == course) ? '' : ',' %> <% end %>

diff --git a/app/views/users/user_watchlist.html.erb b/app/views/users/user_watchlist.html.erb index bc4a655d8..e58e35d27 100644 --- a/app/views/users/user_watchlist.html.erb +++ b/app/views/users/user_watchlist.html.erb @@ -7,31 +7,32 @@ <%= link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :title => "#{user.name}" %> - +
<%= content_tag "div", link_to(user.name,user_path(user)), :class => "project_avatar_name" %> + <%= content_tag "div", link_to(user.name,user_path(user)), :class => "project_avatar_name" %>

- <% unless user.memberships.empty? %> + <%# unless user.memberships.empty? %> <% cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" %> <% memberships = user.memberships.all(:conditions => cond) %> <%= l(:label_x_contribute_to, :count => memberships.count) %> <% for member in memberships %> <%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : ',' %> <% end %> - <% end %> + <%# end %>

- <% unless user.memberships.empty? %> - <% cond = Project.visible_condition(User.current) + " AND projects.project_type = 1" %> - <% memberships = user.memberships.all(:conditions => cond) %> - <%= l(:label_x_course_contribute_to, :count => memberships.count) %> - <% for member in memberships %> - <%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : ',' %> - <% end %> - <% end %> + <%# unless user.memberships.empty? %> + <% user_courses = user_courses_list(user) %> + <%= l(:label_x_course_contribute_to, :count => user_courses.count) %> + <% for course in user_courses %> + <%# if course.name != nil %> + <%= link_to course.name,{:controller => 'courses',:action => 'show',id:course.id, host: Setting.course_domain} %><%= (user_courses.last == course) ? '' : ',' %> + <%# end %> + <% end %> + <%# end %>

-