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 "common";
|
||||||
@import "constants";
|
@import "constants";
|
||||||
|
|
||||||
#dossier-instruction {
|
#dossier-annotations-privees {
|
||||||
h1 {
|
h1 {
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
|
@ -14,9 +14,14 @@ module NewGestionnaire
|
||||||
dossier.notifications.messagerie.mark_as_read
|
dossier.notifications.messagerie.mark_as_read
|
||||||
end
|
end
|
||||||
|
|
||||||
def instruction
|
def annotations_privees
|
||||||
@dossier = dossier
|
@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
|
end
|
||||||
|
|
||||||
def follow
|
def follow
|
||||||
|
@ -67,13 +72,13 @@ module NewGestionnaire
|
||||||
|
|
||||||
def create_avis
|
def create_avis
|
||||||
Avis.create(avis_params.merge(claimant: current_gestionnaire, dossier: dossier))
|
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
|
end
|
||||||
|
|
||||||
def update_annotations
|
def update_annotations
|
||||||
dossier = current_gestionnaire.dossiers.includes(champs_private: :type_de_champ).find(params[:dossier_id])
|
dossier = current_gestionnaire.dossiers.includes(champs_private: :type_de_champ).find(params[:dossier_id])
|
||||||
dossier.update_attributes(champs_private_params)
|
dossier.update_attributes(champs_private_params)
|
||||||
redirect_to instruction_dossier_path(dossier.procedure, dossier)
|
redirect_to annotations_privees_dossier_path(dossier.procedure, dossier)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -83,8 +83,12 @@ class Champ < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def internal_notification
|
def internal_notification
|
||||||
unless dossier.state == 'draft'
|
if dossier.state != 'draft'
|
||||||
|
if type == 'ChampPublic'
|
||||||
NotificationService.new('champs', self.dossier.id, self.libelle).notify
|
NotificationService.new('champs', self.dossier.id, self.libelle).notify
|
||||||
|
else
|
||||||
|
NotificationService.new('annotations_privees', self.dossier.id, self.libelle).notify
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -96,8 +96,9 @@ class Dossier < ActiveRecord::Base
|
||||||
|
|
||||||
{
|
{
|
||||||
demande: unread_notifications.select(&:demande?).present?,
|
demande: unread_notifications.select(&:demande?).present?,
|
||||||
instruction: unread_notifications.select(&:instruction?).present?,
|
avis: unread_notifications.select(&:avis?).present?,
|
||||||
messagerie: unread_notifications.select(&:messagerie?).present?
|
messagerie: unread_notifications.select(&:messagerie?).present?,
|
||||||
|
annotations_privees: unread_notifications.select(&:annotations_privees?).present?
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,30 +5,37 @@ class Notification < ActiveRecord::Base
|
||||||
piece_justificative: 'piece_justificative',
|
piece_justificative: 'piece_justificative',
|
||||||
champs: 'champs',
|
champs: 'champs',
|
||||||
submitted: 'submitted',
|
submitted: 'submitted',
|
||||||
avis: 'avis'
|
avis: 'avis',
|
||||||
|
annotations_privees: 'annotations_privees'
|
||||||
}
|
}
|
||||||
|
|
||||||
DEMANDE = %w(cerfa piece_justificative champs submitted)
|
DEMANDE = %w(cerfa piece_justificative champs submitted)
|
||||||
INSTRUCTION = %w(avis)
|
AVIS = %w(avis)
|
||||||
MESSAGERIE = %w(commentaire)
|
MESSAGERIE = %w(commentaire)
|
||||||
|
ANNOTATIONS_PRIVEES = %w(annotations_privees)
|
||||||
|
|
||||||
belongs_to :dossier
|
belongs_to :dossier
|
||||||
|
|
||||||
scope :unread, -> { where(already_read: false) }
|
scope :unread, -> { where(already_read: false) }
|
||||||
scope :demande, -> { where(type_notif: DEMANDE) }
|
scope :demande, -> { where(type_notif: DEMANDE) }
|
||||||
scope :instruction, -> { where(type_notif: INSTRUCTION) }
|
scope :avis, -> { where(type_notif: AVIS) }
|
||||||
scope :messagerie, -> { where(type_notif: MESSAGERIE) }
|
scope :messagerie, -> { where(type_notif: MESSAGERIE) }
|
||||||
|
scope :annotations_privees, -> { where(type_notif: ANNOTATIONS_PRIVEES) }
|
||||||
scope :mark_as_read, -> { update_all(already_read: true) }
|
scope :mark_as_read, -> { update_all(already_read: true) }
|
||||||
|
|
||||||
def demande?
|
def demande?
|
||||||
Notification::DEMANDE.include?(type_notif)
|
Notification::DEMANDE.include?(type_notif)
|
||||||
end
|
end
|
||||||
|
|
||||||
def instruction?
|
def avis?
|
||||||
Notification::INSTRUCTION.include?(type_notif)
|
Notification::AVIS.include?(type_notif)
|
||||||
end
|
end
|
||||||
|
|
||||||
def messagerie?
|
def messagerie?
|
||||||
Notification::MESSAGERIE.include?(type_notif)
|
Notification::MESSAGERIE.include?(type_notif)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def annotations_privees?
|
||||||
|
Notification::ANNOTATIONS_PRIVEES.include?(type_notif)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,10 +15,14 @@
|
||||||
- if notifications_summary[:demande]
|
- if notifications_summary[:demande]
|
||||||
%span.notifications{ 'aria-label': 'notifications' }
|
%span.notifications{ 'aria-label': 'notifications' }
|
||||||
= link_to "Demande", dossier_path(dossier.procedure, dossier)
|
= link_to "Demande", dossier_path(dossier.procedure, dossier)
|
||||||
%li{ class: current_page?(instruction_dossier_path(dossier.procedure, dossier)) ? 'active' : nil }
|
%li{ class: current_page?(annotations_privees_dossier_path(dossier.procedure, dossier)) ? 'active' : nil }
|
||||||
- if notifications_summary[:instruction]
|
- if notifications_summary[:annotations_privees]
|
||||||
%span.notifications{ 'aria-label': 'notifications' }
|
%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 }
|
%li{ class: current_page?(messagerie_dossier_path(dossier.procedure, dossier)) ? 'active' : nil }
|
||||||
- if notifications_summary[:messagerie]
|
- if notifications_summary[:messagerie]
|
||||||
%span.notifications{ 'aria-label': 'notifications' }
|
%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 }
|
= render partial: "header", locals: { dossier: @dossier }
|
||||||
|
|
||||||
#dossier-instruction.container
|
.container
|
||||||
%section.ask-avis
|
%section.ask-avis
|
||||||
%h1 Inviter une personne à donner son 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.
|
%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'
|
= f.submit 'Demander un avis', class: 'button send'
|
||||||
|
|
||||||
= render partial: 'new_gestionnaire/avis/avis_list', locals: { avis: @dossier.avis }
|
= 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
|
member do
|
||||||
get 'attestation'
|
get 'attestation'
|
||||||
get 'messagerie'
|
get 'messagerie'
|
||||||
get 'instruction'
|
get 'annotations-privees' => 'dossiers#annotations_privees'
|
||||||
|
get 'avis'
|
||||||
patch 'follow'
|
patch 'follow'
|
||||||
patch 'unfollow'
|
patch 'unfollow'
|
||||||
patch 'archive'
|
patch 'archive'
|
||||||
|
|
|
@ -74,28 +74,34 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
||||||
it { expect(response).to redirect_to(procedures_url) }
|
it { expect(response).to redirect_to(procedures_url) }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#show #messagerie #instruction' do
|
describe '#show #messagerie #annotations_privees #avis' do
|
||||||
before 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 }
|
get method, params: { procedure_id: procedure.id, dossier_id: dossier.id }
|
||||||
dossier.notifications.each(&:reload)
|
dossier.notifications.each(&:reload)
|
||||||
end
|
end
|
||||||
|
|
||||||
context '#show' do
|
context '#show' do
|
||||||
let(:method) { :show }
|
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) }
|
it { expect(response).to have_http_status(:success) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context '#instruction' do
|
context '#annotations_privees' do
|
||||||
let(:method) { :instruction }
|
let(:method) { :annotations_privees }
|
||||||
it { expect(dossier.notifications.map(&:already_read)).to match([false, true, false]) }
|
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) }
|
it { expect(response).to have_http_status(:success) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context '#messagerie' do
|
context '#messagerie' do
|
||||||
let(:method) { :messagerie }
|
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) }
|
it { expect(response).to have_http_status(:success) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -133,7 +139,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
||||||
it { expect(saved_avis.confidentiel).to eq(true) }
|
it { expect(saved_avis.confidentiel).to eq(true) }
|
||||||
it { expect(saved_avis.dossier).to eq(dossier) }
|
it { expect(saved_avis.dossier).to eq(dossier) }
|
||||||
it { expect(saved_avis.claimant).to eq(gestionnaire) }
|
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
|
end
|
||||||
|
|
||||||
describe "#update_annotations" do
|
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_multiple_drop_down_list.value).to eq('["un", "deux"]') }
|
||||||
it { expect(champ_datetime.value).to eq('21/12/2019 13:17') }
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue