feedback PR review
This commit is contained in:
parent
eb09a7480e
commit
c039414872
4 changed files with 12 additions and 18 deletions
|
@ -9,7 +9,7 @@
|
|||
= form_with(url: dossiers_path(), method: :get ) do |f|
|
||||
= f.hidden_field :statut, value: @statut
|
||||
|
||||
%fieldset#checkboxes.fr-fieldset{ "aria-labelledby" => "checkboxes-legend checkboxes-messages" }
|
||||
%fieldset#checkboxes.fr-fieldset{ "aria-labelledby" => "checkboxes-legend" }
|
||||
%legend#checkboxes-legend.fr-fieldset__legend--regular.fr-fieldset__legend
|
||||
= t('.legend.states')
|
||||
= f.collection_check_boxes :states, states_collection(@statut), :to_s, :to_s, include_hidden: false do |b|
|
||||
|
|
|
@ -51,18 +51,7 @@ module Users
|
|||
@first_brouillon_recently_updated = current_user.dossiers.visible_by_user.brouillons_recently_updated.first
|
||||
|
||||
@filter = DossiersFilter.new(current_user, params)
|
||||
if @filter.filter_params.present?
|
||||
@dossiers_result = filter_procedures(@filter, @dossiers)
|
||||
@dossiers = @dossiers_result.page(page)
|
||||
end
|
||||
end
|
||||
|
||||
def filter_procedures(filter, dossiers)
|
||||
dossiers_result = dossiers
|
||||
dossiers_result = dossiers_result.where(state: filter.states) if filter.states.present?
|
||||
dossiers_result = dossiers_result.where('created_at >= ?', filter.from_created_at_date) if filter.from_created_at_date.present?
|
||||
dossiers_result = dossiers_result.where('depose_at >= ?', filter.from_depose_at_date) if filter.from_depose_at_date.present?
|
||||
dossiers_result
|
||||
@dossiers = @filter.filter_procedures(@dossiers).page(page)
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
class DossiersFilter
|
||||
attr_reader :user, :params
|
||||
|
||||
ITEMS_PER_PAGE = 25
|
||||
|
||||
def initialize(user, params)
|
||||
@user = user
|
||||
@params = params.permit(:page, :from_created_at_date, :from_depose_at_date, states: [])
|
||||
|
@ -20,6 +18,15 @@ class DossiersFilter
|
|||
count
|
||||
end
|
||||
|
||||
def filter_procedures(dossiers)
|
||||
return dossiers if filter_params.blank?
|
||||
dossiers_result = dossiers
|
||||
dossiers_result = dossiers_result.where(state: states) if states.present?
|
||||
dossiers_result = dossiers_result.where('created_at >= ?', from_created_at_date) if from_created_at_date.present?
|
||||
dossiers_result = dossiers_result.where('depose_at >= ?', from_depose_at_date) if from_depose_at_date.present?
|
||||
dossiers_result
|
||||
end
|
||||
|
||||
def states
|
||||
params[:states].compact_blank if params[:states].present?
|
||||
end
|
||||
|
|
|
@ -68,9 +68,7 @@
|
|||
= render partial: "dossiers_list", locals: { dossiers: @dossiers }
|
||||
|
||||
- else
|
||||
- user_filter_component = Dossiers::UserFilterComponent.new(statut: @statut, filter: @filter)
|
||||
- if user_filter_component.render?
|
||||
= render user_filter_component
|
||||
= render Dossiers::UserFilterComponent.new(statut: @statut, filter: @filter)
|
||||
|
||||
- if @statut == "en-cours"
|
||||
- if @first_brouillon_recently_updated.present?
|
||||
|
|
Loading…
Reference in a new issue