move remove_filter

This commit is contained in:
simon lehericey 2020-10-30 14:34:00 +01:00 committed by Paul Chavard
parent 4241ea05f3
commit e5da1d7111
2 changed files with 11 additions and 6 deletions

View file

@ -156,12 +156,7 @@ module Instructeurs
end
def remove_filter
filters = procedure_presentation.filters
to_remove = params.values_at(:table, :column, :value)
filters[statut].reject! { |filter| filter.values_at('table', 'column', 'value') == to_remove }
procedure_presentation.update(filters: filters)
procedure_presentation.remove_filter(statut, params[:field], params[:value])
redirect_back(fallback_location: instructeur_procedure_url(procedure))
end

View file

@ -217,6 +217,16 @@ class ProcedurePresentation < ApplicationRecord
end
end
def remove_filter(statut, field, value)
table, column = field.split('/')
updated_filters = filters.dup
updated_filters[statut] = filters[statut].reject do |filter|
filter.values_at('table', 'column', 'value') == [table, column, value]
end
update!(filters: updated_filters)
end
def update_displayed_fields(values)
if values.nil?