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
|
|
@ -1,29 +0,0 @@
|
|||
#myroles.roles
|
||||
- unless @role.blank?
|
||||
%p.text-muted
|
||||
= @role.first.description
|
||||
|
||||
%hr
|
||||
.row
|
||||
.col-md-6
|
||||
= semantic_form_for(:user, url: add_user_admin_conference_path(@conference.short_title, role: @selection), remote: true) do |f|
|
||||
%h4
|
||||
= f.input :email, label: "Add role '#{@selection.humanize.titleize}' to user: ", placeholder: "User's email", input_html: { required: 'required' }
|
||||
= f.action :submit, as: :button, label: 'Add User', button_html: {value: 'Add', class: 'btn btn-primary'}
|
||||
.row
|
||||
.col-md-12
|
||||
%h3 Users with role #{@selection.humanize.titleize}
|
||||
%table.table.table-striped.table-bordered.table-hover
|
||||
%thead
|
||||
%th ID
|
||||
%th Name
|
||||
%th Email
|
||||
%tbody
|
||||
- @role_users[@selection].each do |user|
|
||||
%tr
|
||||
%td
|
||||
= link_to remove_user_admin_conference_path(@conference.short_title, user_id: user.id, role: @selection), method: :delete, remote: true, title: 'Remove user' do
|
||||
%i{class: 'fa fa-times'}
|
||||
= user.id
|
||||
%td= user.name
|
||||
%td= user.email
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
.row
|
||||
.col-md-6
|
||||
= semantic_form_for(:user, url: roles_admin_conference_path(@conference.short_title), remote: true) do |f|
|
||||
%h4
|
||||
= f.input :roles, collection: @roles, label: 'Show users for role: '
|
||||
|
||||
= render partial: 'roles'
|
||||
|
||||
:javascript
|
||||
|
||||
$("#user_roles_input").change(function () {
|
||||
|
||||
var url = document.forms[0].action;
|
||||
var selected_role = $(this).find('option:selected').attr('value');
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: "POST",
|
||||
data: {user: { roles: selected_role } },
|
||||
dataType: "script"
|
||||
});
|
||||
});
|
||||
|
|
@ -1 +0,0 @@
|
|||
$('#myroles').html("<%= escape_javascript(render partial: 'roles').html_safe %>");
|
||||
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();
|
||||
|
|
@ -59,29 +59,31 @@
|
|||
- if can? :update, @conference.lodgings.build
|
||||
%li{ class: active_nav_li(admin_conference_lodgings_path(@conference.short_title)) }
|
||||
= link_to 'Lodgings', admin_conference_lodgings_path(@conference.short_title)
|
||||
- if can? :show, @conference.program
|
||||
%li{:class=> "#{active_nav_li(admin_conference_program_path(@conference.short_title))}"}
|
||||
= link_to admin_conference_program_path(@conference.short_title) do
|
||||
%span.fa.fa-calendar
|
||||
Program
|
||||
%ul
|
||||
- if can? :update, Cfp.new(program_id: @conference.program.id)
|
||||
%li{:class=> active_nav_li(admin_conference_program_cfp_path(@conference.short_title))}
|
||||
= link_to 'Call for Papers', admin_conference_program_cfp_path(@conference.short_title)
|
||||
- if can? :update, @conference.program.events.build
|
||||
%li{:class=> active_nav_li(admin_conference_program_events_path(@conference.short_title))}
|
||||
= link_to 'Events', admin_conference_program_events_path(@conference.short_title)
|
||||
- if can? :update, @conference.program.tracks.build
|
||||
%li{:class=> active_nav_li(admin_conference_program_tracks_path(@conference.short_title))}
|
||||
= link_to 'Tracks', admin_conference_program_tracks_path(@conference.short_title)
|
||||
- if can? :update, @conference.program.event_types.build
|
||||
%li{:class=> active_nav_li(admin_conference_program_event_types_path(@conference.short_title))}
|
||||
= link_to 'Event Types', admin_conference_program_event_types_path(@conference.short_title)
|
||||
- if can? :update, @conference.program.difficulty_levels.build, conference_id: @conference.id
|
||||
%li{:class=> active_nav_li(admin_conference_program_difficulty_levels_path(@conference.short_title))}
|
||||
= link_to 'Difficulty Levels', admin_conference_program_difficulty_levels_path(@conference.short_title)
|
||||
- if can? :update, @conference.program.events.build
|
||||
%li{class: active_nav_li(admin_conference_schedule_path(@conference.short_title))}
|
||||
= link_to 'Schedule', admin_conference_schedule_path(@conference.short_title), target: '_blank'
|
||||
- if @conference.program
|
||||
%ul
|
||||
- if can? :update, Cfp.new(program_id: @conference.program.id)
|
||||
%li{:class=> active_nav_li(admin_conference_program_cfp_path(@conference.short_title))}
|
||||
= link_to 'Call for Papers', admin_conference_program_cfp_path(@conference.short_title)
|
||||
- if can? :update, @conference.program.events.build
|
||||
%li{:class=> active_nav_li(admin_conference_program_events_path(@conference.short_title))}
|
||||
= link_to 'Events', admin_conference_program_events_path(@conference.short_title)
|
||||
- if can? :update, @conference.program.tracks.build
|
||||
%li{:class=> active_nav_li(admin_conference_program_tracks_path(@conference.short_title))}
|
||||
= link_to 'Tracks', admin_conference_program_tracks_path(@conference.short_title)
|
||||
- if can? :update, @conference.program.event_types.build
|
||||
%li{:class=> active_nav_li(admin_conference_program_event_types_path(@conference.short_title))}
|
||||
= link_to 'Event Types', admin_conference_program_event_types_path(@conference.short_title)
|
||||
- if can? :update, @conference.program.difficulty_levels.build, conference_id: @conference.id
|
||||
%li{:class=> active_nav_li(admin_conference_program_difficulty_levels_path(@conference.short_title))}
|
||||
= link_to 'Difficulty Levels', admin_conference_program_difficulty_levels_path(@conference.short_title)
|
||||
- if can? :update, @conference.program.events.build
|
||||
%li{class: active_nav_li(admin_conference_schedule_path(@conference.short_title))}
|
||||
= link_to 'Schedule', admin_conference_schedule_path(@conference.short_title), target: '_blank'
|
||||
|
||||
- if can? :update, Registration.new(conference_id: @conference.id)
|
||||
%li{:class=> active_nav_li(admin_conference_registrations_path(@conference.short_title))}
|
||||
|
|
@ -129,8 +131,8 @@
|
|||
= link_to(admin_conference_emails_path(@conference.short_title)) do
|
||||
%span.fa.fa-envelope
|
||||
E-Mails
|
||||
- if can? :manage, @conference
|
||||
%li{:class=> active_nav_li(roles_admin_conference_path(@conference.short_title))}
|
||||
= link_to(roles_admin_conference_path(@conference.short_title)) do
|
||||
- if can? :index, Role.new(resource: @conference)
|
||||
%li{:class=> active_nav_li(admin_conference_roles_path(@conference.short_title))}
|
||||
= link_to(admin_conference_roles_path(@conference.short_title)) do
|
||||
%span.fa.fa-group
|
||||
Roles
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
%span.fa.fa-cog
|
||||
Manage
|
||||
= conference.short_title
|
||||
- if (current_user.is_admin) || (current_user.has_role? :organizer, :any)
|
||||
- if can? :create, Conference
|
||||
%li
|
||||
= link_to(new_admin_conference_path) do
|
||||
%span.fa.fa-plus
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue