Skip to content
Snippets Groups Projects
Commit 780c30dd authored by pabois's avatar pabois
Browse files

interfaces

parent 3e748e6f
No related branches found
No related tags found
No related merge requests found
Showing
with 69 additions and 147 deletions
......@@ -25,7 +25,7 @@ class Admin::Education::Program::TeachersController < Admin::Education::Program:
def create
if @involvement.save
redirect_to admin_education_program_path(@program), notice: t('admin.successfully_created_html', model: @involvement.to_s)
redirect_to admin_education_program_teachers_path(@program), notice: t('admin.successfully_created_html', model: @involvement.to_s)
else
breadcrumb
render :new, status: :unprocessable_entity
......@@ -34,7 +34,7 @@ class Admin::Education::Program::TeachersController < Admin::Education::Program:
def update
if @involvement.update(involvement_params)
redirect_to admin_education_program_path(@program), notice: t('admin.successfully_updated_html', model: @involvement.to_s)
redirect_to admin_education_program_teachers_path(@program), notice: t('admin.successfully_updated_html', model: @involvement.to_s)
else
breadcrumb
render :edit, status: :unprocessable_entity
......
<%= simple_form_for [:admin, involvement],
url: involvement.new_record? ? admin_education_program_role_people_path(@role, { program_id: @program.id })
: admin_education_program_role_person_path(involvement, { program_id: @program.id, role_id: @role.id }) do |f| %>
<div class="card flex-fill w-100">
<div class="card-header">
<h5 class="card-title mb-0"><%= t('admin.infos') %></h5>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-6">
<% used_person_ids = @role.involvements.where.not(id: involvement.id).pluck(:person_id) %>
<%= f.association :person, collection: @available_people %>
</div>
<div class="col-md-6">
<%= f.input :description %>
</div>
</div>
</div>
</div>
<% content_for :action_bar_right do %>
<%= submit f %>
<% end %>
<% end %>
<% if involvements.any? %>
<table class="table">
<thead>
<tr>
<% if can? :reorder, University::Role %>
<th width="20" class="ps-0">&nbsp;</th>
<% end %>
<th class="ps-0"><%= University::Person.model_name.human %></th>
<th></th>
</tr>
</thead>
<tbody data-sortable data-sort-url="<%= reorder_admin_education_program_role_people_path(@role, { program_id: @program.id }) %>">
<% involvements.each do |involvement| %>
<tr data-id="<%= involvement.id %>">
<% if can? :reorder, University::Role %>
<td><i class="fa fa-bars handle"></i></td>
<% end %>
<td class="ps-0">
<%= link_to_if can?(:read, involvement.person),
involvement.person,
[:admin, involvement.person] %>
</td>
<td class="text-end pe-0">
<div class="btn-group" role="group">
<%= link_to t('edit'),
edit_admin_education_program_role_person_path(involvement, { program_id: @program.id, role_id: @role.id }),
class: button_classes if can?(:edit, involvement) %>
<%= link_to t('delete'),
admin_education_program_role_person_path(involvement, { program_id: @program.id, role_id: @role.id }),
method: :delete,
data: { confirm: t('please_confirm') },
class: button_classes_danger if can?(:destroy, involvement) %>
</div>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<% content_for :title, @involvement %>
<%= render 'form', involvement: @involvement %>
<% content_for :title, University::Person.model_name.human %>
<%= render 'form', involvement: @involvement %>
<% content_for :title, University::Role.model_name.human(count: 2) %>
<%= link_to t('create'), new_admin_education_program_role_path(program_id: @program.id), class: button_classes %>
<%= render 'admin/education/program/roles/list', roles: @roles %>
<% content_for :action_bar_right do %>
<%= link_to t('add'), new_admin_education_program_role_path(program_id: @program.id), class: button_classes %>
<% end %>
<% content_for :title, @role %>
<%= link_to t('create'), new_admin_education_program_role_person_path(program_id: @program.id, role_id: @role.id), class: button_classes %>
<%= render 'admin/education/program/role/people/list', involvements: @involvements %>
<% if @involvements.any? %>
<table class="table">
<thead>
<tr>
<% if can? :reorder, University::Role %>
<th width="20" class="ps-0">&nbsp;</th>
<% end %>
<th class="ps-0"><%= University::Person.model_name.human %></th>
</tr>
</thead>
<tbody data-sortable data-sort-url="<%= reorder_admin_education_program_role_people_path(@role, { program_id: @program.id }) %>">
<% @involvements.each do |involvement| %>
<tr data-id="<%= involvement.id %>">
<% if can? :reorder, University::Role %>
<td><i class="fa fa-bars handle"></i></td>
<% end %>
<td class="ps-0">
<%= link_to_if can?(:read, involvement.person),
involvement.person,
[:admin, involvement.person] %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<% content_for :action_bar_right do %>
<%= link_to t('edit'),
......
<% content_for :title, Education::Program.human_attribute_name("teachers") %>
<%= link_to t('create'), new_admin_education_program_teacher_path(program_id: @program.id), class: button_classes %>
<%= render 'admin/education/program/teachers/list', involvements: @involvements %>
<% content_for :action_bar_right do %>
<%= link_to t('add'), new_admin_education_program_teacher_path(program_id: @program.id), class: button_classes %>
<% end %>
<%= simple_form_for [:admin, involvement],
url: involvement.new_record? ? admin_education_school_role_people_path(@role, { school_id: @school.id })
: admin_education_school_role_person_path(involvement, { school_id: @school.id, role_id: @role.id }) do |f| %>
<div class="card flex-fill w-100">
<div class="card-header">
<h5 class="card-title mb-0"><%= t('admin.infos') %></h5>
</div>
<div class="card-body">
<%= f.association :person, collection: @available_people %>
</div>
</div>
<% content_for :action_bar_right do %>
<%= submit f %>
<% end %>
<% end %>
<% if involvements.any? %>
<table class="table">
<thead>
<tr>
<% if can? :reorder, University::Person::Involvement %>
<th width="20" class="ps-0">&nbsp;</th>
<% end %>
<th class="ps-0"><%= University::Person.model_name.human %></th>
<th></th>
</tr>
</thead>
<tbody data-sortable data-sort-url="<%= reorder_admin_education_school_role_people_path(@role, { school_id: @school.id }) %>">
<% involvements.each do |involvement| %>
<tr data-id="<%= involvement.id %>">
<% if can? :reorder, University::Person::Involvement %>
<td><i class="fa fa-bars handle"></i></td>
<% end %>
<td class="ps-0">
<%= link_to_if can?(:read, involvement.person),
involvement.person,
[:admin, involvement.person] %>
</td>
<td class="text-end pe-0">
<div class="btn-group" role="group">
<%= link_to t('edit'),
edit_admin_education_school_role_person_path(involvement, { school_id: @school.id, role_id: @role.id }),
class: button_classes if can?(:edit, involvement) %>
<%= link_to t('delete'),
admin_education_school_role_person_path(involvement, { school_id: @school.id, role_id: @role.id }),
method: :delete,
data: { confirm: t('please_confirm') },
class: button_classes_danger if can?(:destroy, involvement) %>
</div>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<% content_for :title, @involvement %>
<%= render 'form', involvement: @involvement %>
<% content_for :title, University::Person.model_name.human %>
<%= render 'form', involvement: @involvement %>
<% content_for :title, @role %>
<%= link_to t('create'), new_admin_education_school_role_person_path(school_id: @school.id, role_id: @role.id), class: button_classes %>
<%= render 'admin/education/school/role/people/list', involvements: @involvements %>
<% if @involvements.any? %>
<table class="table">
<thead>
<tr>
<% if can? :reorder, University::Person::Involvement %>
<th width="20" class="ps-0">&nbsp;</th>
<% end %>
<th class="ps-0"><%= University::Person.model_name.human %></th>
</tr>
</thead>
<tbody data-sortable data-sort-url="<%= reorder_admin_education_school_role_people_path(@role, { school_id: @school.id }) %>">
<% @involvements.each do |involvement| %>
<tr data-id="<%= involvement.id %>">
<% if can? :reorder, University::Person::Involvement %>
<td><i class="fa fa-bars handle"></i></td>
<% end %>
<td class="ps-0">
<%= link_to_if can?(:read, involvement.person),
involvement.person,
[:admin, involvement.person] %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<% content_for :action_bar_right do %>
<%= link_to t('edit'),
......
......@@ -22,7 +22,7 @@
<td class="ps-0">
<%= link_to_if can?(:read, role),
role,
admin_education_school_role_path(role, { school_id: @school.id }) %>
edit_admin_education_school_role_path(role, { school_id: @school.id }) %>
</td>
<td>
<ul>
......
......@@ -2,25 +2,19 @@ namespace :education do
resources :teachers, only: [:index, :show]
resources :schools do
resources :roles, controller: 'school/roles' do
resources :people, controller: 'school/role/people', except: [:index, :show] do
collection do
post :reorder
end
resources :people, controller: 'school/role/people', only: [] do
post :reorder, on: :collection
end
collection do
post :reorder
end
end
resources :administrators, controller: 'school/administrators', except: [:index, :show]
end
resources :programs do
resources :roles, controller: 'program/roles' do
resources :people, controller: 'program/role/people', except: [:index, :show] do
collection do
post :reorder
end
resources :people, controller: 'program/role/people', only: [] do
post :reorder, on: :collection
end
collection do
post :reorder
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment