From 61135a352aefc03babc1371f88b587dab9b262d6 Mon Sep 17 00:00:00 2001 From: nwb Date: Wed, 28 May 2014 14:43:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=A1=A8?= =?UTF-8?q?=E5=8D=95=E6=94=AF=E6=8C=81=E6=B7=BB=E5=8A=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 31 ++++++++++++++++++++++++++--- app/controllers/users_controller.rb | 2 +- app/helpers/tags_helper.rb | 6 +++++- app/views/attachments/upload.js.erb | 3 +-- app/views/files/_new.html.erb | 2 +- app/views/tags/_tagEx.html.erb | 26 +++++++----------------- config/routes.rb | 5 ++++- db/schema.rb | 17 +++++++++------- 8 files changed, 57 insertions(+), 35 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index f9236d0b7..5b81b7291 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -52,9 +52,14 @@ class FilesController < ApplicationController end def create - if params[:tag_name] + if params[:add_tag] + @addTag=true + #render :back tag_saveEx - render :text =>"success" + #render :text =>"success" + respond_to do |format| + format.js + end else @addTag=false container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id])) @@ -64,7 +69,27 @@ class FilesController < ApplicationController if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') Mailer.attachments_added(attachments[:files]).deliver end - redirect_to project_files_path(@project) + + # 临时用 + sort_init 'created_on', 'desc' + sort_update 'created_on' => "#{Attachment.table_name}.created_on", + 'filename' => "#{Attachment.table_name}.filename", + 'size' => "#{Attachment.table_name}.filesize", + 'downloads' => "#{Attachment.table_name}.downloads" + + @containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] #modify by Long Jun + @containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort + + @attachtype = 0 + @contenttype = 0 + + respond_to do |format| + format.js + format.html { + redirect_to project_files_path(@project) + } + end + end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index cdecb97f8..840dabfe0 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -689,7 +689,7 @@ class UsersController < ApplicationController end def tag_saveEx - @tags = params[:tag_name][:name] + @tags = params[:tag_name] @obj_id = params[:obj_id] @obj_flag = params[:obj_flag] diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb index ba2470fe9..201a582f2 100644 --- a/app/helpers/tags_helper.rb +++ b/app/helpers/tags_helper.rb @@ -49,5 +49,9 @@ module TagsHelper end return @result end - + +end + +def tagname_val + ("#tag_name_name").value end \ No newline at end of file diff --git a/app/views/attachments/upload.js.erb b/app/views/attachments/upload.js.erb index 674d73b79..63600619b 100644 --- a/app/views/attachments/upload.js.erb +++ b/app/views/attachments/upload.js.erb @@ -12,6 +12,5 @@ fileSpan.find('a.remove-upload') }) .off('click'); var divattach = fileSpan.find('div.div_attachments'); -divattach.html('<%#= j(render :partial => 'tags/tagEx', :locals => {:obj => @attachment, :object_flag => "6"})%>'); - +divattach.html('<%= j(render :partial => 'tags/tagEx', :locals => {:obj => @attachment, :object_flag => "6"})%>'); <% end %> diff --git a/app/views/files/_new.html.erb b/app/views/files/_new.html.erb index a01143e0b..7dcf82e19 100644 --- a/app/views/files/_new.html.erb +++ b/app/views/files/_new.html.erb @@ -2,7 +2,7 @@ <% versions = project.versions.sort %> <% attachmenttypes = project.attachmenttypes %> <%= error_messages_for 'attachment' %> -<%= form_tag(project_files_path(project), :multipart => true,:name=>"upload_form", :class => "tabular") do %> +<%= form_tag(project_files_path(project), :multipart => true,:remote => true,:method => :post,:name=>"upload_form", :class => "tabular") do %>

diff --git a/app/views/tags/_tagEx.html.erb b/app/views/tags/_tagEx.html.erb index 08800caa1..3e7cd9c68 100644 --- a/app/views/tags/_tagEx.html.erb +++ b/app/views/tags/_tagEx.html.erb @@ -1,13 +1,3 @@ -
<%#begin @@ -60,11 +50,7 @@ <%= text_field "tag_name" ,"name"%> - <%= button_tag "增加", :type=>"button", :onclick=>"tagAddClick(tags_show-"+obj.class.to_s + "-" +obj.id.to_s + ","+ obj.id.to_s + "," + object_flag.to_s + ")" %> - <%#= f.text_field :object_id,:value=> obj.id,:style=>"display:none"%> - <%#= f.text_field :object_flag,:value=> object_flag,:style=>"display:none"%> - - <%= submit_tag "增加", :name=>"add_tag" %> + <%= submit_tag l(:button_add), :name=>"add_tag",:remote=>"false", :format => 'js' %>