Roles into their own controller. Rework interface. Add flash messages to ajax calls. Add description to roles. Possible to edit roles in use.
This commit is contained in:
parent
eda5c2bc07
commit
ccd7ecbb90
59 changed files with 618 additions and 356 deletions
15
app/views/admin/roles/_form.html.haml
Normal file
15
app/views/admin/roles/_form.html.haml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
.row
|
||||
.col-md-12
|
||||
.page-header
|
||||
%h2
|
||||
Role
|
||||
= @role.name.titleize
|
||||
.text-muted
|
||||
= @role.description
|
||||
|
||||
= semantic_form_for @role, url: admin_conference_role_path(@conference.short_title, @role.name) do |f|
|
||||
.row
|
||||
.col-md-5
|
||||
= f.input :description
|
||||
|
||||
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }
|
||||
20
app/views/admin/roles/_users.html.haml
Normal file
20
app/views/admin/roles/_users.html.haml
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
.page-header
|
||||
%h3 Users (#{users.length})
|
||||
- if users.present?
|
||||
%table.table.table-striped.table-bordered.table-hover.datatable#users
|
||||
%thead
|
||||
%th.col-md-1
|
||||
%th ID
|
||||
%th Name
|
||||
%th Email
|
||||
%tbody
|
||||
- users.each do |user|
|
||||
%tr
|
||||
%td.text-right
|
||||
= hidden_field_tag "role[user_ids][]", nil
|
||||
= check_box_tag @conference.short_title, @role.id, (@role.user_ids.include? user.id), method: :post, url: "/admin/conference/#{@conference.short_title}/roles/#{@role.name}/toggle_user?user[email]=#{user.email}&user[state]=", class: 'switch-checkbox', data: { size: 'small', off_color: 'warning', on_text: 'Yes', off_text: 'No' }
|
||||
%td= user.id
|
||||
%td= user.name
|
||||
%td= user.email
|
||||
- else
|
||||
%h5 No users found!
|
||||
31
app/views/admin/roles/index.html.haml
Normal file
31
app/views/admin/roles/index.html.haml
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
.row
|
||||
.col-md-12.page-header
|
||||
%h2
|
||||
Roles
|
||||
|
||||
.text-muted
|
||||
The available roles for the conference
|
||||
|
||||
.col-md-12
|
||||
%table.table.table-bordered.table-striped.table-hover.datatable#roles
|
||||
%thead
|
||||
%th ID
|
||||
%th Name
|
||||
%th Description
|
||||
%th Users
|
||||
%th Actions
|
||||
%tbody
|
||||
- @roles.each do |role|
|
||||
%tr
|
||||
%td= role.id
|
||||
%td= role.name.titleize
|
||||
%td= role.description
|
||||
%td
|
||||
= role.users.pluck(:name).first(5).join ', '
|
||||
- if role.users.count > 5
|
||||
= link_to '...', admin_conference_role_path(@conference.short_title, role.name)
|
||||
%td
|
||||
.btn-group
|
||||
= link_to 'Users', admin_conference_role_path(@conference.short_title, role.name), class: 'btn btn-success'
|
||||
- if can? :edit, role
|
||||
= link_to 'Edit', edit_admin_conference_role_path(@conference.short_title, role.name), class: 'btn btn-primary'
|
||||
27
app/views/admin/roles/show.html.haml
Normal file
27
app/views/admin/roles/show.html.haml
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
.unobtrusive-flash-container
|
||||
.row
|
||||
.col-md-12
|
||||
.page-header
|
||||
%h2
|
||||
Role
|
||||
= @role.name.titleize
|
||||
- if can? :edit, @role
|
||||
= link_to 'Edit', edit_admin_conference_role_path(@conference.short_title, @role.name), class: 'btn btn-primary pull-right'
|
||||
.text-muted
|
||||
= @role.description
|
||||
|
||||
.row.col-md-3
|
||||
- if ( can? :toggle_user, @role ) && !@role.new_record?
|
||||
|
||||
= semantic_form_for :user, url: toggle_user_admin_conference_role_path(@conference.short_title, @role.name), method: :post do |u|
|
||||
|
||||
= u.label 'Add user by email: '
|
||||
.input-group
|
||||
= u.input :email, label: false, placeholder: "User's email"
|
||||
.input-group-btn
|
||||
= u.submit 'Add', id: 'user-add', class: 'btn btn-primary'
|
||||
|
||||
.row
|
||||
.col-md-12
|
||||
#users_area
|
||||
= render partial: 'users', locals: { users: @users }
|
||||
1
app/views/admin/roles/toggle_user.js.erb
Normal file
1
app/views/admin/roles/toggle_user.js.erb
Normal file
|
|
@ -0,0 +1 @@
|
|||
$(".alert").remove();
|
||||
Loading…
Add table
Add a link
Reference in a new issue