修改课程资源文件类型编辑BUG

This commit is contained in:
nwb 2014-06-18 15:48:06 +08:00
parent 80145c5c3b
commit 462e5ab589
4 changed files with 47 additions and 2 deletions

View File

@ -0,0 +1,14 @@
<% edit_allowed = User.current.allowed_to?(:manage_files, @course) %>
<% 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=>"course_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 %>

View File

@ -41,7 +41,7 @@
<td class="attach_type">
<span id="attach_type_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.attachmentstype.typeName %></span>
<span id="attach_type_id_edit<%= file.id %>" style="white-space:nowrap;">
<%= 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} %>
</span>
</td>
<td class="content_type"><%= file.show_suffix_type %></td>

View File

@ -36,7 +36,7 @@
<span id="attach_type_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.attachmentstype.typeName %></span>
&nbsp;
<span id="attach_type_id_edit<%= file.id %>" style="white-space:nowrap;">
<%= render :partial => 'attachments/type_edit', :locals => {:attachmenttypes => attachmenttypes,
<%= render :partial => 'attachments/course_type_edit', :locals => {:attachmenttypes => attachmenttypes,
:attachment => file,:contentype=>selContentType} %>
</span>
</td>

View File

@ -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%>
}
</script>