1.修复竞赛作品每次修改之后,都会吧图片清空的BUG

2.修改删除竞赛作品图片功能
This commit is contained in:
sw 2014-07-30 15:48:13 +08:00
parent 1f4943483e
commit 31e8ad98ae
6 changed files with 29 additions and 4 deletions

View File

@ -217,6 +217,17 @@ class AttachmentsController < ApplicationController
end
end
#删除竞赛作品的附件
def delete_softapplications
@attachment = Attachment.find params[:id]
@softapplication = @attachment.container if @attachment!=nil
@attachment.container.attachments.delete(@attachment) if @attachment!=nil
respond_to do |format|
format.html { redirect_to_referer_or edit_softapplication_path(@softapplication) }
#format.js
end
end
def autocomplete
# modify by nwb
if params[:project_id]

View File

@ -172,8 +172,8 @@ class SoftapplicationsController < ApplicationController
# PUT /softapplications/1.json
def update
# @softapplication = Softapplication.find(params[:id])
@softapplication.attachments.map{|attach| attach.destroy }
@softapplication.save_attachments(params[:attachments])
#@softapplication.attachments.map{|attach| attach.destroy }
@softapplication.save_attachments(params[:attachments]) if params[:attachments]
#@softapplication.deposit_project = params[:project]
@softapplication.project = Project.find_by_id(params[:project])

View File

@ -18,11 +18,20 @@
:method => :delete,
:class => 'delete',
:title => l(:button_delete) %>
<%# elsif attachment.container_type == 'Softapplication'%>
<%#= link_to image_tag('delete.png'), delete_softapplications_attachments_path(:id => attachment.id),
:data => {:confirm => l(:text_are_you_sure)},
:method => :delete,
:class => 'delete',
:remote => true,
:title => l(:button_delete) %>
<% else %>
<%= link_to image_tag('delete.png'), attachment_path(attachment),
:data => {:confirm => l(:text_are_you_sure)},
:method => :delete,
:class => 'delete',
:remote => true,
#:id => "attachments_" + attachment.id.to_s,
:title => l(:button_delete) %>
<% end %>
<% end %>

View File

@ -0,0 +1,2 @@
<% options = {:author => true, :deletable => true} %>
$("#soft_attachments_links").html('<%= escape_javascript(render(:partial => 'links', :locals => {:attachments => @softapplication.attachments, :options => options} )) %>');

View File

@ -102,8 +102,10 @@
<fieldset style="width: 500px">
<p style="padding-left: 60px">
<% options = {:author => true, :deletable => true} %>
<%= render :partial => 'attachments/links',
:locals => {:attachments => @softapplication.attachments, :options => options} %>
<span id="soft_attachments_links">
<%= render :partial => 'attachments/links',
:locals => {:attachments => @softapplication.attachments, :options => options} %>
</span>
</p>
<legend><%=l(:label_upload_softworkpacket_photo)%></legend>
<%= render_flash_messages %>

View File

@ -520,6 +520,7 @@ RedmineApp::Application.routes.draw do
match "updateType" , via: [:get, :post]
match "updateFileDense" , via: [:get, :post]
match "renderTag" , via: [:get, :post]
match 'delete_softapplications', via: [:get, :post]
end
end