From bc71754e87119f9417cad0afb79cf7dc974a6215 Mon Sep 17 00:00:00 2001 From: Xavier J Date: Tue, 10 Jan 2017 17:29:38 +0100 Subject: [PATCH] Add tool change dossier state --- .../admin/change_dossier_state_controller.rb | 14 ++++++++++++++ .../admin/change_dossier_state/change.html.haml | 16 ++++++++++++++++ .../admin/change_dossier_state/check.html.haml | 17 +++++++++++++++++ .../admin/change_dossier_state/index.html.haml | 7 +++++++ config/routes.rb | 4 ++++ 5 files changed, 58 insertions(+) create mode 100644 app/controllers/admin/change_dossier_state_controller.rb create mode 100644 app/views/admin/change_dossier_state/change.html.haml create mode 100644 app/views/admin/change_dossier_state/check.html.haml create mode 100644 app/views/admin/change_dossier_state/index.html.haml diff --git a/app/controllers/admin/change_dossier_state_controller.rb b/app/controllers/admin/change_dossier_state_controller.rb new file mode 100644 index 000000000..86611da4f --- /dev/null +++ b/app/controllers/admin/change_dossier_state_controller.rb @@ -0,0 +1,14 @@ +class Admin::ChangeDossierStateController < AdminController + def index + @dossier = Dossier.new + end + + def change + @dossier = Dossier.find(params[:dossier][:id]) + @dossier.update state: params[:next_state] + end + + def check + @dossier = Dossier.find(params[:dossier][:id]) + end +end \ No newline at end of file diff --git a/app/views/admin/change_dossier_state/change.html.haml b/app/views/admin/change_dossier_state/change.html.haml new file mode 100644 index 000000000..36316f51f --- /dev/null +++ b/app/views/admin/change_dossier_state/change.html.haml @@ -0,0 +1,16 @@ +.center + %h2 Outil de changement d'état d'un dossier + + %h4.text-success + Changement effectué + + = form_for @dossier, url: 'change_dossier_state', action: :put do |f| + Dossier ID : + = @dossier.id + %br + État : + = @dossier.decorate.display_state + + %br + %br + = link_to 'Réaliser un autre dossier', 'change_dossier_state' \ No newline at end of file diff --git a/app/views/admin/change_dossier_state/check.html.haml b/app/views/admin/change_dossier_state/check.html.haml new file mode 100644 index 000000000..c77a2a61c --- /dev/null +++ b/app/views/admin/change_dossier_state/check.html.haml @@ -0,0 +1,17 @@ +.center + %h2 Outil de changement d'état d'un dossier + + = form_for @dossier, url: 'change_dossier_state', action: :put do |f| + Dossier ID : + = @dossier.id + = f.hidden_field :id + %br + État : + = @dossier.decorate.display_state + %br + État souhaité : + %select{id: :next_state, name: :next_state} + - Dossier.states.each do |state| + %option{value: state[0]} + =DossierDecorator.case_state_fr state[1] + = f.submit 'Valider' \ No newline at end of file diff --git a/app/views/admin/change_dossier_state/index.html.haml b/app/views/admin/change_dossier_state/index.html.haml new file mode 100644 index 000000000..525023b5f --- /dev/null +++ b/app/views/admin/change_dossier_state/index.html.haml @@ -0,0 +1,7 @@ +.center + %h2 Outil de changement d'état d'un dossier + + = form_for @dossier, url: 'change_dossier_state', action: :post do |f| + Dossier ID + = f.text_field :id + = f.submit 'Vérifier état' diff --git a/config/routes.rb b/config/routes.rb index a71414e61..abe924522 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -106,6 +106,10 @@ Rails.application.routes.draw do get 'procedures/path_list' => 'procedures#path_list' get 'profile' => 'profile#show', as: :profile + get 'change_dossier_state' => 'change_dossier_state#index' + post 'change_dossier_state' => 'change_dossier_state#check' + patch 'change_dossier_state' => 'change_dossier_state#change' + resources :procedures do resources :types_de_champ, only: [:destroy] resource :types_de_champ, only: [:show, :update] do