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 000000000..f0bebaf89
--- /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? %>
+
+ <%= select_tag "attachment_type",
+ options_from_collection_for_select(attachmenttypes, "id",
+ "typeName",attachment.attachtype), :onchange=>"course_attachmenttypes_change("+attachment.id.to_s + ",this.value)"%>
+
+ <%= 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 083fd2f70..1a8a8ca65 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 fe3311bdd..f73cac072 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 68c5f5cac..b086b90db 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%>
+
+ }