老师配置课程时成员列表显示异常

This commit is contained in:
sw 2014-11-24 15:03:34 +08:00
parent adf75d2e8a
commit f1aca94a30
1 changed files with 38 additions and 13 deletions

View File

@ -20,8 +20,10 @@
<% members.each do |member| %> <% members.each do |member| %>
<% next if member.new_record? %> <% next if member.new_record? %>
<tr id="member-<%= member.id %>" class="<%= cycle 'odd', 'even' %> member"> <tr id="member-<%= member.id %>" class="<%= cycle 'odd', 'even' %> member">
<td class="<%= member.principal.class.name.downcase %>" style="text-align: center"><%= link_to_user member.principal %></td> <td class="<%= member.principal.class.name.downcase %>">
<td class="roles" style="text-align: center"> <%= link_to_user member.principal %>
</td>
<td class="roles">
<span id="member-<%= member.id %>-roles"> <span id="member-<%= member.id %>-roles">
<%= h member.roles.sort.collect(&:to_s).join(', ') %> <%= h member.roles.sort.collect(&:to_s).join(', ') %>
</span> </span>
@ -31,9 +33,14 @@
) do |f| %> ) do |f| %>
<p> <p>
<% roles.each do |role| %> <% roles.each do |role| %>
<label><%= radio_button_tag 'membership[role_ids][]', role.id, member.roles.include?(role), <label>
:disabled => member.member_roles.detect { |mr| mr.role_id == role.id && !mr.inherited_from.nil? } %> <%= h role %></label><br/> <%= radio_button_tag 'membership[role_ids][]', role.id, member.roles.include?(role),
<% end %></p> :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][]', '' %> <%= 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), <%= link_to_function l(:button_cancel),
@ -43,7 +50,9 @@
</td> </td>
<!--modified by huang for: if the user'roles is Manager that he will can't modified himself--> <!--modified by huang for: if the user'roles is Manager that he will can't modified himself-->
<% if member.roles.first.to_s == "Manager" %> <% if member.roles.first.to_s == "Manager" %>
<td class="buttons"></td> <td class="buttons">
</td>
<% else %> <% else %>
<td class="buttons"> <td class="buttons">
<%= link_to_function l(:button_edit), <%= link_to_function l(:button_edit),
@ -61,7 +70,9 @@
</tbody> </tbody>
</table> </table>
<% else %> <% else %>
<p class="nodata"><%= l(:label_no_data) %></p> <p class="nodata">
<%= l(:label_no_data) %>
</p>
<% end %> <% end %>
</div> </div>
@ -69,9 +80,14 @@
<% if roles.any? %> <% if roles.any? %>
<%= form_for(@member, {:as => :membership, :url => course_memberships_path(@course), :remote => true, :method => :post}) do |f| %> <%= form_for(@member, {:as => :membership, :url => course_memberships_path(@course), :remote => true, :method => :post}) do |f| %>
<fieldset> <fieldset>
<legend><%= l(:label_member_new) %></legend> <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') }')" %> <%= javascript_tag "observeSearchfield('principal_search', null, '#{ escape_javascript autocomplete_course_memberships_path(@course, :format => 'js') }')" %>
<div id="principals_for_new_member"> <div id="principals_for_new_member">
@ -83,13 +99,22 @@
<% roles.each do |role| %> <% roles.each do |role| %>
<% if role.id == 10 %> <!-- 默认学生角色 --> <% if role.id == 10 %> <!-- 默认学生角色 -->
<label><%= radio_button_tag 'membership[role_ids][]', role.id, true %> <%= h role %></label> <label>
<%= radio_button_tag 'membership[role_ids][]', role.id, true %>
<%= h role %>
</label>
<% else %> <% else %>
<label><%= radio_button_tag 'membership[role_ids][]', role.id %> <%= h role %></label> <label>
<%= radio_button_tag 'membership[role_ids][]', role.id %>
<%= h role %>
</label>
<% end %> <% end %>
<% end %></p> <% end %>
</p>
<p><%= submit_tag l(:button_add), :id => 'member-add-submit' %></p> <p>
<%= submit_tag l(:button_add), :id => 'member-add-submit' %>
</p>
</fieldset> </fieldset>
<% end %> <% end %>
<% end %> <% end %>