Merge pull request #767 from sgmap/split_avis_and_private_champs
Split avis and private champs
This commit is contained in:
commit
3cbf555ee5
10 changed files with 78 additions and 45 deletions
|
@ -2,7 +2,7 @@
|
|||
@import "common";
|
||||
@import "constants";
|
||||
|
||||
#dossier-instruction {
|
||||
#dossier-annotations-privees {
|
||||
h1 {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
|
@ -14,9 +14,14 @@ module NewGestionnaire
|
|||
dossier.notifications.messagerie.mark_as_read
|
||||
end
|
||||
|
||||
def instruction
|
||||
def annotations_privees
|
||||
@dossier = dossier
|
||||
dossier.notifications.instruction.mark_as_read
|
||||
dossier.notifications.annotations_privees.mark_as_read
|
||||
end
|
||||
|
||||
def avis
|
||||
@dossier = dossier
|
||||
dossier.notifications.avis.mark_as_read
|
||||
end
|
||||
|
||||
def follow
|
||||
|
@ -67,13 +72,13 @@ module NewGestionnaire
|
|||
|
||||
def create_avis
|
||||
Avis.create(avis_params.merge(claimant: current_gestionnaire, dossier: dossier))
|
||||
redirect_to instruction_dossier_path(dossier.procedure, dossier)
|
||||
redirect_to avis_dossier_path(dossier.procedure, dossier)
|
||||
end
|
||||
|
||||
def update_annotations
|
||||
dossier = current_gestionnaire.dossiers.includes(champs_private: :type_de_champ).find(params[:dossier_id])
|
||||
dossier.update_attributes(champs_private_params)
|
||||
redirect_to instruction_dossier_path(dossier.procedure, dossier)
|
||||
redirect_to annotations_privees_dossier_path(dossier.procedure, dossier)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -83,8 +83,12 @@ class Champ < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def internal_notification
|
||||
unless dossier.state == 'draft'
|
||||
NotificationService.new('champs', self.dossier.id, self.libelle).notify
|
||||
if dossier.state != 'draft'
|
||||
if type == 'ChampPublic'
|
||||
NotificationService.new('champs', self.dossier.id, self.libelle).notify
|
||||
else
|
||||
NotificationService.new('annotations_privees', self.dossier.id, self.libelle).notify
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -96,8 +96,9 @@ class Dossier < ActiveRecord::Base
|
|||
|
||||
{
|
||||
demande: unread_notifications.select(&:demande?).present?,
|
||||
instruction: unread_notifications.select(&:instruction?).present?,
|
||||
messagerie: unread_notifications.select(&:messagerie?).present?
|
||||
avis: unread_notifications.select(&:avis?).present?,
|
||||
messagerie: unread_notifications.select(&:messagerie?).present?,
|
||||
annotations_privees: unread_notifications.select(&:annotations_privees?).present?
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -5,30 +5,37 @@ class Notification < ActiveRecord::Base
|
|||
piece_justificative: 'piece_justificative',
|
||||
champs: 'champs',
|
||||
submitted: 'submitted',
|
||||
avis: 'avis'
|
||||
avis: 'avis',
|
||||
annotations_privees: 'annotations_privees'
|
||||
}
|
||||
|
||||
DEMANDE = %w(cerfa piece_justificative champs submitted)
|
||||
INSTRUCTION = %w(avis)
|
||||
AVIS = %w(avis)
|
||||
MESSAGERIE = %w(commentaire)
|
||||
ANNOTATIONS_PRIVEES = %w(annotations_privees)
|
||||
|
||||
belongs_to :dossier
|
||||
|
||||
scope :unread, -> { where(already_read: false) }
|
||||
scope :demande, -> { where(type_notif: DEMANDE) }
|
||||
scope :instruction, -> { where(type_notif: INSTRUCTION) }
|
||||
scope :messagerie, -> { where(type_notif: MESSAGERIE) }
|
||||
scope :mark_as_read, -> { update_all(already_read: true) }
|
||||
scope :unread, -> { where(already_read: false) }
|
||||
scope :demande, -> { where(type_notif: DEMANDE) }
|
||||
scope :avis, -> { where(type_notif: AVIS) }
|
||||
scope :messagerie, -> { where(type_notif: MESSAGERIE) }
|
||||
scope :annotations_privees, -> { where(type_notif: ANNOTATIONS_PRIVEES) }
|
||||
scope :mark_as_read, -> { update_all(already_read: true) }
|
||||
|
||||
def demande?
|
||||
Notification::DEMANDE.include?(type_notif)
|
||||
end
|
||||
|
||||
def instruction?
|
||||
Notification::INSTRUCTION.include?(type_notif)
|
||||
def avis?
|
||||
Notification::AVIS.include?(type_notif)
|
||||
end
|
||||
|
||||
def messagerie?
|
||||
Notification::MESSAGERIE.include?(type_notif)
|
||||
end
|
||||
|
||||
def annotations_privees?
|
||||
Notification::ANNOTATIONS_PRIVEES.include?(type_notif)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,10 +15,14 @@
|
|||
- if notifications_summary[:demande]
|
||||
%span.notifications{ 'aria-label': 'notifications' }
|
||||
= link_to "Demande", dossier_path(dossier.procedure, dossier)
|
||||
%li{ class: current_page?(instruction_dossier_path(dossier.procedure, dossier)) ? 'active' : nil }
|
||||
- if notifications_summary[:instruction]
|
||||
%li{ class: current_page?(annotations_privees_dossier_path(dossier.procedure, dossier)) ? 'active' : nil }
|
||||
- if notifications_summary[:annotations_privees]
|
||||
%span.notifications{ 'aria-label': 'notifications' }
|
||||
= link_to "Instruction", instruction_dossier_path(dossier.procedure, dossier)
|
||||
= link_to "Annotations Privées", annotations_privees_dossier_path(dossier.procedure, dossier)
|
||||
%li{ class: current_page?(avis_dossier_path(dossier.procedure, dossier)) ? 'active' : nil }
|
||||
- if notifications_summary[:avis]
|
||||
%span.notifications{ 'aria-label': 'notifications' }
|
||||
= link_to "Avis Externes", avis_dossier_path(dossier.procedure, dossier)
|
||||
%li{ class: current_page?(messagerie_dossier_path(dossier.procedure, dossier)) ? 'active' : nil }
|
||||
- if notifications_summary[:messagerie]
|
||||
%span.notifications{ 'aria-label': 'notifications' }
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
= render partial: "header", locals: { dossier: @dossier }
|
||||
|
||||
#dossier-annotations-privees.container
|
||||
- if @dossier.ordered_champs_private.present?
|
||||
%section
|
||||
%h1.private-annotations Annotations privées
|
||||
.card.featured
|
||||
= form_for @dossier, url: annotations_dossier_path(@dossier.procedure, @dossier), html: { class: 'form' } do |f|
|
||||
= f.fields_for :champs_private, f.object.ordered_champs_private do |champ_form|
|
||||
- champ = champ_form.object
|
||||
= render partial: "new_gestionnaire/dossiers/champs/#{champ.type_champ}",
|
||||
locals: { champ: champ, form: champ_form }
|
||||
|
||||
.send-wrapper
|
||||
= f.submit 'Sauvegarder', class: 'button send'
|
||||
|
||||
- else
|
||||
%h2.empty-text Aucune annotation privée
|
|
@ -1,6 +1,6 @@
|
|||
= render partial: "header", locals: { dossier: @dossier }
|
||||
|
||||
#dossier-instruction.container
|
||||
.container
|
||||
%section.ask-avis
|
||||
%h1 Inviter une personne à donner son avis
|
||||
%p.avis-notice L'invité pourra consulter, donner un avis sur le dossier et contribuer au fil de messagerie, mais il ne pourra le modifier.
|
||||
|
@ -16,16 +16,3 @@
|
|||
= f.submit 'Demander un avis', class: 'button send'
|
||||
|
||||
= render partial: 'new_gestionnaire/avis/avis_list', locals: { avis: @dossier.avis }
|
||||
|
||||
- if @dossier.ordered_champs_private.present?
|
||||
%section
|
||||
%h1.private-annotations Annotations privées
|
||||
.card.featured
|
||||
= form_for @dossier, url: annotations_dossier_path(@dossier.procedure, @dossier), html: { class: 'form' } do |f|
|
||||
= f.fields_for :champs_private, f.object.ordered_champs_private do |champ_form|
|
||||
- champ = champ_form.object
|
||||
= render partial: "new_gestionnaire/dossiers/champs/#{champ.type_champ}",
|
||||
locals: { champ: champ, form: champ_form }
|
||||
|
||||
.send-wrapper
|
||||
= f.submit 'Sauvegarder', class: 'button send'
|
|
@ -243,7 +243,8 @@ Rails.application.routes.draw do
|
|||
member do
|
||||
get 'attestation'
|
||||
get 'messagerie'
|
||||
get 'instruction'
|
||||
get 'annotations-privees' => 'dossiers#annotations_privees'
|
||||
get 'avis'
|
||||
patch 'follow'
|
||||
patch 'unfollow'
|
||||
patch 'archive'
|
||||
|
|
|
@ -74,28 +74,34 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
it { expect(response).to redirect_to(procedures_url) }
|
||||
end
|
||||
|
||||
describe '#show #messagerie #instruction' do
|
||||
describe '#show #messagerie #annotations_privees #avis' do
|
||||
before do
|
||||
dossier.notifications = %w(champs avis commentaire).map{ |type| Notification.create!(type_notif: type) }
|
||||
dossier.notifications = %w(champs annotations_privees avis commentaire).map{ |type| Notification.create!(type_notif: type) }
|
||||
get method, params: { procedure_id: procedure.id, dossier_id: dossier.id }
|
||||
dossier.notifications.each(&:reload)
|
||||
end
|
||||
|
||||
context '#show' do
|
||||
let(:method) { :show }
|
||||
it { expect(dossier.notifications.map(&:already_read)).to match([true, false, false]) }
|
||||
it { expect(dossier.notifications.map(&:already_read)).to match([true, false, false, false]) }
|
||||
it { expect(response).to have_http_status(:success) }
|
||||
end
|
||||
|
||||
context '#instruction' do
|
||||
let(:method) { :instruction }
|
||||
it { expect(dossier.notifications.map(&:already_read)).to match([false, true, false]) }
|
||||
context '#annotations_privees' do
|
||||
let(:method) { :annotations_privees }
|
||||
it { expect(dossier.notifications.map(&:already_read)).to match([false, true, false, false]) }
|
||||
it { expect(response).to have_http_status(:success) }
|
||||
end
|
||||
|
||||
context '#avis' do
|
||||
let(:method) { :avis }
|
||||
it { expect(dossier.notifications.map(&:already_read)).to match([false, false, true, false]) }
|
||||
it { expect(response).to have_http_status(:success) }
|
||||
end
|
||||
|
||||
context '#messagerie' do
|
||||
let(:method) { :messagerie }
|
||||
it { expect(dossier.notifications.map(&:already_read)).to match([false, false, true]) }
|
||||
it { expect(dossier.notifications.map(&:already_read)).to match([false, false, false, true]) }
|
||||
it { expect(response).to have_http_status(:success) }
|
||||
end
|
||||
end
|
||||
|
@ -133,7 +139,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
it { expect(saved_avis.confidentiel).to eq(true) }
|
||||
it { expect(saved_avis.dossier).to eq(dossier) }
|
||||
it { expect(saved_avis.claimant).to eq(gestionnaire) }
|
||||
it { expect(response).to redirect_to(instruction_dossier_path(dossier.procedure, dossier)) }
|
||||
it { expect(response).to redirect_to(avis_dossier_path(dossier.procedure, dossier)) }
|
||||
end
|
||||
|
||||
describe "#update_annotations" do
|
||||
|
@ -179,6 +185,6 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
|
||||
it { expect(champ_multiple_drop_down_list.value).to eq('["un", "deux"]') }
|
||||
it { expect(champ_datetime.value).to eq('21/12/2019 13:17') }
|
||||
it { expect(response).to redirect_to(instruction_dossier_path(dossier.procedure, dossier)) }
|
||||
it { expect(response).to redirect_to(annotations_privees_dossier_path(dossier.procedure, dossier)) }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue