Add 'refuser' and 'classer sans suite' buttons
This commit is contained in:
parent
0120ce2a32
commit
09236f32aa
7 changed files with 104 additions and 11 deletions
|
@ -42,6 +42,7 @@ function application_init(){
|
||||||
}
|
}
|
||||||
|
|
||||||
function tooltip_init() {
|
function tooltip_init() {
|
||||||
|
$('.action_button[data-toggle="tooltip"]').tooltip({delay: { "show": 100, "hide": 100 }});
|
||||||
$('[data-toggle="tooltip"]').tooltip({delay: { "show": 800, "hide": 100 }});
|
$('[data-toggle="tooltip"]').tooltip({delay: { "show": 800, "hide": 100 }});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,24 @@ class Backoffice::DossiersController < ApplicationController
|
||||||
render 'show'
|
render 'show'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def refuse
|
||||||
|
create_dossier_facade params[:dossier_id]
|
||||||
|
|
||||||
|
@facade.dossier.next_step! 'gestionnaire', 'refuse'
|
||||||
|
flash.notice = 'Dossier considéré comme refusé.'
|
||||||
|
|
||||||
|
render 'show'
|
||||||
|
end
|
||||||
|
|
||||||
|
def without_continuation
|
||||||
|
create_dossier_facade params[:dossier_id]
|
||||||
|
|
||||||
|
@facade.dossier.next_step! 'gestionnaire', 'without_continuation'
|
||||||
|
flash.notice = 'Dossier considéré comme sans suite.'
|
||||||
|
|
||||||
|
render 'show'
|
||||||
|
end
|
||||||
|
|
||||||
def close
|
def close
|
||||||
create_dossier_facade params[:dossier_id]
|
create_dossier_facade params[:dossier_id]
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ class Dossier < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def next_step! role, action
|
def next_step! role, action
|
||||||
unless %w(initiate update comment valid submit receive close).include?(action)
|
unless %w(initiate update comment valid submit receive refuse without_continuation close).include?(action)
|
||||||
fail 'action is not valid'
|
fail 'action is not valid'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -138,6 +138,14 @@ class Dossier < ActiveRecord::Base
|
||||||
if received?
|
if received?
|
||||||
closed!
|
closed!
|
||||||
end
|
end
|
||||||
|
when 'refuse'
|
||||||
|
if received?
|
||||||
|
refused!
|
||||||
|
end
|
||||||
|
when 'without_continuation'
|
||||||
|
if received?
|
||||||
|
without_continuation!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
state
|
state
|
||||||
|
|
|
@ -71,7 +71,13 @@
|
||||||
= 'Notifier de la bonne réception'
|
= 'Notifier de la bonne réception'
|
||||||
|
|
||||||
-elsif @facade.dossier.received?
|
-elsif @facade.dossier.received?
|
||||||
= form_tag(url_for({controller: 'backoffice/dossiers', action: :close, dossier_id: @facade.dossier.id}), class: 'form-inline', method: 'POST') do
|
= 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_button.btn.btn-success
|
%button#action_button.btn.btn-success
|
||||||
= 'Accepter le dossier'
|
%i.fa.fa-check
|
||||||
|
= form_tag(url_for({controller: 'backoffice/dossiers', action: :refuse, dossier_id: @facade.dossier.id}), class: 'form-inline action_button', method: 'POST', style: 'display:inline', 'data-toggle' => :tooltip, title: 'Refuser') do
|
||||||
|
%button#action_button.btn.btn-danger
|
||||||
|
%i.fa.fa-times
|
||||||
|
= form_tag(url_for({controller: 'backoffice/dossiers', action: :without_continuation, dossier_id: @facade.dossier.id}), class: 'form-inline action_button', method: 'POST', style: 'display:inline', 'data-toggle' => :tooltip, title: 'Classer sans suite') do
|
||||||
|
%button#action_button.btn.btn-warning
|
||||||
|
%i.fa.fa-circle-o
|
||||||
|
|
||||||
|
|
|
@ -157,6 +157,8 @@ Rails.application.routes.draw do
|
||||||
resources :dossiers do
|
resources :dossiers do
|
||||||
post 'valid' => 'dossiers#valid'
|
post 'valid' => 'dossiers#valid'
|
||||||
post 'receive' => 'dossiers#receive'
|
post 'receive' => 'dossiers#receive'
|
||||||
|
post 'refuse' => 'dossiers#refuse'
|
||||||
|
post 'without_continuation' => 'dossiers#without_continuation'
|
||||||
post 'close' => 'dossiers#close'
|
post 'close' => 'dossiers#close'
|
||||||
|
|
||||||
post 'invites' => '/invites#create'
|
post 'invites' => '/invites#create'
|
||||||
|
|
|
@ -382,6 +382,59 @@ describe Dossier do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when dossier is at state refused' do
|
||||||
|
before do
|
||||||
|
dossier.refused!
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when user is connected' do
|
||||||
|
let(:role) { 'user' }
|
||||||
|
|
||||||
|
context 'when he posts a comment' do
|
||||||
|
let(:action) { 'comment' }
|
||||||
|
|
||||||
|
it { is_expected.to eq('refused') }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when gestionnaire is connect' do
|
||||||
|
let(:role) { 'gestionnaire' }
|
||||||
|
|
||||||
|
context 'when he posts a comment' do
|
||||||
|
let(:action) { 'comment' }
|
||||||
|
|
||||||
|
it { is_expected.to eq('refused') }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when dossier is at state without_continuation' do
|
||||||
|
before do
|
||||||
|
dossier.without_continuation!
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when user is connected' do
|
||||||
|
let(:role) { 'user' }
|
||||||
|
|
||||||
|
context 'when he posts a comment' do
|
||||||
|
let(:action) { 'comment' }
|
||||||
|
|
||||||
|
it { is_expected.to eq('without_continuation') }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when gestionnaire is connect' do
|
||||||
|
let(:role) { 'gestionnaire' }
|
||||||
|
|
||||||
|
context 'when he posts a comment' do
|
||||||
|
let(:action) { 'comment' }
|
||||||
|
|
||||||
|
it { is_expected.to eq('without_continuation') }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
context 'when dossier is at state closed' do
|
context 'when dossier is at state closed' do
|
||||||
before do
|
before do
|
||||||
dossier.closed!
|
dossier.closed!
|
||||||
|
|
|
@ -138,8 +138,10 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
|
||||||
|
|
||||||
it { expect(rendered).to have_content('Reçu') }
|
it { expect(rendered).to have_content('Reçu') }
|
||||||
|
|
||||||
it 'button accepter le dossier is present' do
|
it 'button accepter / refuser / classer sans suite are present' do
|
||||||
expect(rendered).to have_content('Accepter le dossier')
|
expect(rendered).to have_css('.action_button[data-toggle="tooltip"][title="Accepter"]')
|
||||||
|
expect(rendered).to have_css('.action_button[data-toggle="tooltip"][title="Classer sans suite"]')
|
||||||
|
expect(rendered).to have_css('.action_button[data-toggle="tooltip"][title="Refuser"]')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -153,8 +155,9 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
|
||||||
it { expect(rendered).to have_content('Accepté') }
|
it { expect(rendered).to have_content('Accepté') }
|
||||||
|
|
||||||
it 'button Accepter le dossier is not present' do
|
it 'button Accepter le dossier is not present' do
|
||||||
expect(rendered).not_to have_css('#action_button')
|
expect(rendered).not_to have_css('.action_button[data-toggle="tooltip"][title="Accepter"]')
|
||||||
expect(rendered).not_to have_content('Accepter le dossier')
|
expect(rendered).not_to have_css('.action_button[data-toggle="tooltip"][title="Classer sans suite"]')
|
||||||
|
expect(rendered).not_to have_css('.action_button[data-toggle="tooltip"][title="Refuser"]')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -168,8 +171,9 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
|
||||||
it { expect(rendered).to have_content('Sans suite') }
|
it { expect(rendered).to have_content('Sans suite') }
|
||||||
|
|
||||||
it 'button Valider le dossier is not present' do
|
it 'button Valider le dossier is not present' do
|
||||||
expect(rendered).not_to have_css('#action_button')
|
expect(rendered).not_to have_css('.action_button[data-toggle="tooltip"][title="Accepter"]')
|
||||||
expect(rendered).not_to have_content('Valider le dossier')
|
expect(rendered).not_to have_css('.action_button[data-toggle="tooltip"][title="Classer sans suite"]')
|
||||||
|
expect(rendered).not_to have_css('.action_button[data-toggle="tooltip"][title="Refuser"]')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -183,8 +187,9 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
|
||||||
it { expect(rendered).to have_content('Refusé') }
|
it { expect(rendered).to have_content('Refusé') }
|
||||||
|
|
||||||
it 'button Valider le dossier is not present' do
|
it 'button Valider le dossier is not present' do
|
||||||
expect(rendered).not_to have_css('#action_button')
|
expect(rendered).not_to have_css('.action_button[data-toggle="tooltip"][title="Accepter"]')
|
||||||
expect(rendered).not_to have_content('Valider le dossier')
|
expect(rendered).not_to have_css('.action_button[data-toggle="tooltip"][title="Classer sans suite"]')
|
||||||
|
expect(rendered).not_to have_css('.action_button[data-toggle="tooltip"][title="Refuser"]')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue