Autolab icon indicating copy to clipboard operation
Autolab copied to clipboard

Option to delete on "Manage users" view

Open jez opened this issue 9 years ago • 3 comments

screenshot 2015-04-29 19 56 43

We should add a button (or checkbox) that lets admins delete (or mass delete) users from the "Manage users" screen. Right now, you have to click on the user, then click Edit Information, then finally you have a button that lets you delete a user.

jez avatar Apr 30 '15 01:04 jez

Conversely, maybe it's good that it's hard to delete users, seeing as that's not something that should accidentally happen.

dlbucci avatar Apr 30 '15 01:04 dlbucci

Sure, but it's also not obvious that you should have to edit a user's information for a delete button to show up. Maybe we move the delete button forward one view in the chain: you still have to click on the user, but you don't have to click all the way to edit information.

jez avatar Apr 30 '15 01:04 jez

Suggestion:

(Note: confirmation message is currently broken, the confirm has to be wrapped by a data)

diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb
index 8c99a716..31855b33 100755
--- a/app/views/users/edit.html.erb
+++ b/app/views/users/edit.html.erb
@@ -23,9 +23,3 @@
 
   <%= f.submit 'Save Changes', { :class=>"btn primary"} %>
 <% end %>
-
-<% if current_user.administrator? %>
-<br> <br><hr><br>
-<h3> Admin Only</h3>
-  <%= link_to raw('<span class="btn">Delete User</span>'), user_path(@user), method: :delete, confirm: "Are you sure!?" %>
-<% end %> 
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
index f07e9a64..0c4bc5ee 100644
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -20,7 +20,10 @@
     <% end %>
   </li>
 </ul>
-<%= link_to raw('<span class="btn primary">Edit Information</span>'), edit_user_path(@user) %><br>
+<%= link_to raw('<span class="btn primary">Edit Information</span>'), edit_user_path(@user) %>
+<% if current_user.administrator? %>
+  <%= link_to raw('<span class="btn">Delete User</span>'), user_path(@user), method: :delete, data: {confirm: "Are you sure?"} %>
+<% end %>
+<br>
 <% if @user == current_user %>
   <hr>
   <h4>Private Settings</h4>

damianhxy avatar Jun 09 '22 04:06 damianhxy