commit
5521983472
1 changed files with 19 additions and 11 deletions
|
@ -144,18 +144,20 @@ module NewGestionnaire
|
|||
end
|
||||
|
||||
def add_filter
|
||||
filters = procedure_presentation.filters
|
||||
table, column = params[:field].split('/')
|
||||
label = procedure.fields.find { |c| c['table'] == table && c['column'] == column }['label']
|
||||
if params[:value].present?
|
||||
filters = procedure_presentation.filters
|
||||
table, column = params[:field].split('/')
|
||||
label = procedure.fields.find { |c| c['table'] == table && c['column'] == column }['label']
|
||||
|
||||
filters[statut] << {
|
||||
'label' => label,
|
||||
'table' => table,
|
||||
'column' => column,
|
||||
'value' => params[:value]
|
||||
}
|
||||
filters[statut] << {
|
||||
'label' => label,
|
||||
'table' => table,
|
||||
'column' => column,
|
||||
'value' => params[:value]
|
||||
}
|
||||
|
||||
procedure_presentation.update_attributes(filters: filters.to_json)
|
||||
procedure_presentation.update_attributes(filters: filters.to_json)
|
||||
end
|
||||
|
||||
redirect_back(fallback_location: procedure_url(procedure))
|
||||
end
|
||||
|
@ -236,9 +238,15 @@ module NewGestionnaire
|
|||
.where("champs.value LIKE ?", "%#{filter['value']}%")
|
||||
|
||||
when 'user', 'etablissement', 'entreprise'
|
||||
dossiers
|
||||
if filter['column'] == 'date_creation'
|
||||
dossiers
|
||||
.includes(filter['table'])
|
||||
.where("#{filter['table'].pluralize}.#{filter['column']} = ?", filter['value'].to_date)
|
||||
else
|
||||
dossiers
|
||||
.includes(filter['table'])
|
||||
.where("#{filter['table'].pluralize}.#{filter['column']} LIKE ?", "%#{filter['value']}%")
|
||||
end
|
||||
|
||||
end.pluck(:id)
|
||||
end.reduce(:&)
|
||||
|
|
Loading…
Reference in a new issue