From 462e5ab5891fd1dbc1853b09ac03093eaa62e483 Mon Sep 17 00:00:00 2001 From: nwb Date: Wed, 18 Jun 2014 15:48:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=BE=E7=A8=8B=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E6=96=87=E4=BB=B6=E7=B1=BB=E5=9E=8B=E7=BC=96=E8=BE=91?= =?UTF-8?q?BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../attachments/_course_type_edit.html.erb | 14 +++++++++ .../_course_show_all_attachment.html.erb | 2 +- .../_course_sort_by_attachtypel.html.erb | 2 +- app/views/files/index.html.erb | 31 +++++++++++++++++++ 4 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 app/views/attachments/_course_type_edit.html.erb diff --git a/app/views/attachments/_course_type_edit.html.erb b/app/views/attachments/_course_type_edit.html.erb new file mode 100644 index 00000000..f0bebaf8 --- /dev/null +++ b/app/views/attachments/_course_type_edit.html.erb @@ -0,0 +1,14 @@ +<% edit_allowed = User.current.allowed_to?(:manage_files, @course) %> +<% if attachmenttypes.any? %> + + <%= 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 %> + diff --git a/app/views/files/_course_show_all_attachment.html.erb b/app/views/files/_course_show_all_attachment.html.erb index 083fd2f7..1a8a8ca6 100644 --- a/app/views/files/_course_show_all_attachment.html.erb +++ b/app/views/files/_course_show_all_attachment.html.erb @@ -41,7 +41,7 @@ <%= file.attachmentstype.typeName %> - <%= render :partial => 'attachments/type_edit', :locals => {:attachmenttypes => attachmenttypes, :attachment => file, :contentype => selContentType} %> + <%= render :partial => 'attachments/course_type_edit', :locals => {:attachmenttypes => attachmenttypes, :attachment => file, :contentype => selContentType} %> <%= file.show_suffix_type %> diff --git a/app/views/files/_course_sort_by_attachtypel.html.erb b/app/views/files/_course_sort_by_attachtypel.html.erb index fe3311bd..f73cac07 100644 --- a/app/views/files/_course_sort_by_attachtypel.html.erb +++ b/app/views/files/_course_sort_by_attachtypel.html.erb @@ -36,7 +36,7 @@ <%= file.attachmentstype.typeName %>   - <%= render :partial => 'attachments/type_edit', :locals => {:attachmenttypes => attachmenttypes, + <%= render :partial => 'attachments/course_type_edit', :locals => {:attachmenttypes => attachmenttypes, :attachment => file,:contentype=>selContentType} %> diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index 68c5f5ca..b086b90d 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -176,6 +176,37 @@ <%end%> } + + function course_attachmenttypes_change(id, type) { + <% if @course%> + $.ajax({ + url: '<%=updateType_attachments_path%>', + type: "POST", + data: { + attachmentid: encodeURIComponent(id), + newtype: encodeURIComponent(type) + } + + }).complete(function (xhr, textStatus) { + + if (textStatus == 'success') { + $.ajax({ + url: '<%=getattachtype_course_files_path(course_id: @course)%>', + type: "POST", + data: { + type: $('#attachment_browse').val(), + contentType: $('#attach_sufix_browse').val() + } + }).error(function () { + alert('error'); + }); + } else if (textStatus == 'error') { + alert('An error has occurred'); + } + }); + <%end%> + + }