commit
166feb9dfb
8 changed files with 55 additions and 12 deletions
|
@ -1 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><g fill="none" fill-rule="evenodd"><path d="M0 0h24v24H0z"/><g stroke="#0069CC" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M13 12H3m6.438 4.242L13.68 12 9.437 7.757"/><path d="M3 16v3a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5c0-1.1-.901-2-2-2H5c-1.099 0-2 .9-2 2v3"/></g></g></svg>
|
||||
<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path d="M0 0h24v24H0z"/><g stroke-linecap="round" stroke-linejoin="round" stroke="#0069CC" stroke-width="2"><path d="M20.3 12H10m6.63 4L21 12l-4.37-4"/><path d="M21 7V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14c0 1.1.901 2 2 2h14c1.099 0 2-.9 2-2v-2"/></g></g></svg>
|
Before Width: | Height: | Size: 385 B After Width: | Height: | Size: 356 B |
|
@ -1,14 +1,12 @@
|
|||
module Manager
|
||||
class ProceduresController < Manager::ApplicationController
|
||||
def whitelist
|
||||
procedure = Procedure.find(params[:id])
|
||||
procedure.whitelist!
|
||||
flash[:notice] = "Démarche whitelistée."
|
||||
redirect_to manager_procedure_path(procedure)
|
||||
end
|
||||
|
||||
def draft
|
||||
procedure = Procedure.find(params[:id])
|
||||
if procedure.dossiers.empty?
|
||||
procedure.draft!
|
||||
flash[:notice] = "La démarche a bien été passée en brouillon."
|
||||
|
@ -19,14 +17,12 @@ module Manager
|
|||
end
|
||||
|
||||
def hide
|
||||
procedure = Procedure.find(params[:id])
|
||||
procedure.hide!
|
||||
flash[:notice] = "La démarche a bien été supprimée, en cas d'erreur contactez un développeur."
|
||||
redirect_to manager_procedures_path
|
||||
end
|
||||
|
||||
def add_administrateur
|
||||
procedure = Procedure.find(params[:id])
|
||||
administrateur = Administrateur.find_by(email: params[:email])
|
||||
if administrateur
|
||||
procedure.administrateurs << administrateur
|
||||
|
@ -36,5 +32,28 @@ module Manager
|
|||
end
|
||||
redirect_to manager_procedure_path(procedure)
|
||||
end
|
||||
|
||||
def change_piece_justificative_template
|
||||
if type_de_champ.update(type_de_champ_params)
|
||||
flash[:notice] = "Le modèle est mis à jour."
|
||||
else
|
||||
flash[:alert] = type_de_champ.errors.full_messages.join(', ')
|
||||
end
|
||||
redirect_to manager_procedure_path(procedure)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def procedure
|
||||
Procedure.find(params[:id])
|
||||
end
|
||||
|
||||
def type_de_champ
|
||||
TypeDeChamp.find(params[:type_de_champ][:id])
|
||||
end
|
||||
|
||||
def type_de_champ_params
|
||||
params.require(:type_de_champ).permit(:piece_justificative_template)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,7 +31,18 @@ class Gestionnaire < ApplicationRecord
|
|||
return
|
||||
end
|
||||
|
||||
followed_dossiers << dossier
|
||||
begin
|
||||
followed_dossiers << dossier
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
# Altough we checked before the insertion that the gestionnaire wasn't
|
||||
# already following this dossier, this was done at the Rails level:
|
||||
# at the database level, the dossier was already followed, and a
|
||||
# "invalid constraint" exception is raised.
|
||||
#
|
||||
# We can ignore this safely, as it means the goal is already reached:
|
||||
# the gestionnaire follows the dossier.
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
def unfollow(dossier)
|
||||
|
@ -116,6 +127,8 @@ class Gestionnaire < ApplicationRecord
|
|||
procedure.dossiers.termine
|
||||
when :not_archived
|
||||
procedure.dossiers.not_archived
|
||||
when :all
|
||||
procedure.dossiers
|
||||
else
|
||||
procedure.dossiers.en_cours
|
||||
end
|
||||
|
@ -215,7 +228,7 @@ class Gestionnaire < ApplicationRecord
|
|||
|
||||
h = {
|
||||
nb_en_construction: procedure.dossiers.en_construction.count,
|
||||
nb_notification: notifications_per_procedure(procedure).count
|
||||
nb_notification: notifications_for_procedure(procedure, :all).count
|
||||
}
|
||||
|
||||
if h[:nb_en_construction] > 0 || h[:nb_notification] > 0
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
%td.cell-label Libelle
|
||||
%td.cell-label Type de champ
|
||||
%td.cell-label Rempli
|
||||
%td.cell-label Modifier le modèle
|
||||
%tbody
|
||||
- field.data.order(:order_place).each do |f|
|
||||
%tr
|
||||
|
@ -20,5 +21,14 @@
|
|||
vide
|
||||
- else
|
||||
rempli
|
||||
|
||||
%td.cell-data
|
||||
- if f.type_champ == 'piece_justificative'
|
||||
= form_for f,
|
||||
url: change_piece_justificative_template_manager_procedure_path,
|
||||
method: :post do |form|
|
||||
= form.hidden_field :id
|
||||
= form.file_field :piece_justificative_template
|
||||
= form.submit 'modifier'
|
||||
- else
|
||||
Aucun
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
.mandatory-explanation
|
||||
Les champs avec un astérisque (
|
||||
%span.mandatory> *
|
||||
) sont obligatoires.
|
||||
) sont obligatoires. Pour enregistrer les informations saisies, cliquez sur le bouton « enregistrer le brouillon » en bas à gauche du formulaire.
|
||||
|
||||
- if notice_url(dossier.procedure).present?
|
||||
= link_to notice_url(dossier.procedure), target: '_blank', rel: 'noopener', class: 'button notice', title: "Pour vous aider à remplir votre dossier, vous pouvez consulter le guide de cette démarche." do
|
||||
|
|
|
@ -11,6 +11,7 @@ Rails.application.routes.draw do
|
|||
post 'draft', on: :member
|
||||
post 'hide', on: :member
|
||||
post 'add_administrateur', on: :member
|
||||
post 'change_piece_justificative_template', on: :member
|
||||
end
|
||||
|
||||
resources :dossiers, only: [:index, :show] do
|
||||
|
|
|
@ -279,7 +279,7 @@ describe Gestionnaire, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#notification_for_procedure' do
|
||||
describe '#notifications_for_procedure' do
|
||||
let!(:dossier) { create(:dossier, :followed, state: Dossier.states.fetch(:en_construction)) }
|
||||
let(:gestionnaire) { dossier.follows.first.gestionnaire }
|
||||
let(:procedure) { dossier.procedure }
|
||||
|
@ -438,8 +438,8 @@ describe Gestionnaire, type: :model do
|
|||
|
||||
context 'when a notification exists' do
|
||||
before do
|
||||
allow(gestionnaire).to receive(:notifications_per_procedure)
|
||||
.with(procedure_to_assign)
|
||||
allow(gestionnaire).to receive(:notifications_for_procedure)
|
||||
.with(procedure_to_assign, :all)
|
||||
.and_return([1, 2, 3])
|
||||
end
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ describe NotificationService do
|
|||
|
||||
context 'when there is a notification on this procedure' do
|
||||
before do
|
||||
allow_any_instance_of(Gestionnaire).to receive(:notifications_per_procedure)
|
||||
allow_any_instance_of(Gestionnaire).to receive(:notifications_for_procedure)
|
||||
.and_return([12])
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue