上传文件表单支持添加文件标签
This commit is contained in:
parent
68b9a7efc5
commit
61135a352a
|
@ -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
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
||||
|
|
|
@ -51,3 +51,7 @@ module TagsHelper
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
def tagname_val
|
||||
("#tag_name_name").value
|
||||
end
|
|
@ -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 %>
|
||||
|
|
|
@ -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 %>
|
||||
<div class="box">
|
||||
<p>
|
||||
<table>
|
||||
|
|
|
@ -1,13 +1,3 @@
|
|||
<script>
|
||||
window.onload=function (){
|
||||
$('#upload_form').submit(function() {
|
||||
$(this).ajaxSubmit( {
|
||||
target : '#tags_show'
|
||||
});
|
||||
return false;
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<div id="tags">
|
||||
<%#begin
|
||||
|
@ -60,11 +50,7 @@
|
|||
<%= text_field "tag_name" ,"name"%>
|
||||
<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">
|
||||
<%= 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"%>
|
||||
<input type="image" name="button" onclick="submitForm('<%=obj.id%>,<%=object_flag%>')" src="/commit.png"/>
|
||||
<%= submit_tag "增加", :name=>"add_tag" %>
|
||||
<%= submit_tag l(:button_add), :name=>"add_tag",:remote=>"false", :format => 'js' %>
|
||||
<div class='hidden'>
|
||||
<% preTags = @preTags.nil? ? [] : @preTags %>
|
||||
<% preTags.each do |tag|%>
|
||||
|
@ -113,13 +99,15 @@
|
|||
|
||||
|
||||
<script language="JavaScript">
|
||||
function submitForm(objId,objTag){
|
||||
function submitForm123(objId,objTag){
|
||||
alert("OK");
|
||||
$.ajax({
|
||||
type :"POST",
|
||||
type :"Get",
|
||||
url :'<%= users_tag_saveEx_path%>',
|
||||
remote:"true",
|
||||
format:"js",
|
||||
data: {
|
||||
tagname: $('tag_name').value,
|
||||
tagname: $('tag_name_name').val(),
|
||||
obj_id: encodeURIComponent(objId),
|
||||
obj_flag:encodeURIComponent(objTag)
|
||||
},
|
||||
|
@ -150,7 +138,7 @@
|
|||
type :"POST",
|
||||
url :'<%= users_tag_saveEx_path%>',
|
||||
data: {
|
||||
tagname: $('tag_name').value,
|
||||
tagname: $('tag_name_name').val(),
|
||||
obj_id: encodeURIComponent(objId),
|
||||
obj_flag:encodeURIComponent(objTag)
|
||||
},
|
||||
|
|
|
@ -184,6 +184,9 @@ RedmineApp::Application.routes.draw do
|
|||
|
||||
#added by young
|
||||
resources :users do
|
||||
collection do
|
||||
match "tag_saveEx" , via: [:get, :post]
|
||||
end
|
||||
member do
|
||||
match 'user_projects', :to => 'users#user_projects', :via => :get
|
||||
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'
|
||||
################# added by william
|
||||
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'
|
||||
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.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20140519074133) do
|
||||
ActiveRecord::Schema.define(:version => 20140522025721) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
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"], :name => "index_activities_on_user_id"
|
||||
|
||||
create_table "andoidcontests", :force => true do |t|
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
create_table "applied_projects", :force => true do |t|
|
||||
t.integer "project_id", :null => false
|
||||
t.integer "user_id", :null => false
|
||||
end
|
||||
|
||||
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", ["created_on"], :name => "index_attachments_on_created_on"
|
||||
|
||||
create_table "attachmentstypes", :force => true do |t|
|
||||
t.integer "typeId", :null => false
|
||||
create_table "attachmentstypes", :id => false, :force => true do |t|
|
||||
t.integer "id", :null => false
|
||||
t.integer "typeId"
|
||||
t.string "typeName", :limit => 50
|
||||
end
|
||||
|
||||
add_index "attachmentstypes", ["id"], :name => "id"
|
||||
|
||||
create_table "auth_sources", :force => true do |t|
|
||||
t.string "type", :limit => 30, :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.integer "project_type"
|
||||
t.boolean "hidden_repo", :default => false, :null => false
|
||||
t.integer "user_id"
|
||||
t.integer "attachmenttype", :default => 1
|
||||
t.integer "user_id"
|
||||
end
|
||||
|
||||
add_index "projects", ["lft"], :name => "index_projects_on_lft"
|
||||
|
|
Loading…
Reference in New Issue