Commit a91bd62c authored by Tugce Nur Tas's avatar Tugce Nur Tas
Browse files

add responsiblity filter and ordering

parent 6b8cffa4
...@@ -39,8 +39,10 @@ class SemesterProcessVolunteersController < ApplicationController ...@@ -39,8 +39,10 @@ class SemesterProcessVolunteersController < ApplicationController
def index def index
authorize SemesterProcessVolunteer authorize SemesterProcessVolunteer
@spvs = SemesterProcessVolunteer.index(Semester.parse(params[:semester])).page(params[:page]) @q = SemesterProcessVolunteer.index(Semester.parse(params[:semester])).ransack(params[:q])
@spvs_sorted = @spvs.sort { |spv1, spv2| spv1.volunteer.contact.full_name <=> spv2.volunteer.contact.full_name} @q.sorts = ['volunteer_contact_last_name asc'] if @q.sorts.empty?
@spvs = @q.result.paginate(page: params[:page])
set_responsibles
end end
def show; end def show; end
...@@ -104,6 +106,19 @@ class SemesterProcessVolunteersController < ApplicationController ...@@ -104,6 +106,19 @@ class SemesterProcessVolunteersController < ApplicationController
end end
end end
def set_responsibles
@responsibles = SemesterProcessVolunteer.joins(responsible: [profile: [:contact]])
.distinct
.select('users.id, contacts.full_name')
.map do |responsible|
{
q: :responsible_id_eq,
text: "Übernommen von #{responsible.full_name}",
value: responsible.id
}
end
end
def semester_process_volunteer_params def semester_process_volunteer_params
params.require(:semester_process_volunteer).permit(:semester) params.require(:semester_process_volunteer).permit(:semester)
end end
......
nav.navbar.section-navigation nav.navbar.section-navigation
hr hr
ul.list-inline ul.list-inline
li= clear_filter_button
li= button_link 'Neuen Semester Prozess erstellen', new_semester_process_path, dimension: 'sm' li= button_link 'Neuen Semester Prozess erstellen', new_semester_process_path, dimension: 'sm'
li= render 'semester_filter' li= render 'semester_filter'
= custom_filter_dropdown('Übernommen',
{ q: :responsible_id_null, text: 'Offen', value: 'true' },
{ q: :responsible_id_not_null, text: 'Übernommen', value: 'true' },
*@responsibles)
hr hr
...@@ -19,10 +19,10 @@ h1= t_title(:index) ...@@ -19,10 +19,10 @@ h1= t_title(:index)
th Bemerkungen th Bemerkungen
th= t_attr(:commited_by) th= t_attr(:commited_by)
th Letzte Bestätigung th Letzte Bestätigung
th Aktionen th= sort_link @q, :responsible_profile_contact_full_name, 'Übernommen'
tbody tbody
- @spvs_sorted.each do |spv| - @spvs.each do |spv|
tr tr
td.index-action-cell.hidden-print td.index-action-cell.hidden-print
= button_link icon_span(:edit), review_semester_semester_process_volunteer_path(spv), title: 'Bearbeiten' = button_link icon_span(:edit), review_semester_semester_process_volunteer_path(spv), title: 'Bearbeiten'
......
...@@ -24,4 +24,12 @@ class SemesterProcessVolunteerActionsTest < ApplicationSystemTestCase ...@@ -24,4 +24,12 @@ class SemesterProcessVolunteerActionsTest < ApplicationSystemTestCase
assert page.has_text? "Übernommen durch #{@superadmin.email}"\ assert page.has_text? "Übernommen durch #{@superadmin.email}"\
" am #{I18n.l(@spv1.responsibility_taken_at.to_date)}" " am #{I18n.l(@spv1.responsibility_taken_at.to_date)}"
end end
test 'take_feedback_responsibility_filter_works' do
# TODO: add filter test
# filter: Alle
# filter: Offen
# filter: Übernommen
# filter: Übernommen von
end
end end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment