Commit 1c80bf2b authored by Kaspar Vollenweider's avatar Kaspar Vollenweider 👻 Committed by Kaspar
Browse files

adding ransack filter and sorting to volunteers index

parent bf571fef
......@@ -4,8 +4,9 @@ class VolunteersController < ApplicationController
before_action :set_state, only: [:update]
def index
@q = Volunteer.ransack(params[:q])
@volunteers = @q.result(distinct: true)
ransack_params = params[:q] || {}
@q = Volunteer.ransack(ransack_params)
@volunteers = @q.result
end
def show; end
......@@ -61,7 +62,7 @@ class VolunteersController < ApplicationController
end
def filter_params
params.require(:volunteer).permit(:q)
params.require(:volunteer).permit(:commit, q: [:gender, :state])
end
def volunteer_params
......
tr
td = volunteer.full_name
td = volunteer.date_of_birth
td = l(volunteer.date_of_birth) if volunteer.date_of_birth.present?
td = country(volunteer.nationality)
td = volunteer.created_at
td = l(volunteer.created_at)
td = t("gender.#{volunteer.gender}") unless volunteer.gender.blank?
td = t("simple_form.options.volunteer.state.#{volunteer.state}")
td = link_to t_action(:show), volunteer
......
.row
.col-xs-12
h1= t('volunteers')
.row
= search_form_for @q, builder: SimpleForm::FormBuilder do |f|
.col-xs-6.col-md-3
= f.input :state_cont, collection: Volunteer.state_collection,
include_blank: true, html: {class: 'input-group input-group-sm' }, input_html: { onchange: 'this.form.submit();', class: 'input-group input-group-xs' }
.row
.col-xs-12
table.table.table-striped
thead
tr
th= t_attr(:full_name)
th= sort_link @q, :full_name
th= sort_link @q, :date_of_birth
th= t_attr(:nationality)
th= sort_link @q, :nationality
th= sort_link @q, :created_at
th= sort_link @q, :gender
th= sort_link @q, :state
......
require_relative 'boot'
require File.expand_path('../boot', __FILE__)
ENV['RANSACK_FORM_BUILDER'] = '::SimpleForm::FormBuilder'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
......
......@@ -117,6 +117,7 @@ de:
training: Bildung
woman: Frau
zip: Postleitzahl
created_at: Erstellt am
errors:
models:
profile:
......@@ -378,6 +379,8 @@ de:
region: In welcher Region können Sie sich Ihren Einsatz vorstellen?
skills: Berufliche Kompetenzen, die Sie einbringen könnten?
strengths: Wo sehen Sie Ihre Stärken? (soziale Kompetenzen, die Sie in FW-Arbeit einbringen könnten)
q:
state_cont: Status
"no": 'Nein'
options:
client:
......@@ -433,6 +436,13 @@ de:
registered: interessiert / angemeldet
rejected: Absage
reserved: kontaktiert / für Gespräch eingeladen
q:
state_cont:
active: aktiv / im Einsatz
finished: ausgetreten
registered: interessiert / angemeldet
rejected: Absage
reserved: kontaktiert / für Gespräch eingeladen
placeholders:
required:
mark: '*'
......@@ -452,6 +462,8 @@ de:
thank_you: "Vielen Dank \U0001F389"
time:
formats:
default:
"%d. %B %Y %H:%M"
devise:
mailer:
invitation_instructions:
......
......@@ -61,6 +61,10 @@ en:
crud:
title:
add: 'Add %{model}'
datetime:
formats:
default:
'%s %B %Y'
date:
formats:
default:
......
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