parent
9c24102e65
commit
8badbb1e78
|
@ -62,6 +62,17 @@ class AttachmentsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#更新资源文件类型
|
||||||
|
def updateType
|
||||||
|
@attachment = Attachment.find(params[:attachmentid])
|
||||||
|
if @attachment != nil
|
||||||
|
@attachment.attachtype = params[:newtype]
|
||||||
|
@attachment.save
|
||||||
|
render :text =>'success'
|
||||||
|
else
|
||||||
|
render :text=>'error'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def thumbnail
|
def thumbnail
|
||||||
if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size])
|
if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size])
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<% edit_allowed = User.current.allowed_to?(:manage_files, @project) %>
|
||||||
|
<% if attachmenttypes.any? %>
|
||||||
|
<div id="put-tag-form-<%=attachment.id%>" class="hidden">
|
||||||
|
<%= select_tag "attachment_type",
|
||||||
|
options_from_collection_for_select(attachmenttypes, "id",
|
||||||
|
"typeName",attachment.attachtype), :onchange=>"attachmenttypes_change("+attachment.id.to_s + ",this.value)"%>
|
||||||
|
</div>
|
||||||
|
<%= link_to(image_tag('edit/edit.png'), 'javascript:void(0);',:style=>"white-space:nowrap;", :id=>"edit_box"+attachment.id.to_s ,
|
||||||
|
:onclick =>"$('#put-tag-form-" +attachment.id.to_s+ "').show();
|
||||||
|
$('#attach_type_id_label" +attachment.id.to_s+ "').hide();
|
||||||
|
$('#edit_box" +attachment.id.to_s+ "').hide();") if edit_allowed %>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
<% attachmenttypes = @project.attachmenttypes %>
|
||||||
<% delete_allowed = User.current.allowed_to?(:manage_files, @project) %>
|
<% delete_allowed = User.current.allowed_to?(:manage_files, @project) %>
|
||||||
<% edit_allowed = User.current.allowed_to?(:manage_files, @project) %>
|
<% edit_allowed = User.current.allowed_to?(:manage_files, @project) %>
|
||||||
<ul id="all_browse_ul">
|
<ul id="all_browse_ul">
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<% selAttachType =@attachtype %>
|
<% selAttachType =@attachtype %>
|
||||||
<% selContentType =@contenttype %>
|
<% selContentType =@contenttype %>
|
||||||
|
<% attachmenttypes = @project.attachmenttypes %>
|
||||||
<% delete_allowed = User.current.allowed_to?(:manage_files, @project) %>
|
<% delete_allowed = User.current.allowed_to?(:manage_files, @project) %>
|
||||||
<% edit_allowed = User.current.allowed_to?(:manage_files, @project) %>
|
<% edit_allowed = User.current.allowed_to?(:manage_files, @project) %>
|
||||||
<div id="catarory_browse_div" class="catarory_browse_div">
|
<div id="catarory_browse_div" class="catarory_browse_div">
|
||||||
|
@ -33,7 +34,15 @@
|
||||||
<td class="filename" style="font-size: 13px; width: 240px; "><%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %></td>
|
<td class="filename" style="font-size: 13px; width: 240px; "><%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %></td>
|
||||||
<td class="created_on"><%= format_time(file.created_on) %></td>
|
<td class="created_on"><%= format_time(file.created_on) %></td>
|
||||||
<td class="filesize"><%= number_to_human_size(file.filesize) %></td>
|
<td class="filesize"><%= number_to_human_size(file.filesize) %></td>
|
||||||
<td class="attach_type"><%= file.attachmentstype.typeName %></td>
|
<td class="attach_type">
|
||||||
|
<div id="attach_type_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.attachmentstype.typeName %></div>
|
||||||
|
|
||||||
|
<div id="attach_type_id_edit<%= file.id %>" style="white-space:nowrap;">
|
||||||
|
<%= render :partial => 'attachments/type_edit', :locals => {:attachmenttypes => attachmenttypes,
|
||||||
|
:attachment => file,:contentype=>selContentType} %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</td>
|
||||||
<td class="content_type"><%= file.show_suffix_type %></td>
|
<td class="content_type"><%= file.show_suffix_type %></td>
|
||||||
<td class="downloads"><%= file.downloads %></td>
|
<td class="downloads"><%= file.downloads %></td>
|
||||||
<!-- <td class="digest" width="300px"><%= file.description %></td> -->
|
<!-- <td class="digest" width="300px"><%= file.description %></td> -->
|
||||||
|
@ -64,3 +73,4 @@
|
||||||
</table>
|
</table>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -318,3 +318,40 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script type='text/javascript'>
|
||||||
|
function attachtype_edit(value) {
|
||||||
|
$.ajax({
|
||||||
|
|
||||||
|
url: '<%=getattachtype_project_files_path(project_id: @project)%>' + '?type='
|
||||||
|
+ $('#attachment_browse').val() + "&contentType=" + encodeURIComponent(value),
|
||||||
|
type: "POST"
|
||||||
|
|
||||||
|
}).complete(function (xhr, textStatus) {
|
||||||
|
if (textStatus == 'success') {
|
||||||
|
eval(xhr.responseText);
|
||||||
|
} else if (textStatus == 'error') {
|
||||||
|
alert('error');
|
||||||
|
}
|
||||||
|
;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function attachmenttypes_change(id,type) {
|
||||||
|
$.ajax({
|
||||||
|
url: '<%=updateType_attachments_path%>' + '?attachmentid=' +encodeURIComponent(id) + "&newtype="+encodeURIComponent(type) ,
|
||||||
|
type: "POST"
|
||||||
|
|
||||||
|
}).complete(function (xhr, textStatus) {
|
||||||
|
if (textStatus == 'success') {
|
||||||
|
$.ajax({
|
||||||
|
url: '<%=getattachtype_project_files_path(project_id: @project)%>' + '?type='
|
||||||
|
+ $('#attachment_browse').val() + "&contentType=" +$('#attach_sufix_browse').val(),
|
||||||
|
type: "POST"
|
||||||
|
});
|
||||||
|
} else if (textStatus == 'error') {
|
||||||
|
alert('error');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -456,7 +456,12 @@ 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'
|
||||||
resources :attachments, :only => [:show, :destroy]
|
post 'attachments/updateType/:attachmentid/:newtype' ,:to => 'attachments#updateType', :attachmentid => /\d+/, :newtype => /.*/
|
||||||
|
resources :attachments, :only => [:show, :destroy] do
|
||||||
|
collection do
|
||||||
|
match "updateType" , via: [:get, :post]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
resources :groups do
|
resources :groups do
|
||||||
member do
|
member do
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 522 B |
Loading…
Reference in New Issue