diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 900487364..d6c90ccf4 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -224,4 +224,11 @@ private referer = request.headers['Referer'] require_login unless referer =~ /softapplication/ end + + def renderTag + @attachmentNew = Attachment.find(params[:attchmentId]) + respond_to do |format| + format.js + end + end end diff --git a/app/views/attachments/_form.html.erb b/app/views/attachments/_form.html.erb index f34a0e4e7..ce4ffbea1 100644 --- a/app/views/attachments/_form.html.erb +++ b/app/views/attachments/_form.html.erb @@ -6,6 +6,7 @@ <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 155, :placeholder => l(:label_optional_description), :class => 'description') + link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %> + <%= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %> <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> <% end %> diff --git a/app/views/attachments/renderTag.js.erb b/app/views/attachments/renderTag.js.erb new file mode 100644 index 000000000..7e45299d5 --- /dev/null +++ b/app/views/attachments/renderTag.js.erb @@ -0,0 +1,3 @@ +<%if @attachmentNew != nil%> +$("#div-attachments[" + @attachmentNew.id + "]").html('<%= j(render :partial => 'tags/tag', :locals => {:obj => @attachmentNew, :object_flag => "6"})%>'); +<%end%> diff --git a/app/views/attachments/upload.js.erb b/app/views/attachments/upload.js.erb index 82b79bb63..63492688a 100644 --- a/app/views/attachments/upload.js.erb +++ b/app/views/attachments/upload.js.erb @@ -11,4 +11,6 @@ fileSpan.find('a.remove-upload') "href": '<%= j attachment_path(@attachment, :attachment_id => params[:attachment_id], :format => 'js') %>' }) .off('click'); +var divattach = fileSpan.find('div.div_attachments'); +divattach.html('<%= j(render :partial => 'tags/tag', :locals => {:obj => @attachment, :object_flag => "6"})%>'); <% end %> diff --git a/app/views/tags/_tag.html.erb b/app/views/tags/_tag.html.erb index 205143924..dc94b3571 100644 --- a/app/views/tags/_tag.html.erb +++ b/app/views/tags/_tag.html.erb @@ -47,7 +47,7 @@ <%= form_for "tag_for_save",:remote=>true,:url=>tag_path, :update => "tags_show", :complete => "$(\"#put-tag-form-#{obj.class}-#{obj.id}\").hide();" do |f| %> - <%= f.text_field :name ,:id => "name",:size=>"28",:require=>true,:maxlength => Setting.tags_max_length,:minlength=>Setting.tags_min_length %> + <%= f.text_field :name ,:id => "name",:size=>"28",:require=>true,:maxlength => Setting.tags_max_length,:minlength=>Setting.tags_min_length,:style=>"width: 100px;"%> <%= f.text_field :object_id,:value=> obj.id,:style=>"display:none"%> <%= f.text_field :object_flag,:value=> object_flag,:style=>"display:none"%> <%= f.submit l(:button_project_tags_add),:class => "small" %> diff --git a/config/routes.rb b/config/routes.rb index d93112c54..a3f4b4149 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -37,6 +37,7 @@ RedmineApp::Application.routes.draw do end mount SeemsRateable::Engine => '/rateable', :as => :rateable + namespace :zipdown do match 'assort' end @@ -458,9 +459,11 @@ RedmineApp::Application.routes.draw do get 'attachments/autocomplete' match 'attachments/autocomplete', :to => 'attachments#autocomplete', via: [:post] post 'attachments/relationfile', to: 'attachments#add_exist_file_to_project', as: 'attach_relation' + get 'attachments/renderTag/:attchmentId', :to => 'attachments#renderTag', :attchmentId => /\d+/ resources :attachments, :only => [:show, :destroy] do collection do match "updateType" , via: [:get, :post] + match "renderTag" , via: [:get, :post] end end diff --git a/public/javascripts/attachments.js b/public/javascripts/attachments.js index 3d1520f84..663183b9a 100644 --- a/public/javascripts/attachments.js +++ b/public/javascripts/attachments.js @@ -1,6 +1,17 @@ /* Redmine - project management software Copyright (C) 2006-2013 Jean-Philippe Lang */ +function postUpMsg(attachmentId) +{ + $.ajax({ + url: '/attachments/renderTag', + type: "GET", + data: { + attachmentId: attachmentId + } + + }) +} function addFile(inputEl, file, eagerUpload) { if ($('#attachments_fields').children().length < 10) { @@ -12,14 +23,15 @@ function addFile(inputEl, file, eagerUpload) { fileSpan.append( $('', { 'type': 'text', 'class': 'filename readonly', 'name': 'attachments[' + attachmentId + '][filename]', 'readonly': 'readonly'} ).val(file.name), $('', { 'type': 'text', 'class': 'description', 'name': 'attachments[' + attachmentId + '][description]', 'maxlength': 255, 'placeholder': $(inputEl).data('description-placeholder') } ).toggle(!eagerUpload), - $(' ').attr({ 'href': "#", 'class': 'remove-upload', 'data-confirm' : "您确定要删除吗?" }).click(removeFile).toggle(!eagerUpload) + $(' ').attr({ 'href': "#", 'class': 'remove-upload', 'data-confirm' : "您确定要删除吗?" }).click(removeFile).toggle(!eagerUpload), + $('