list all demarches, filtered by status
This commit is contained in:
parent
9abf1c4af3
commit
22fe357d75
3 changed files with 33 additions and 0 deletions
|
@ -330,9 +330,11 @@ module Administrateurs
|
|||
@other_zones = Zone.all - @admin_zones
|
||||
@zone_ids = params[:zone_ids].filter(&:present?) if params[:zone_ids]
|
||||
@selected_zones = @zone_ids.map { |id| Zone.find(id) } if @zone_ids && @zone_ids.any?
|
||||
@statuses = params[:statuses].filter(&:present?) if params[:statuses]
|
||||
|
||||
@procedures = Procedure.joins(:procedures_zones).publiees_ou_closes
|
||||
@procedures = @procedures.where(procedures_zones: { zone_id: @zone_ids }) if @zone_ids && @zone_ids.any?
|
||||
@procedures = @procedures.where(aasm_state: @statuses) if @statuses && @statuses.any?
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -39,6 +39,16 @@
|
|||
.fr-checkbox-group.fr-ml-2w
|
||||
= b.check_box(checked: @zone_ids&.map(&:to_i)&.include?(b.value))
|
||||
= b.label(class: 'fr-label') { b.text }
|
||||
%li.fr-py-2w.fr-pl-2w{'data-controller': "expand"}
|
||||
.fr-mb-1w{'data-action': 'click->expand#toggle'}
|
||||
%button
|
||||
%span.fr-icon-add-line.fr-icon--sm.fr-mr-1w.fr-text-action-high--blue-france{'aria-hidden': 'true', 'data-expand-target': 'icon'}
|
||||
Statut
|
||||
.fr-ml-1w.hidden{'data-expand-target': 'content'}
|
||||
= f.collection_check_boxes :statuses, ['publiee', 'close'], :to_s, :to_s, include_hidden: false do |b|
|
||||
.fr-checkbox-group.fr-ml-2w
|
||||
= b.check_box(checked: @statuses&.include?(b.value))
|
||||
= b.label(class: 'fr-label') { b.text }
|
||||
= f.submit 'Filtrer', class: 'fr-btn'
|
||||
|
||||
.fr-col-9
|
||||
|
@ -49,6 +59,10 @@
|
|||
.selected-zones.fr-mb-2w
|
||||
- @selected_zones.each do |zone|
|
||||
%p.fr-tag.fr-mb-1w.fr--background-alt-blue-france= zone.current_label
|
||||
- if @statuses
|
||||
.selected-statuses.fr-mb-2w
|
||||
- @statuses.each do |status|
|
||||
%p.fr-tag.fr-mb-1w.fr--background-alt-blue-france= status
|
||||
%thead
|
||||
%tr
|
||||
%th{scope: 'col'}
|
||||
|
|
|
@ -120,6 +120,23 @@ describe Administrateurs::ProceduresController, type: :controller do
|
|||
expect(assigns(:procedures)).not_to include(procedure1)
|
||||
end
|
||||
end
|
||||
|
||||
context 'for specific status' do
|
||||
let!(:procedure1) { create(:procedure, :published) }
|
||||
let!(:procedure2) { create(:procedure, :closed) }
|
||||
|
||||
it 'display only published procedures' do
|
||||
get :all, params: { statuses: ['publiee'] }
|
||||
expect(assigns(:procedures)).to include(procedure1)
|
||||
expect(assigns(:procedures)).not_to include(procedure2)
|
||||
end
|
||||
|
||||
it 'display only closed procedures' do
|
||||
get :all, params: { statuses: ['close'] }
|
||||
expect(assigns(:procedures)).to include(procedure2)
|
||||
expect(assigns(:procedures)).not_to include(procedure1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #search' do
|
||||
|
|
Loading…
Reference in a new issue