调整资源文件界面

This commit is contained in:
nwb 2014-05-17 14:07:57 +08:00
parent 7e4343f00f
commit 7df6be8ff4
8 changed files with 37 additions and 9 deletions

View File

@ -224,4 +224,11 @@ private
referer = request.headers['Referer'] referer = request.headers['Referer']
require_login unless referer =~ /softapplication/ require_login unless referer =~ /softapplication/
end end
def renderTag
@attachmentNew = Attachment.find(params[:attchmentId])
respond_to do |format|
format.js
end
end
end end

View File

@ -6,6 +6,7 @@
</span> </span>
<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 155, :placeholder => l(:label_optional_description), :class => 'description') + <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 155, :placeholder => l(:label_optional_description), :class => 'description') +
link_to('&nbsp;'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %> link_to('&nbsp;'.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}" %> <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
</span> </span>
<% end %> <% end %>

View File

@ -0,0 +1,3 @@
<%if @attachmentNew != nil%>
$("#div-attachments[" + @attachmentNew.id + "]").html('<%= j(render :partial => 'tags/tag', :locals => {:obj => @attachmentNew, :object_flag => "6"})%>');
<%end%>

View File

@ -11,4 +11,6 @@ fileSpan.find('a.remove-upload')
"href": '<%= j attachment_path(@attachment, :attachment_id => params[:attachment_id], :format => 'js') %>' "href": '<%= j attachment_path(@attachment, :attachment_id => params[:attachment_id], :format => 'js') %>'
}) })
.off('click'); .off('click');
var divattach = fileSpan.find('div.div_attachments');
divattach.html('<%= j(render :partial => 'tags/tag', :locals => {:obj => @attachment, :object_flag => "6"})%>');
<% end %> <% end %>

View File

@ -47,7 +47,7 @@
<%= form_for "tag_for_save",:remote=>true,:url=>tag_path, <%= form_for "tag_for_save",:remote=>true,:url=>tag_path,
:update => "tags_show", :update => "tags_show",
:complete => "$(\"#put-tag-form-#{obj.class}-#{obj.id}\").hide();" do |f| %> :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_id,:value=> obj.id,:style=>"display:none"%>
<%= f.text_field :object_flag,:value=> object_flag,:style=>"display:none"%> <%= f.text_field :object_flag,:value=> object_flag,:style=>"display:none"%>
<%= f.submit l(:button_project_tags_add),:class => "small" %> <%= f.submit l(:button_project_tags_add),:class => "small" %>

View File

@ -37,6 +37,7 @@ RedmineApp::Application.routes.draw do
end end
mount SeemsRateable::Engine => '/rateable', :as => :rateable mount SeemsRateable::Engine => '/rateable', :as => :rateable
namespace :zipdown do namespace :zipdown do
match 'assort' match 'assort'
end end
@ -458,9 +459,11 @@ RedmineApp::Application.routes.draw do
get 'attachments/autocomplete' get 'attachments/autocomplete'
match 'attachments/autocomplete', :to => 'attachments#autocomplete', via: [:post] match 'attachments/autocomplete', :to => 'attachments#autocomplete', via: [:post]
post 'attachments/relationfile', to: 'attachments#add_exist_file_to_project', as: 'attach_relation' 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 resources :attachments, :only => [:show, :destroy] do
collection do collection do
match "updateType" , via: [:get, :post] match "updateType" , via: [:get, :post]
match "renderTag" , via: [:get, :post]
end end
end end

View File

@ -1,6 +1,17 @@
/* Redmine - project management software /* Redmine - project management software
Copyright (C) 2006-2013 Jean-Philippe Lang */ Copyright (C) 2006-2013 Jean-Philippe Lang */
function postUpMsg(attachmentId)
{
$.ajax({
url: '/attachments/renderTag',
type: "GET",
data: {
attachmentId: attachmentId
}
})
}
function addFile(inputEl, file, eagerUpload) { function addFile(inputEl, file, eagerUpload) {
if ($('#attachments_fields').children().length < 10) { if ($('#attachments_fields').children().length < 10) {
@ -12,13 +23,14 @@ function addFile(inputEl, file, eagerUpload) {
fileSpan.append( fileSpan.append(
$('<input>', { 'type': 'text', 'class': 'filename readonly', 'name': 'attachments[' + attachmentId + '][filename]', 'readonly': 'readonly'} ).val(file.name), $('<input>', { 'type': 'text', 'class': 'filename readonly', 'name': 'attachments[' + attachmentId + '][filename]', 'readonly': 'readonly'} ).val(file.name),
$('<input>', { 'type': 'text', 'class': 'description', 'name': 'attachments[' + attachmentId + '][description]', 'maxlength': 255, 'placeholder': $(inputEl).data('description-placeholder') } ).toggle(!eagerUpload), $('<input>', { 'type': 'text', 'class': 'description', 'name': 'attachments[' + attachmentId + '][description]', 'maxlength': 255, 'placeholder': $(inputEl).data('description-placeholder') } ).toggle(!eagerUpload),
$('<a>&nbsp</a>').attr({ 'href': "#", 'class': 'remove-upload', 'data-confirm' : "您确定要删除吗?" }).click(removeFile).toggle(!eagerUpload) $('<a>&nbsp</a>').attr({ 'href': "#", 'class': 'remove-upload', 'data-confirm' : "您确定要删除吗?" }).click(removeFile).toggle(!eagerUpload),
$('<div>', { 'class': 'div_attachments', 'name': 'div_'+'attachments_' + attachmentId} )
).appendTo('#attachments_fields'); ).appendTo('#attachments_fields');
if(eagerUpload) { if(eagerUpload) {
ajaxUpload(file, attachmentId, fileSpan, inputEl); ajaxUpload(file, attachmentId, fileSpan, inputEl);
}
}
return attachmentId; return attachmentId;
} }
return null; return null;

View File

@ -1829,7 +1829,7 @@ fieldset#notified_events .parent { padding-left: 20px; }
span.required {color: #bb0000;} span.required {color: #bb0000;}
.summary {font-style: italic;} .summary {font-style: italic;}
#attachments_fields input.description {margin-left:4px; width:340px; } #attachments_fields input.description {margin-left:4px; width:100px; }
#attachments_fields span {display:block; white-space:nowrap; font-family:'微软雅黑';} #attachments_fields span {display:block; white-space:nowrap; font-family:'微软雅黑';}
#attachments_fields input.filename {border:0; height:1.8em; width:150px; color:#555; background-color:inherit; background:url(../images/attachment.png) no-repeat 1px 50%; padding-left:18px;}/*Modified by young*/ #attachments_fields input.filename {border:0; height:1.8em; width:150px; color:#555; background-color:inherit; background:url(../images/attachment.png) no-repeat 1px 50%; padding-left:18px;}/*Modified by young*/
#attachments_fields .ajax-waiting input.filename {background:url(../images/hourglass.png) no-repeat 0px 50%;} #attachments_fields .ajax-waiting input.filename {background:url(../images/hourglass.png) no-repeat 0px 50%;}