From 7df6be8ff4d4a9e75a2a3432a961f3a2b0428344 Mon Sep 17 00:00:00 2001 From: nwb Date: Sat, 17 May 2014 14:07:57 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 7 ++++++ app/views/attachments/_form.html.erb | 1 + app/views/attachments/renderTag.js.erb | 3 +++ app/views/attachments/upload.js.erb | 2 ++ app/views/tags/_tag.html.erb | 2 +- config/routes.rb | 3 +++ public/javascripts/attachments.js | 26 +++++++++++++++++------ public/stylesheets/application.css | 2 +- 8 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 app/views/attachments/renderTag.js.erb 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), + $('
', { 'class': 'div_attachments', 'name': 'div_'+'attachments_' + attachmentId} ) ).appendTo('#attachments_fields'); - - if(eagerUpload) { - ajaxUpload(file, attachmentId, fileSpan, inputEl); - } - return attachmentId; + if(eagerUpload) { + ajaxUpload(file, attachmentId, fileSpan, inputEl); + + } + return attachmentId; } return null; } @@ -66,7 +78,7 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) { //gcm files count and add delete_all link - var count=$('#attachments_fields>span').length; + var count=$('#attachments_fields>span').length; $('#upload_file_count').html("已上传"+""+count+""+"个文件"); if(count>=1){ diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index d786101b1..1a1c1b2ea 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -1829,7 +1829,7 @@ fieldset#notified_events .parent { padding-left: 20px; } span.required {color: #bb0000;} .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 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%;} From fc1d5baf95fea6587f2687249aabe6b3a9563d9f Mon Sep 17 00:00:00 2001 From: z9hang Date: Sat, 17 May 2014 15:15:33 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E3=80=81=E7=AB=9E?= =?UTF-8?q?=E8=B5=9B=E3=80=81=E9=A1=B9=E7=9B=AE=E7=9A=84=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=E7=9A=84=E4=B8=8A=E4=B8=8B=E9=97=B4=E8=B7=9D=E7=BC=A9=E5=B0=8F?= =?UTF-8?q?=20logo=E5=92=8C=E5=A4=A7=E5=AD=A6=E5=90=8D=E7=A7=B0=E7=9A=84?= =?UTF-8?q?=E5=B1=85=E4=B8=AD=E5=AF=B9=E9=BD=90=EF=BC=8C=E4=BB=A5=E5=8F=8A?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E6=9D=A1=E7=9A=84=E4=B8=8A=E4=B8=8B=E5=B1=85?= =?UTF-8?q?=E4=B8=AD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_base_footer.html.erb | 2 +- app/views/welcome/contest.html.erb | 21 ++++++++++++++++++--- app/views/welcome/course.html.erb | 21 +++++++++++++++++---- app/views/welcome/index.html.erb | 21 +++++++++++++++++---- public/stylesheets/welcome.css | 8 ++++---- 5 files changed, 57 insertions(+), 16 deletions(-) diff --git a/app/views/layouts/_base_footer.html.erb b/app/views/layouts/_base_footer.html.erb index ee7bcecf0..baf438cb2 100644 --- a/app/views/layouts/_base_footer.html.erb +++ b/app/views/layouts/_base_footer.html.erb @@ -1,6 +1,6 @@
-