Merge pull request #10041 from demarches-simplifiees/10029-filter-kind-usager
ETQ admin, je peux filtrer toutes les démarches par type d'usager
This commit is contained in:
commit
1024557081
7 changed files with 67 additions and 1 deletions
|
@ -421,6 +421,7 @@ module Administrateurs
|
|||
procedures_result = procedures_result.where('published_at >= ?', filter.from_publication_date) if filter.from_publication_date.present?
|
||||
procedures_result = procedures_result.where(service: service) if filter.service_siret.present?
|
||||
procedures_result = procedures_result.where(service: services) if services
|
||||
procedures_result = procedures_result.where(for_individual: filter.for_individual) if filter.for_individual.present?
|
||||
procedures_result = procedures_result.where('unaccent(libelle) ILIKE unaccent(?)', "%#{filter.libelle}%") if filter.libelle.present?
|
||||
procedures_sql = procedures_result.to_sql
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ class ProceduresFilter
|
|||
|
||||
params[:zone_ids] = admin.zones.pluck(:id) if params[:zone_ids] == 'admin_default'
|
||||
|
||||
@params = params.permit(:page, :libelle, :email, :from_publication_date, :service_siret, :service_departement, :template, tags: [], zone_ids: [], statuses: [])
|
||||
@params = params.permit(:page, :libelle, :email, :from_publication_date, :service_siret, :service_departement, :template, tags: [], zone_ids: [], statuses: [], kind_usagers: [])
|
||||
end
|
||||
|
||||
def admin_zones
|
||||
|
@ -35,6 +35,21 @@ class ProceduresFilter
|
|||
params[:tags].compact_blank.uniq if params[:tags].present?
|
||||
end
|
||||
|
||||
def kind_usagers
|
||||
params[:kind_usagers].compact_blank if params[:kind_usagers].present?
|
||||
end
|
||||
|
||||
def kind_usager_filtered?(kind_usager)
|
||||
kind_usagers&.include?(kind_usager)
|
||||
end
|
||||
|
||||
def for_individual
|
||||
kind_usagers = params[:kind_usagers]
|
||||
if kind_usagers.present?
|
||||
kind_usagers.map { |k| k == "individual" }.uniq
|
||||
end
|
||||
end
|
||||
|
||||
def template?
|
||||
ActiveRecord::Type::Boolean.new.cast(params[:template])
|
||||
end
|
||||
|
|
|
@ -36,6 +36,10 @@
|
|||
.selected-statuses.fr-mb-2w
|
||||
- @filter.statuses.each do |status|
|
||||
= link_to status, all_admin_procedures_path(@filter.without(:statuses, status)), class: 'fr-tag fr-tag--dismiss fr-mb-1w'
|
||||
- if @filter.kind_usagers.present?
|
||||
.selected-kind_usagers.fr-mb-2w
|
||||
- @filter.kind_usagers.each do |kind_usager|
|
||||
= link_to t(kind_usager, scope: 'activerecord.attributes.procedure.kind_usager'), all_admin_procedures_path(@filter.without(:kind_usagers, kind_usager)), class: 'fr-tag fr-tag--dismiss fr-mb-1w'
|
||||
- if @filter.tags.present?
|
||||
.selected-tag.fr-mb-2w
|
||||
- @filter.tags.each do |tag|
|
||||
|
|
|
@ -86,6 +86,16 @@
|
|||
= b.check_box(checked: @filter.status_filtered?(b.value))
|
||||
= b.label(class: 'fr-label') { t b.text, scope: 'activerecord.attributes.procedure.aasm_state' }
|
||||
|
||||
%li.fr-py-2w.fr-pl-2w{ 'data-controller': "expand" }
|
||||
.fr-mb-1w
|
||||
%button{ 'data-action': 'expand#toggle' }
|
||||
%span.fr-icon-add-line.fr-icon--sm.fr-mr-1w.fr-text-action-high--blue-france{ 'aria-hidden': 'true', 'data-expand-target': 'icon' }
|
||||
Type d'usager
|
||||
.fr-ml-1w.hidden{ 'data-expand-target': 'content' }
|
||||
= f.collection_check_boxes :kind_usagers, ['individual', 'personne_morale'], :to_s, :to_s, include_hidden: false do |b|
|
||||
.fr-checkbox-group.fr-ml-2w.fr-py-1w
|
||||
= b.check_box(checked: @filter.kind_usager_filtered?(b.value))
|
||||
= b.label(class: 'fr-label') { t b.text, scope: 'activerecord.attributes.procedure.kind_usager' }
|
||||
%li.fr-py-2w.fr-pl-2w{ 'data-controller': "expand" }
|
||||
.fr-mb-1w
|
||||
%button{ 'data-action': 'expand#toggle' }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue