First step to remove :validated and :submitted states
This commit is contained in:
parent
b2198663d1
commit
cae5b37e38
10 changed files with 28 additions and 161 deletions
|
@ -85,21 +85,10 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
|
|||
default_sort: dossiers_list_facade.service.default_sort
|
||||
end
|
||||
|
||||
def valid
|
||||
create_dossier_facade params[:dossier_id]
|
||||
|
||||
@facade.dossier.next_step! 'gestionnaire', 'valid'
|
||||
flash.notice = 'Dossier confirmé avec succès.'
|
||||
|
||||
NotificationMailer.dossier_validated(@facade.dossier).deliver_now!
|
||||
|
||||
redirect_to backoffice_dossier_path(id: @facade.dossier.id)
|
||||
end
|
||||
|
||||
def receive
|
||||
create_dossier_facade params[:dossier_id]
|
||||
|
||||
@facade.dossier.next_step! 'gestionnaire', 'receive'
|
||||
@facade.dossier.received!
|
||||
flash.notice = 'Dossier considéré comme reçu.'
|
||||
|
||||
NotificationMailer.dossier_received(@facade.dossier).deliver_now!
|
||||
|
|
|
@ -5,8 +5,8 @@ class Dossier < ActiveRecord::Base
|
|||
initiated: 'initiated',
|
||||
replied: 'replied', #action utilisateur demandé
|
||||
updated: 'updated', #etude par l'administration en cours
|
||||
validated: 'validated',
|
||||
submitted: 'submitted',
|
||||
# validated: 'validated',
|
||||
# submitted: 'submitted',
|
||||
received: 'received',
|
||||
closed: 'closed',
|
||||
refused: 'refused',
|
||||
|
@ -122,10 +122,6 @@ class Dossier < ActiveRecord::Base
|
|||
if draft?
|
||||
initiated!
|
||||
end
|
||||
when 'submit'
|
||||
if validated?
|
||||
submitted!
|
||||
end
|
||||
when 'update'
|
||||
if replied?
|
||||
updated!
|
||||
|
@ -147,18 +143,6 @@ class Dossier < ActiveRecord::Base
|
|||
if initiated?
|
||||
updated!
|
||||
end
|
||||
when 'valid'
|
||||
if updated?
|
||||
validated!
|
||||
elsif replied?
|
||||
validated!
|
||||
elsif initiated?
|
||||
validated!
|
||||
end
|
||||
when 'receive'
|
||||
if submitted?
|
||||
received!
|
||||
end
|
||||
when 'close'
|
||||
if received?
|
||||
closed!
|
||||
|
@ -332,7 +316,7 @@ class Dossier < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def read_only?
|
||||
validated? || received? || submitted? || closed? || refused? || without_continuation?
|
||||
received? || closed? || refused? || without_continuation?
|
||||
end
|
||||
|
||||
def owner? email
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
- MailTemplate::TAGS.each do |balise|
|
||||
%tr
|
||||
%td.center
|
||||
%b.text-success
|
||||
= "--#{balise.first}--"
|
||||
%td
|
||||
=balise.second[:description]
|
||||
|
|
|
@ -4,14 +4,9 @@
|
|||
|
||||
%div#action-block
|
||||
- if gestionnaire_signed_in?
|
||||
- if !@facade.dossier.read_only?
|
||||
= form_tag(url_for({controller: 'backoffice/dossiers', action: :valid, dossier_id: @facade.dossier.id}), class: 'form-inline', method: 'POST') do
|
||||
%button.action{'data-toggle' => :tooltip, title: 'En cliquant ici, vous figez le dossier et autorisez le dépôt du dossier pour instruction.'}
|
||||
= 'Déclarer complet'.upcase
|
||||
- elsif @facade.dossier.submitted?
|
||||
= form_tag(url_for({controller: 'backoffice/dossiers', action: :receive, dossier_id: @facade.dossier.id}), class: 'form-inline', method: 'POST') do
|
||||
%button.action
|
||||
= 'Accuser réception'.upcase
|
||||
- if !@facade.dossier.read_only? || @facade.dossier.initiated?
|
||||
= link_to 'Accuser réception', backoffice_dossier_receive_path(@facade.dossier), method: :post, class: 'btn btn-danger btn-block'
|
||||
|
||||
- elsif @facade.dossier.received?
|
||||
= form_tag(url_for({controller: 'backoffice/dossiers', action: :close, dossier_id: @facade.dossier.id}), class: 'form-inline action_button', method: 'POST', style: 'display:inline', 'data-toggle' => :tooltip, title: 'Accepter') do
|
||||
%button.action.close-dossier
|
||||
|
|
|
@ -23,11 +23,11 @@
|
|||
.badge.progress-bar-danger
|
||||
= @dossiers_list_facade.en_construction_total
|
||||
|
||||
%a{:href => "#{url_for users_dossiers_path(liste: 'valides')}", 'data-toggle' => :tooltip, title: 'Les dossiers relus par votre accompagnateur pouvant être déposés pour examen.'}
|
||||
%div.procedure_list_element{ class: @dossiers_list_facade.valides_class, id: 'valides' }
|
||||
="À déposer"
|
||||
.badge.progress-bar-purple
|
||||
= @dossiers_list_facade.valides_total
|
||||
-# %a{:href => "#{url_for users_dossiers_path(liste: 'valides')}", 'data-toggle' => :tooltip, title: 'Les dossiers relus par votre accompagnateur pouvant être déposés pour examen.'}
|
||||
-# %div.procedure_list_element{ class: @dossiers_list_facade.valides_class, id: 'valides' }
|
||||
-# ="À déposer"
|
||||
-# .badge.progress-bar-purple
|
||||
-# = @dossiers_list_facade.valides_total
|
||||
|
||||
%a{:href => "#{url_for users_dossiers_path(liste: 'en_instruction')}", 'data-toggle' => :tooltip, title: 'Les dossiers en cours d\'examen par l\'administration compétante.'}
|
||||
%div.procedure_list_element{ class: @dossiers_list_facade.en_instruction_class, id: 'en_instruction' }
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class RemoveUselessDossierStates < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
Dossier.where(state: [:validated, :submitted]).update_all(state: :initiated)
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20170215142944) do
|
||||
ActiveRecord::Schema.define(version: 20170221143909) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
|
|
@ -39,7 +39,7 @@ describe MailTemplate do
|
|||
end
|
||||
end
|
||||
|
||||
xdescribe '.replace_tags' do
|
||||
describe '.replace_tags' do
|
||||
let(:dossier) { create :dossier }
|
||||
let(:procedure) { dossier.procedure }
|
||||
let(:mail_received) { procedure.mail_received }
|
||||
|
|
|
@ -23,6 +23,11 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm
|
|||
end
|
||||
|
||||
context 'button dossier state changements' do
|
||||
|
||||
shared_examples 'button Accuser réception is present' do
|
||||
it { expect(rendered).to have_link('Accuser réception') }
|
||||
end
|
||||
|
||||
context 'when dossier have state initiated' do
|
||||
let(:state) { 'initiated' }
|
||||
|
||||
|
@ -32,10 +37,7 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm
|
|||
|
||||
it { expect(rendered).to have_content('Nouveau') }
|
||||
|
||||
it 'button Déclarer complet is present' do
|
||||
expect(rendered).to have_css('.action')
|
||||
expect(rendered).to have_content('DÉCLARER COMPLET')
|
||||
end
|
||||
include_examples 'button Accuser réception is present'
|
||||
end
|
||||
|
||||
context 'when dossier have state replied' do
|
||||
|
@ -47,10 +49,7 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm
|
|||
|
||||
it { expect(rendered).to have_content('En construction') }
|
||||
|
||||
it 'button Déclarer complet is present' do
|
||||
expect(rendered).to have_css('.action')
|
||||
expect(rendered).to have_content('DÉCLARER COMPLET')
|
||||
end
|
||||
include_examples 'button Accuser réception is present'
|
||||
end
|
||||
|
||||
context 'when dossier have state update' do
|
||||
|
@ -62,44 +61,7 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm
|
|||
|
||||
it { expect(rendered).to have_content('En construction') }
|
||||
|
||||
it 'button Déclarer complet is present' do
|
||||
expect(rendered).to have_css('.action')
|
||||
expect(rendered).to have_content('DÉCLARER COMPLET')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier have state validated' do
|
||||
let(:state) { 'validated' }
|
||||
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).to have_content('Figé') }
|
||||
|
||||
it 'button Déclarer complet is not present' do
|
||||
expect(rendered).not_to have_css('.action')
|
||||
expect(rendered).not_to have_content('Déclarer complet')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier have state submitted' do
|
||||
let(:state) { 'submitted' }
|
||||
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).to have_content('Déposé / À réceptionner') }
|
||||
|
||||
it 'button Accuser réception is present' do
|
||||
expect(rendered).to have_css('.action')
|
||||
expect(rendered).to have_content('ACCUSER RÉCEPTION')
|
||||
end
|
||||
|
||||
it 'button Déclarer complet is not present' do
|
||||
expect(rendered).not_to have_content('Accepter le dossier')
|
||||
end
|
||||
include_examples 'button Accuser réception is present'
|
||||
end
|
||||
|
||||
context 'when dossier have state received' do
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'layouts/left_panels/_left_panel_users_dossierscontroller_index.html.haml', type: :view do
|
||||
|
||||
shared_examples 'active_tab' do
|
||||
let(:user) { create :user }
|
||||
|
||||
before do
|
||||
sign_in user
|
||||
|
||||
create :dossier, user: user
|
||||
|
||||
assign :dossiers_list_facade, (DossiersListFacades.new user, param_list)
|
||||
|
||||
render
|
||||
end
|
||||
|
||||
subject { rendered }
|
||||
|
||||
let(:active_class) { 'div.procedure_list_element.active '+active_klass }
|
||||
let(:param_list) { liste }
|
||||
|
||||
it { is_expected.to have_selector(active_class) }
|
||||
end
|
||||
|
||||
describe 'list brouillon' do
|
||||
let(:active_klass) { '.progress-bar-default' }
|
||||
let(:liste) { 'brouillon' }
|
||||
|
||||
it_behaves_like 'active_tab'
|
||||
end
|
||||
|
||||
describe 'list en construction' do
|
||||
let(:active_klass) { '.progress-bar-danger' }
|
||||
let(:liste) { 'a_traiter' }
|
||||
|
||||
it_behaves_like 'active_tab'
|
||||
end
|
||||
|
||||
describe 'list a depose' do
|
||||
let(:active_klass) { '.progress-bar-purple' }
|
||||
let(:liste) { 'valides' }
|
||||
|
||||
it_behaves_like 'active_tab'
|
||||
end
|
||||
|
||||
describe 'list en examen' do
|
||||
let(:active_klass) { '.progress-bar-default' }
|
||||
let(:liste) { 'en_instruction' }
|
||||
|
||||
it_behaves_like 'active_tab'
|
||||
end
|
||||
|
||||
describe 'list cloture' do
|
||||
let(:active_klass) { '.progress-bar-success' }
|
||||
let(:liste) { 'termine' }
|
||||
|
||||
it_behaves_like 'active_tab'
|
||||
end
|
||||
|
||||
describe 'list invite' do
|
||||
let(:active_klass) { '.progress-bar-warning' }
|
||||
let(:liste) { 'invite' }
|
||||
|
||||
it_behaves_like 'active_tab'
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue