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
def index
authorize SemesterProcessVolunteer
@spvs = SemesterProcessVolunteer.index(Semester.parse(params[:semester])).page(params[:page])
@spvs_sorted = @spvs.sort { |spv1, spv2| spv1.volunteer.contact.full_name <=> spv2.volunteer.contact.full_name}
@q = SemesterProcessVolunteer.index(Semester.parse(params[:semester])).ransack(params[:q])
@q.sorts = ['volunteer_contact_last_name asc'] if @q.sorts.empty?
@spvs = @q.result.paginate(page: params[:page])
set_responsibles
end
def show; end
......@@ -104,6 +106,19 @@ class SemesterProcessVolunteersController < ApplicationController
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
params.require(:semester_process_volunteer).permit(:semester)
end
......
nav.navbar.section-navigation
hr
ul.list-inline
li= clear_filter_button
li= button_link 'Neuen Semester Prozess erstellen', new_semester_process_path, dimension: 'sm'
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
......@@ -19,10 +19,10 @@ h1= t_title(:index)
th Bemerkungen
th= t_attr(:commited_by)
th Letzte Bestätigung
th Aktionen
th= sort_link @q, :responsible_profile_contact_full_name, 'Übernommen'
tbody
- @spvs_sorted.each do |spv|
- @spvs.each do |spv|
tr
td.index-action-cell.hidden-print
= button_link icon_span(:edit), review_semester_semester_process_volunteer_path(spv), title: 'Bearbeiten'
......
......@@ -24,4 +24,12 @@ class SemesterProcessVolunteerActionsTest < ApplicationSystemTestCase
assert page.has_text? "Übernommen durch #{@superadmin.email}"\
" am #{I18n.l(@spv1.responsibility_taken_at.to_date)}"
end
test 'take_feedback_responsibility_filter_works' do
# TODO: add filter test
# filter: Alle
# filter: Offen
# filter: Übernommen
# filter: Übernommen von
end
end
Markdown is supported
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