上传文件表单支持添加文件标签
This commit is contained in:
parent
68b9a7efc5
commit
61135a352a
|
@ -52,9 +52,14 @@ class FilesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
if params[:tag_name]
|
if params[:add_tag]
|
||||||
|
@addTag=true
|
||||||
|
#render :back
|
||||||
tag_saveEx
|
tag_saveEx
|
||||||
render :text =>"success"
|
#render :text =>"success"
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
end
|
||||||
else
|
else
|
||||||
@addTag=false
|
@addTag=false
|
||||||
container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id]))
|
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')
|
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
|
||||||
Mailer.attachments_added(attachments[:files]).deliver
|
Mailer.attachments_added(attachments[:files]).deliver
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -689,7 +689,7 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag_saveEx
|
def tag_saveEx
|
||||||
@tags = params[:tag_name][:name]
|
@tags = params[:tag_name]
|
||||||
@obj_id = params[:obj_id]
|
@obj_id = params[:obj_id]
|
||||||
@obj_flag = params[:obj_flag]
|
@obj_flag = params[:obj_flag]
|
||||||
|
|
||||||
|
|
|
@ -49,5 +49,9 @@ module TagsHelper
|
||||||
end
|
end
|
||||||
return @result
|
return @result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def tagname_val
|
||||||
|
("#tag_name_name").value
|
||||||
end
|
end
|
|
@ -12,6 +12,5 @@ fileSpan.find('a.remove-upload')
|
||||||
})
|
})
|
||||||
.off('click');
|
.off('click');
|
||||||
var divattach = fileSpan.find('div.div_attachments');
|
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 %>
|
<% end %>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<% versions = project.versions.sort %>
|
<% versions = project.versions.sort %>
|
||||||
<% attachmenttypes = project.attachmenttypes %>
|
<% attachmenttypes = project.attachmenttypes %>
|
||||||
<%= error_messages_for 'attachment' %>
|
<%= 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 %>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<p>
|
<p>
|
||||||
<table>
|
<table>
|
||||||
|
|
|
@ -1,13 +1,3 @@
|
||||||
<script>
|
|
||||||
window.onload=function (){
|
|
||||||
$('#upload_form').submit(function() {
|
|
||||||
$(this).ajaxSubmit( {
|
|
||||||
target : '#tags_show'
|
|
||||||
});
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div id="tags">
|
<div id="tags">
|
||||||
<%#begin
|
<%#begin
|
||||||
|
@ -60,11 +50,7 @@
|
||||||
<%= text_field "tag_name" ,"name"%>
|
<%= text_field "tag_name" ,"name"%>
|
||||||
<input id="object_id" type="text" size="20" name="object_id" value='<%=obj.id%>' class="hidden">
|
<input id="object_id" type="text" size="20" name="object_id" value='<%=obj.id%>' class="hidden">
|
||||||
<input id="object_flag" type="text" size="20" name="object_flag" value='<%=object_flag%>' class="hidden">
|
<input id="object_flag" type="text" size="20" name="object_flag" value='<%=object_flag%>' class="hidden">
|
||||||
<%= button_tag "增加", :type=>"button", :onclick=>"tagAddClick(tags_show-"+obj.class.to_s + "-" +obj.id.to_s + ","+ obj.id.to_s + "," + object_flag.to_s + ")" %>
|
<%= submit_tag l(:button_add), :name=>"add_tag",:remote=>"false", :format => 'js' %>
|
||||||
<%#= f.text_field :object_id,:value=> obj.id,:style=>"display:none"%>
|
|
||||||
<%#= f.text_field :object_flag,:value=> object_flag,:style=>"display:none"%>
|
|
||||||
<input type="image" name="button" onclick="submitForm('<%=obj.id%>,<%=object_flag%>')" src="/commit.png"/>
|
|
||||||
<%= submit_tag "增加", :name=>"add_tag" %>
|
|
||||||
<div class='hidden'>
|
<div class='hidden'>
|
||||||
<% preTags = @preTags.nil? ? [] : @preTags %>
|
<% preTags = @preTags.nil? ? [] : @preTags %>
|
||||||
<% preTags.each do |tag|%>
|
<% preTags.each do |tag|%>
|
||||||
|
@ -113,13 +99,15 @@
|
||||||
|
|
||||||
|
|
||||||
<script language="JavaScript">
|
<script language="JavaScript">
|
||||||
function submitForm(objId,objTag){
|
function submitForm123(objId,objTag){
|
||||||
alert("OK");
|
alert("OK");
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type :"POST",
|
type :"Get",
|
||||||
url :'<%= users_tag_saveEx_path%>',
|
url :'<%= users_tag_saveEx_path%>',
|
||||||
|
remote:"true",
|
||||||
|
format:"js",
|
||||||
data: {
|
data: {
|
||||||
tagname: $('tag_name').value,
|
tagname: $('tag_name_name').val(),
|
||||||
obj_id: encodeURIComponent(objId),
|
obj_id: encodeURIComponent(objId),
|
||||||
obj_flag:encodeURIComponent(objTag)
|
obj_flag:encodeURIComponent(objTag)
|
||||||
},
|
},
|
||||||
|
@ -150,7 +138,7 @@
|
||||||
type :"POST",
|
type :"POST",
|
||||||
url :'<%= users_tag_saveEx_path%>',
|
url :'<%= users_tag_saveEx_path%>',
|
||||||
data: {
|
data: {
|
||||||
tagname: $('tag_name').value,
|
tagname: $('tag_name_name').val(),
|
||||||
obj_id: encodeURIComponent(objId),
|
obj_id: encodeURIComponent(objId),
|
||||||
obj_flag:encodeURIComponent(objTag)
|
obj_flag:encodeURIComponent(objTag)
|
||||||
},
|
},
|
||||||
|
|
|
@ -184,6 +184,9 @@ RedmineApp::Application.routes.draw do
|
||||||
|
|
||||||
#added by young
|
#added by young
|
||||||
resources :users do
|
resources :users do
|
||||||
|
collection do
|
||||||
|
match "tag_saveEx" , via: [:get, :post]
|
||||||
|
end
|
||||||
member do
|
member do
|
||||||
match 'user_projects', :to => 'users#user_projects', :via => :get
|
match 'user_projects', :to => 'users#user_projects', :via => :get
|
||||||
match 'user_activities', :to => 'users#show', :via => :get, :as => "user_activities"
|
match 'user_activities', :to => 'users#show', :via => :get, :as => "user_activities"
|
||||||
|
@ -235,7 +238,7 @@ RedmineApp::Application.routes.draw do
|
||||||
match 'users/:id/memberships', :to => 'users#edit_membership', :via => :post, :as => 'user_memberships'
|
match 'users/:id/memberships', :to => 'users#edit_membership', :via => :post, :as => 'user_memberships'
|
||||||
################# added by william
|
################# added by william
|
||||||
match 'users/tag_save', :to => 'users#tag_save', :via => :post, :as => 'tag'
|
match 'users/tag_save', :to => 'users#tag_save', :via => :post, :as => 'tag'
|
||||||
match 'users/tag_saveEx', :to => 'users#tag_saveEx', :via => :post
|
match 'users/tag_saveEx', :to => 'users#tag_saveEx', :via => [:get, :post]
|
||||||
|
|
||||||
post 'watchers/watch', :to => 'watchers#watch', :as => 'watch'
|
post 'watchers/watch', :to => 'watchers#watch', :as => 'watch'
|
||||||
delete 'watchers/watch', :to => 'watchers#unwatch'
|
delete 'watchers/watch', :to => 'watchers#unwatch'
|
||||||
|
|
17
db/schema.rb
17
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20140519074133) do
|
ActiveRecord::Schema.define(:version => 20140522025721) do
|
||||||
|
|
||||||
create_table "activities", :force => true do |t|
|
create_table "activities", :force => true do |t|
|
||||||
t.integer "act_id", :null => false
|
t.integer "act_id", :null => false
|
||||||
|
@ -23,9 +23,9 @@ ActiveRecord::Schema.define(:version => 20140519074133) do
|
||||||
add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type"
|
add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type"
|
||||||
add_index "activities", ["user_id"], :name => "index_activities_on_user_id"
|
add_index "activities", ["user_id"], :name => "index_activities_on_user_id"
|
||||||
|
|
||||||
create_table "andoidcontests", :force => true do |t|
|
create_table "applied_projects", :force => true do |t|
|
||||||
t.datetime "created_at", :null => false
|
t.integer "project_id", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.integer "user_id", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "apply_project_masters", :force => true do |t|
|
create_table "apply_project_masters", :force => true do |t|
|
||||||
|
@ -57,11 +57,14 @@ ActiveRecord::Schema.define(:version => 20140519074133) do
|
||||||
add_index "attachments", ["container_id", "container_type"], :name => "index_attachments_on_container_id_and_container_type"
|
add_index "attachments", ["container_id", "container_type"], :name => "index_attachments_on_container_id_and_container_type"
|
||||||
add_index "attachments", ["created_on"], :name => "index_attachments_on_created_on"
|
add_index "attachments", ["created_on"], :name => "index_attachments_on_created_on"
|
||||||
|
|
||||||
create_table "attachmentstypes", :force => true do |t|
|
create_table "attachmentstypes", :id => false, :force => true do |t|
|
||||||
t.integer "typeId", :null => false
|
t.integer "id", :null => false
|
||||||
|
t.integer "typeId"
|
||||||
t.string "typeName", :limit => 50
|
t.string "typeName", :limit => 50
|
||||||
end
|
end
|
||||||
|
|
||||||
|
add_index "attachmentstypes", ["id"], :name => "id"
|
||||||
|
|
||||||
create_table "auth_sources", :force => true do |t|
|
create_table "auth_sources", :force => true do |t|
|
||||||
t.string "type", :limit => 30, :default => "", :null => false
|
t.string "type", :limit => 30, :default => "", :null => false
|
||||||
t.string "name", :limit => 60, :default => "", :null => false
|
t.string "name", :limit => 60, :default => "", :null => false
|
||||||
|
@ -651,8 +654,8 @@ ActiveRecord::Schema.define(:version => 20140519074133) do
|
||||||
t.boolean "inherit_members", :default => false, :null => false
|
t.boolean "inherit_members", :default => false, :null => false
|
||||||
t.integer "project_type"
|
t.integer "project_type"
|
||||||
t.boolean "hidden_repo", :default => false, :null => false
|
t.boolean "hidden_repo", :default => false, :null => false
|
||||||
t.integer "user_id"
|
|
||||||
t.integer "attachmenttype", :default => 1
|
t.integer "attachmenttype", :default => 1
|
||||||
|
t.integer "user_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "projects", ["lft"], :name => "index_projects_on_lft"
|
add_index "projects", ["lft"], :name => "index_projects_on_lft"
|
||||||
|
|
Loading…
Reference in New Issue