修复课程角色不能修改的BUG

This commit is contained in:
sw 2014-09-29 16:59:36 +08:00
parent ca519ce22d
commit 2ce07955c1
1 changed files with 15 additions and 28 deletions

View File

@ -20,34 +20,25 @@
<% members.each do |member| %>
<% next if member.new_record? %>
<tr id="member-<%= member.id %>" class="<%= cycle 'odd', 'even' %> member">
<td class="<%= member.principal.class.name.downcase %>">
<%= link_to_user member.principal %>
</td>
<td class="<%= member.principal.class.name.downcase %>"><%= link_to_user member.principal %></td>
<td class="roles">
<span id="member-<%= member.id %>-roles">
<%= h member.roles.sort.collect(&:to_s).join(', ') %>
</span>
<%= form_for(member, {:as => :membership, :remote => true,
:url => course_memberships_path(member),:method => :put,
:html => {:id => "member-#{member.id}-roles-form",
:class => 'hol'}}
<%= form_for(member, {:as => :membership, :remote => true, :url => membership_path(member),
:method => :put,
:html => {:id => "member-#{member.id}-roles-form", :class => 'hol'}}
) do |f| %>
<p>
<% roles.each do |role| %>
<label>
<%= radio_button_tag 'membership[role_ids][]', role.id, member.roles.include?(role),:disabled => member.member_roles.detect { |mr| mr.role_id == role.id && !mr.inherited_from.nil? } %>
<%= h role %>
</label>
<br/>
<% end %>
</p>
<label><%= radio_button_tag 'membership[role_ids][]', role.id, member.roles.include?(role),
:disabled => member.member_roles.detect { |mr| mr.role_id == role.id && !mr.inherited_from.nil? } %> <%= h role %></label><br/>
<% end %></p>
<%= hidden_field_tag 'membership[role_ids][]', '' %>
<p>
<%= submit_tag l(:button_change), :class => "small" %>
<p><%= submit_tag l(:button_change), :class => "small" %>
<%= link_to_function l(:button_cancel),
"$('#member-#{member.id}-roles').show(); $('#member-#{member.id}-roles-form').hide(); return false;"
%>
</p>
%></p>
<% end %>
</td>
<!--modified by huang for: if the user'roles is Manager that he will can't modified himself-->
@ -79,10 +70,8 @@
<%= form_for(@member, {:as => :membership, :url => course_memberships_path(@course), :remote => true, :method => :post}) do |f| %>
<fieldset>
<legend><%= l(:label_member_new) %></legend>
<p>
<%= label_tag "principal_search", l(:label_principal_search) %>
<%= text_field_tag 'principal_search', nil %>
</p>
<p><%= label_tag "principal_search", l(:label_principal_search) %><%= text_field_tag 'principal_search', nil %></p>
<%= javascript_tag "observeSearchfield('principal_search', null, '#{ escape_javascript autocomplete_course_memberships_path(@course, :format => 'js') }')" %>
<div id="principals_for_new_member">
@ -92,12 +81,10 @@
<!--show the roles which will select-->
<p style="padding-top: 5px"><%= l(:label_role_plural) %>:
<% roles.each do |role| %>
<label>
<%= radio_button_tag 'membership[role_ids][]', role.id %>
<%= h role %>
</label>
<% end %>
</p>
<label><%= radio_button_tag 'membership[role_ids][]', role.id %> <%= h role %></label>
<% end %></p>
<p><%= submit_tag l(:button_add), :id => 'member-add-submit' %></p>
</fieldset>
<% end %>