clean: remove old procedure_presentation methods from procedures_controller
This commit is contained in:
parent
22ab0f4eca
commit
947ef3498b
3 changed files with 0 additions and 98 deletions
|
@ -132,44 +132,6 @@ module Instructeurs
|
||||||
@statut = 'supprime'
|
@statut = 'supprime'
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: to remove because of new procedure_presentation_controller
|
|
||||||
def update_displayed_fields
|
|
||||||
ids = (params['values'].presence || []).reject(&:empty?)
|
|
||||||
|
|
||||||
procedure_presentation.update!(displayed_columns: ids)
|
|
||||||
|
|
||||||
redirect_back(fallback_location: instructeur_procedure_url(procedure))
|
|
||||||
end
|
|
||||||
|
|
||||||
# TODO: to remove because of new procedure_presentation_controller
|
|
||||||
def update_sort
|
|
||||||
procedure_presentation.update!(sorted_column_params)
|
|
||||||
|
|
||||||
redirect_back(fallback_location: instructeur_procedure_url(procedure))
|
|
||||||
end
|
|
||||||
|
|
||||||
# TODO: to remove because of new procedure_presentation_controller
|
|
||||||
def add_filter
|
|
||||||
if !procedure_presentation.update(filter_params)
|
|
||||||
# complicated way to display inner error messages
|
|
||||||
flash.alert = procedure_presentation.errors
|
|
||||||
.flat_map { _1.detail[:value].flat_map { |c| c.errors.full_messages } }
|
|
||||||
end
|
|
||||||
|
|
||||||
redirect_back(fallback_location: instructeur_procedure_url(procedure))
|
|
||||||
end
|
|
||||||
|
|
||||||
# TODO: to remove because of new procedure_presentation_controller
|
|
||||||
def update_filter
|
|
||||||
@statut = statut
|
|
||||||
@procedure = procedure
|
|
||||||
@procedure_presentation = procedure_presentation
|
|
||||||
current_filter = procedure_presentation.filters_name_for(@statut)
|
|
||||||
# According to the html, the selected column is the last one
|
|
||||||
h_id = JSON.parse(params[current_filter].last[:id], symbolize_names: true)
|
|
||||||
@column = procedure.find_column(h_id:)
|
|
||||||
end
|
|
||||||
|
|
||||||
def download_export
|
def download_export
|
||||||
groupe_instructeurs = current_instructeur
|
groupe_instructeurs = current_instructeur
|
||||||
.groupe_instructeurs
|
.groupe_instructeurs
|
||||||
|
@ -410,17 +372,5 @@ module Instructeurs
|
||||||
def cookies_export_key
|
def cookies_export_key
|
||||||
"exports_#{@procedure.id}_seen_at"
|
"exports_#{@procedure.id}_seen_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: to remove because of new procedure_presentation_controller
|
|
||||||
def sorted_column_params
|
|
||||||
params.permit(sorted_column: [:order, :id])
|
|
||||||
end
|
|
||||||
|
|
||||||
# TODO: to remove because of new procedure_presentation_controller
|
|
||||||
def filter_params
|
|
||||||
keys = [:tous_filters, :a_suivre_filters, :suivis_filters, :traites_filters, :expirant_filters, :archives_filters, :supprimes_filters]
|
|
||||||
h = keys.index_with { [:id, :filter] }
|
|
||||||
params.permit(h)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -490,13 +490,6 @@ Rails.application.routes.draw do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: to remove because of new procedure_presentation_controller
|
|
||||||
patch 'update_displayed_fields'
|
|
||||||
get 'update_sort' => 'procedures#update_sort', as: 'update_sort'
|
|
||||||
post 'add_filter'
|
|
||||||
post 'update_filter'
|
|
||||||
get 'remove_filter'
|
|
||||||
|
|
||||||
get 'download_export'
|
get 'download_export'
|
||||||
post 'download_export'
|
post 'download_export'
|
||||||
get 'polling_last_export'
|
get 'polling_last_export'
|
||||||
|
|
|
@ -905,45 +905,4 @@ describe Instructeurs::ProceduresController, type: :controller do
|
||||||
it { is_expected.to have_http_status(:forbidden) }
|
it { is_expected.to have_http_status(:forbidden) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#update_filter' do
|
|
||||||
let(:instructeur) { create(:instructeur) }
|
|
||||||
let(:procedure) { create(:procedure, :for_individual) }
|
|
||||||
def procedure_presentation = instructeur.assign_to.first.procedure_presentation_or_default_and_errors.first
|
|
||||||
|
|
||||||
before do
|
|
||||||
create(:assign_to, instructeur:, groupe_instructeur: build(:groupe_instructeur, procedure:))
|
|
||||||
|
|
||||||
sign_in(instructeur.user)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'can change order' do
|
|
||||||
column = procedure.find_column(label: "Nom")
|
|
||||||
expect { get :update_sort, params: { procedure_id: procedure.id, sorted_column: { id: column.id, order: 'asc' } } }
|
|
||||||
.to change { procedure_presentation.sorted_column }
|
|
||||||
.from(procedure.default_sorted_column)
|
|
||||||
.to(SortedColumn.new(column:, order: 'asc'))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#add_filter' do
|
|
||||||
let(:instructeur) { create(:instructeur) }
|
|
||||||
let(:procedure) { create(:procedure, :for_individual) }
|
|
||||||
|
|
||||||
before do
|
|
||||||
create(:assign_to, instructeur:, groupe_instructeur: build(:groupe_instructeur, procedure:))
|
|
||||||
|
|
||||||
sign_in(instructeur.user)
|
|
||||||
end
|
|
||||||
|
|
||||||
subject do
|
|
||||||
column = procedure.find_column(label: "Nom")
|
|
||||||
post :add_filter, params: { procedure_id: procedure.id, a_suivre_filters: [{ id: column.id, filter: "n" * 4049 }] }
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should render the error' do
|
|
||||||
subject
|
|
||||||
expect(flash.alert[0]).to include("Le filtre « Nom » est trop long (maximum: 4048 caractères)")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue