cooperative: manage cannot delete self

competitions
p31729568 5 years ago
parent f61ff70159
commit a909a8ee15

@ -48,7 +48,7 @@ class Cooperative::BaseController < ApplicationController
return if request.format.symbol != :js
return if response.content_type != 'text/javascript'
path = Rails.root.join('app/views/shared/after_render_js_hook.js.erb')
path = Rails.root.join('app/views/cooperative/shared/after_render_js_hook.js.erb')
return unless File.exists?(path)
append_js = ERB.new(File.open(path).read).result

@ -10,6 +10,7 @@ class Cooperative::LaboratoryUsersController < Cooperative::BaseController
end
def destroy
return render_error('不能删除自己', type: :notify) if current_laboratory_user.user_id == current_user.id
current_laboratory_user.destroy!
render_delete_success

@ -7,7 +7,7 @@
<%= javascript_void_link '添加管理员', class: 'btn btn-primary btn-sm', data: { toggle: 'modal', target: '.cooperative-add-laboratory-user-modal'} %>
</div>
<div class="box users-list-container">
<div class="box laboratory-user-list-container">
<%= render partial: 'cooperative/laboratory_users/shared/list', locals: { laboratory_users: @laboratory_users } %>
</div>

@ -0,0 +1 @@
$('.laboratory-user-list-container').html("<%= j(render partial: 'cooperative/laboratory_users/shared/list', locals: { laboratory_users: @laboratory_users }) %>");

@ -28,7 +28,9 @@
<td><%= overflow_hidden_span display_text(user.phone), width: 100 %></td>
<td><%= [user.school_name.presence, user.department_name.presence].compact.join('-') %></td>
<td class="action-container">
<%= delete_link '删除', cooperative_laboratory_user_path(laboratory_user, element: ".laboratory-user-item-#{laboratory_user.id}"), class: 'delete-laboratory-user-action' %>
<% if current_user.id != laboratory_user.user_id %>
<%= delete_link '删除', cooperative_laboratory_user_path(laboratory_user, element: ".laboratory-user-item-#{laboratory_user.id}"), class: 'delete-laboratory-user-action' %>
<% end %>
</td>
</tr>
<% end %>

Loading…
Cancel
Save