Skip to content

Commit

Permalink
admin roles
Browse files Browse the repository at this point in the history
  • Loading branch information
qinmingyuan committed Jan 8, 2025
1 parent d07243c commit 138f74a
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 26 deletions.
5 changes: 3 additions & 2 deletions app/controllers/org/admin/members_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Org
class Admin::MembersController < Admin::BaseController
before_action :set_member, only: [:show, :edit, :update, :mock, :profile, :token, :destroy]
before_action :set_member, only: [:show, :edit, :update, :mock, :edit_roles, :token, :destroy]
before_action :set_new_member, only: [:new, :create, :options]

def index
Expand Down Expand Up @@ -41,7 +41,8 @@ def options
@member_department = @member.member_departments.build(department_id: params[:node_id])
end

def profile
def edit_roles
@roles = Roled::MemberRole.all
end

def edit
Expand Down
3 changes: 0 additions & 3 deletions app/views/org/admin/members/_base/_index_tbody.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
<% model.roles.pluck(:name).each do |role| %>
<span class="tag"><%= role %></span>
<% end %>
<%= link_to({ controller: 'roled/admin/who_roles', action: 'show', who_type: 'Org::Member', who_id: model.id }, data: { turbo_frame: 'modal' }) do %>
<i class="fa-solid fa-user-shield"></i>
<% end %>
</div>
</td>
<td>
Expand Down
11 changes: 7 additions & 4 deletions app/views/org/admin/members/_base/_index_tr.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
<%= button_to({ action: 'show', id: model.id }, aria: { label: t('.show.title') }, class: 'button is-small is-rounded is-light') do %>
<i class="fa-solid fa-circle-info text-info"></i>
<% end %>
<%= link_to({ action: 'profile', id: model.id }, aria: { label: t('.profile') }, class: 'button is-small is-rounded is-light') do %>
<i class="fa-solid fa-id-card text-info"></i>
<% end %>

<%= button_to({ action: 'edit', id: model.id }, aria: { label: t('.edit.title') }, class: 'button is-small is-rounded is-light') do %>
<i class="fa-solid fa-pencil text-link"></i>
<% end %>
<%= button_to({ action: 'destroy', id: model.id }, method: :delete, aria: { label: t('.destroy.title') }, class: 'button is-small is-rounded is-light', form: { data: { turbo_confirm: t('.destroy.confirm') } }) do %>
<i class="fa-solid fa-trash text-danger"></i>
<% end %>
<%# link_to 'tutorials', admin_tutorials_path(member_id: model.id), class: 'ui mini circular button' %>
</div>
<div data-show-target="item" class="visibility-hidden">
<%= button_to({ action: 'edit_roles', id: model.id }, class: 'button is-small is-rounded is-light') do %>
<i class="fa-solid fa-user-shield"></i>
<span class="ml-1"><%= t('.edit_roles.title') %></span>
<% end %>
</div>
</td>
</tr>
8 changes: 8 additions & 0 deletions app/views/org/admin/members/_role_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<%= form_with theme: 'modal', model: @member, url: { action: 'update' } do |f| %>
<%= render 'modal_header' %>
<div class="modal-card-body">
<%= render 'error_messages', target: @member %>
<%= f.collection_check_boxes :role_ids, @roles, :id, :name %>
</div>
<%= f.submit %>
<% end %>
1 change: 1 addition & 0 deletions app/views/org/admin/members/edit_roles.turbo_stream.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= turbo_stream.append 'body', partial: 'role_form', layout: 'modal_form' %>
16 changes: 0 additions & 16 deletions app/views/org/admin/members/profile.html.erb

This file was deleted.

1 change: 0 additions & 1 deletion app/views/org/admin/members/profile.turbo_stream.erb

This file was deleted.

0 comments on commit 138f74a

Please sign in to comment.