controllers: add a TypesDeChamp#estimate_fill_duration action

This commit is contained in:
Pierre de La Morinerie 2022-05-17 13:44:18 +00:00
parent 736ef10bb3
commit ac6ae94c93
2 changed files with 13 additions and 1 deletions

View file

@ -1,6 +1,6 @@
module Administrateurs
class TypesDeChampController < AdministrateurController
before_action :retrieve_procedure, only: [:create, :update, :move, :destroy]
before_action :retrieve_procedure, only: [:create, :update, :move, :estimate_fill_duration, :destroy]
before_action :procedure_revisable?, only: [:create, :update, :move, :destroy]
def create
@ -31,6 +31,15 @@ module Administrateurs
head :no_content
end
def estimate_fill_duration
estimate = if @procedure.feature_enabled?(:procedure_estimated_fill_duration)
@procedure.draft_revision.estimated_fill_duration
else
0
end
render json: { estimated_fill_duration: estimate }
end
def destroy
@procedure.draft_revision.remove_type_de_champ(params[:id])
reset_procedure

View file

@ -461,6 +461,9 @@ Rails.application.routes.draw do
resources :experts, controller: 'experts_procedures', only: [:index, :create, :update, :destroy]
resources :types_de_champ, only: [:create, :update, :destroy] do
collection do
get :estimate_fill_duration
end
member do
patch :move
end