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