mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-18 14:11:10 +00:00
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();
|
||||
Loading…
Add table
Add a link
Reference in a new issue