Merge branch 'develop' into staging
This commit is contained in:
commit
f7d6f013f1
23 changed files with 166 additions and 70 deletions
|
@ -5,7 +5,7 @@
|
|||
};
|
||||
|
||||
var showData = function(data) {
|
||||
$('.dossier-link .procedureLibelle').text(data.procedureLibelle);
|
||||
$('.dossier-link .dossier-text-summary').text(data.textSummary);
|
||||
$('.dossier-link .text-info').show();
|
||||
$('.dossier-link .text-warning').hide();
|
||||
};
|
||||
|
@ -18,7 +18,7 @@
|
|||
var fetchProcedureLibelle = function(e) {
|
||||
var dossierId = $(e.target).val();
|
||||
if(dossierId) {
|
||||
$.get('/users/dossiers/' + dossierId + '/procedure_libelle')
|
||||
$.get('/users/dossiers/' + dossierId + '/text_summary')
|
||||
.done(showData)
|
||||
.fail(showNotFound);
|
||||
} else {
|
||||
|
|
|
@ -164,9 +164,9 @@ class Users::DossiersController < UsersController
|
|||
redirect_to url_for users_dossiers_path
|
||||
end
|
||||
|
||||
def procedure_libelle
|
||||
def text_summary
|
||||
dossier = Dossier.find(params[:dossier_id])
|
||||
render json: { procedureLibelle: dossier.procedure.libelle }
|
||||
render json: { textSummary: dossier.text_summary }
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render json: {}, status: 404
|
||||
end
|
||||
|
|
|
@ -278,6 +278,28 @@ class Dossier < ActiveRecord::Base
|
|||
!(procedure.archived && draft?)
|
||||
end
|
||||
|
||||
def text_summary
|
||||
if brouillon?
|
||||
parts = [
|
||||
"Dossier en brouillon répondant à la démarche ",
|
||||
procedure.libelle,
|
||||
", gérée par l'organisme ",
|
||||
procedure.organisation
|
||||
]
|
||||
else
|
||||
parts = [
|
||||
"Dossier déposé le ",
|
||||
initiated_at.strftime("%d/%m/%Y"),
|
||||
", sur la démarche ",
|
||||
procedure.libelle,
|
||||
", gérée par l'organisme ",
|
||||
procedure.organisation
|
||||
]
|
||||
end
|
||||
|
||||
parts.join
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def update_state_dates
|
||||
|
|
|
@ -98,6 +98,10 @@ class Gestionnaire < ActiveRecord::Base
|
|||
0
|
||||
end
|
||||
|
||||
def dossiers_with_notifications_count
|
||||
notifications.pluck(:dossier_id).uniq.count
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def valid_couple_table_attr? table, column
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
class Notification < ActiveRecord::Base
|
||||
belongs_to :dossier
|
||||
|
||||
# after_save :broadcast_notification
|
||||
|
||||
enum type_notif: {
|
||||
commentaire: 'commentaire',
|
||||
cerfa: 'cerfa',
|
||||
|
@ -10,10 +7,5 @@ class Notification < ActiveRecord::Base
|
|||
champs: 'champs',
|
||||
submitted: 'submitted'
|
||||
}
|
||||
|
||||
# def broadcast_notification
|
||||
# ActionCable.server.broadcast 'notifications',
|
||||
# message: "Dossier nº #{self.dossier.id} : #{self.liste.last}",
|
||||
# dossier: {id: self.dossier.id}
|
||||
# end
|
||||
scope :unread, -> { where(already_read: false) }
|
||||
end
|
||||
|
|
|
@ -3,6 +3,7 @@ class Procedure < ActiveRecord::Base
|
|||
has_many :types_de_champ, class_name: 'TypeDeChampPublic', dependent: :destroy
|
||||
has_many :types_de_champ_private, dependent: :destroy
|
||||
has_many :dossiers
|
||||
has_many :notifications, through: :dossiers
|
||||
|
||||
has_one :procedure_path, dependent: :destroy
|
||||
|
||||
|
@ -47,6 +48,8 @@ class Procedure < ActiveRecord::Base
|
|||
end
|
||||
|
||||
scope :not_archived, -> { where(archived: false) }
|
||||
scope :by_libelle, -> { order(libelle: :asc) }
|
||||
|
||||
|
||||
def path
|
||||
procedure_path.path unless procedure_path.nil?
|
||||
|
|
|
@ -39,11 +39,13 @@
|
|||
.col-xs-5.depositaire-info{ id: "champ-#{champ.id}-value" }
|
||||
- unless champ.decorate.value.blank?
|
||||
- if champ.type_champ == 'dossier_link'
|
||||
- dossier = Dossier.find_by(id: champ.decorate.value)
|
||||
- if dossier && gestionnaire_signed_in?
|
||||
= link_to(dossier.procedure.libelle, backoffice_dossier_path(champ.decorate.value), target: '_blank')
|
||||
- dossier = Dossier.includes(:procedure).find_by(id: champ.decorate.value)
|
||||
- if dossier
|
||||
= link_to("Dossier #{dossier.id}", backoffice_dossier_path(champ.decorate.value), target: '_blank')
|
||||
%br
|
||||
= dossier.text_summary
|
||||
- else
|
||||
= dossier.nil? ? 'pas de dossier associé' : dossier.procedure.libelle
|
||||
Pas de dossier associé
|
||||
- else
|
||||
= champ.decorate.value.html_safe
|
||||
|
||||
|
|
|
@ -1,42 +1,42 @@
|
|||
%div#first-block
|
||||
#first-block
|
||||
.dossiers-en-cours
|
||||
.count= @facade_data_view.total_dossier_follow
|
||||
.count= current_gestionnaire.dossiers_follow.count
|
||||
.text SUIVIS
|
||||
.nouveaux-dossiers
|
||||
.count= @facade_data_view.total_new_dossier
|
||||
.count= current_gestionnaire.dossiers.nouveaux.count
|
||||
.text NOUVEAUX
|
||||
.nouvelles-notifications
|
||||
.count= @facade_data_view.dossiers_with_unread_notifications.count
|
||||
.count= current_gestionnaire.dossiers_with_notifications_count
|
||||
.text MODIFIÉS
|
||||
|
||||
%div#action-block
|
||||
#action-block
|
||||
|
||||
%div#menu-block
|
||||
#menu-block
|
||||
.split-hr-left
|
||||
#switch-buttons
|
||||
#switch-procedures.active Procédures
|
||||
#switch-notifications Notifications
|
||||
|
||||
%div#infos-block
|
||||
#infos-block
|
||||
.split-hr-left
|
||||
#procedure-list
|
||||
- @facade_data_view.gestionnaire_procedures_name_and_id_list.each do |procedure|
|
||||
|
||||
= link_to backoffice_dossiers_procedure_path(procedure[:id]), { title: procedure[:libelle] } do
|
||||
.procedure-list-element{ class: ('active' if procedure[:id] == @facade_data_view.procedure.id rescue '') }
|
||||
= truncate(procedure[:libelle], length: 50)
|
||||
- total_new = @facade_data_view.new_dossier_number procedure[:id]
|
||||
- current_gestionnaire.procedures.by_libelle.each do |procedure|
|
||||
= link_to backoffice_dossiers_procedure_path(procedure.id), { title: procedure.libelle } do
|
||||
.procedure-list-element{ class: ('active' if procedure.id.to_s == params[:id]) }
|
||||
= procedure.libelle.truncate(50)
|
||||
- total_new = procedure.dossiers.nouveaux.count
|
||||
- if total_new > 0
|
||||
.badge.progress-bar-success{ title: 'Nouveaux dossiers' }
|
||||
= total_new
|
||||
- if procedure[:unread_notifications] > 0
|
||||
- unread_notif_count = procedure.notifications.unread.count
|
||||
- if unread_notif_count > 0
|
||||
.badge.progress-bar-warning{ title: 'Notifications' }
|
||||
= procedure[:unread_notifications]
|
||||
= unread_notif_count
|
||||
#notifications-list.hidden
|
||||
- if @facade_data_view.dossiers_with_unread_notifications.empty?
|
||||
- if current_gestionnaire.notifications.empty?
|
||||
.no-notification Aucune notification pour le moment.
|
||||
- else
|
||||
- @facade_data_view.dossiers_with_unread_notifications.each do |dossier|
|
||||
- current_gestionnaire.notifications.includes(:dossier).map(&:dossier).uniq.each do |dossier|
|
||||
= link_to backoffice_dossier_path(dossier.id) do
|
||||
.notification
|
||||
.dossier-index= "Dossier nº #{dossier.id}"
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
- dossier = Dossier.find_by(id: champ.value)
|
||||
- show_procedure_libelle = dossier ? true : false
|
||||
- show_warning = !show_procedure_libelle && champ.value.present?
|
||||
- procedure_libelle = dossier.nil? ? '' : dossier.procedure.libelle
|
||||
- show_text_summary = dossier.present?
|
||||
- show_warning = !show_text_summary && champ.value.present?
|
||||
- text_summary = dossier.try(:text_summary)
|
||||
|
||||
.dossier-link
|
||||
%input.form-control{ name: "champs['#{ champ.id }']",
|
||||
placeholder: champ.libelle,
|
||||
placeholder: "Numéro de dossier",
|
||||
id: "champs_#{ champ.id }",
|
||||
value: champ.value,
|
||||
type: 'number',
|
||||
|
@ -13,9 +13,8 @@
|
|||
'data-type' => 'dossier-link' }
|
||||
|
||||
.help-block
|
||||
%p.text-info{ style: show_procedure_libelle ? nil : 'display: none;' }
|
||||
ce dossier répond à la procédure :
|
||||
%br
|
||||
%span.procedureLibelle= procedure_libelle
|
||||
%p.text-info{ style: show_text_summary ? nil : 'display: none;' }
|
||||
%span.dossier-text-summary= text_summary
|
||||
|
||||
%p.text-warning{ style: show_warning ? nil : 'display: none;' }
|
||||
ce dossier est inconnu
|
||||
Ce dossier est inconnu
|
||||
|
|
|
@ -95,7 +95,7 @@ Rails.application.routes.draw do
|
|||
post '/siret_informations' => 'dossiers#siret_informations'
|
||||
put '/change_siret' => 'dossiers#change_siret'
|
||||
|
||||
get 'procedure_libelle' => 'dossiers#procedure_libelle'
|
||||
get 'text_summary' => 'dossiers#text_summary'
|
||||
end
|
||||
resource :dossiers
|
||||
end
|
||||
|
|
|
@ -554,27 +554,27 @@ describe Users::DossiersController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'Get #procedure_libelle' do
|
||||
describe 'Get #text_summary' do
|
||||
let!(:dossier) { create(:dossier, procedure: procedure) }
|
||||
|
||||
context 'when user is connected' do
|
||||
before { sign_in user }
|
||||
|
||||
context 'when the dossier exist' do
|
||||
before { get :procedure_libelle, params: { dossier_id: dossier.id } }
|
||||
before { get :text_summary, params: { dossier_id: dossier.id } }
|
||||
it 'returns the procedure name' do
|
||||
expect(JSON.parse(response.body)).to eq('procedureLibelle' => procedure.libelle)
|
||||
expect(JSON.parse(response.body)).to eq("textSummary" => "Dossier en brouillon répondant à la démarche #{procedure.libelle}, gérée par l'organisme #{procedure.organisation}")
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the dossier does not exist' do
|
||||
before { get :procedure_libelle, params: { dossier_id: 666 } }
|
||||
before { get :text_summary, params: { dossier_id: 666 } }
|
||||
it { expect(response.code).to eq('404') }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when user is not connected' do
|
||||
before { get :procedure_libelle, params: { dossier_id: dossier.id } }
|
||||
before { get :text_summary, params: { dossier_id: dossier.id } }
|
||||
it { expect(response.code).to eq('302') }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -55,6 +55,17 @@ FactoryGirl.define do
|
|||
archived false
|
||||
end
|
||||
|
||||
trait :with_dossier_link do
|
||||
after(:create) do |dossier, _evaluator|
|
||||
linked_dossier = create(:dossier)
|
||||
type_de_champ = dossier.procedure.types_de_champ.find { |t| t.type_champ == 'dossier_link' }
|
||||
champ = dossier.champs.find { |c| c.type_de_champ == type_de_champ }
|
||||
|
||||
champ.value = linked_dossier.id
|
||||
champ.save!
|
||||
end
|
||||
end
|
||||
|
||||
trait :replied do
|
||||
state 'replied'
|
||||
end
|
||||
|
|
|
@ -61,6 +61,14 @@ FactoryGirl.define do
|
|||
end
|
||||
end
|
||||
|
||||
trait :with_dossier_link do
|
||||
after(:build) do |procedure, _evaluator|
|
||||
type_de_champ = create(:type_de_champ_public, :type_dossier_link)
|
||||
|
||||
procedure.types_de_champ << type_de_champ
|
||||
end
|
||||
end
|
||||
|
||||
trait :with_two_type_de_piece_justificative do
|
||||
after(:build) do |procedure, _evaluator|
|
||||
rib = create(:type_de_piece_justificative, :rib, order_place: 1)
|
||||
|
|
|
@ -9,5 +9,10 @@ FactoryGirl.define do
|
|||
trait :checkbox do
|
||||
type_champ 'checkbox'
|
||||
end
|
||||
|
||||
trait :type_dossier_link do
|
||||
libelle 'Référence autre dossier'
|
||||
type_champ 'dossier_link'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,8 +3,8 @@ require 'spec_helper'
|
|||
feature 'As a User I want to edit a dossier I own' do
|
||||
|
||||
let(:user) { create(:user) }
|
||||
let(:procedure_for_individual) { create(:procedure, :published, :for_individual, :with_type_de_champ, :with_two_type_de_piece_justificative) }
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, :for_individual, procedure: procedure_for_individual, user: user, autorisation_donnees: true, state: 'initiated') }
|
||||
let(:procedure_for_individual) { create(:procedure, :published, :for_individual, :with_type_de_champ, :with_two_type_de_piece_justificative, :with_dossier_link) }
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, :for_individual, :with_dossier_link, procedure: procedure_for_individual, user: user, autorisation_donnees: true, state: 'initiated') }
|
||||
|
||||
before "Create dossier and visit root path" do
|
||||
login_as user, scope: :user
|
||||
|
@ -23,7 +23,7 @@ feature 'As a User I want to edit a dossier I own' do
|
|||
end
|
||||
|
||||
scenario 'Getting a dossier, I want to create a new message on', js: true do
|
||||
page.find_by_id('tr_dossier_' + Dossier.last.id.to_s).click
|
||||
page.find_by_id('tr_dossier_' + dossier.id.to_s).click
|
||||
expect(page).to have_current_path(users_dossier_recapitulatif_path(Dossier.first.id.to_s), only_path: true)
|
||||
page.find_by_id('open-message').click
|
||||
page.execute_script("$('#texte_commentaire').data('wysihtml5').editor.setValue('Contenu du nouveau message')")
|
||||
|
@ -34,12 +34,17 @@ feature 'As a User I want to edit a dossier I own' do
|
|||
scenario 'On the same dossier, I want to edit informations', js: true do
|
||||
page.find_by_id('tr_dossier_' + dossier.id.to_s).click
|
||||
expect(page).to have_current_path(users_dossier_recapitulatif_path(dossier.id.to_s), only_path: true)
|
||||
|
||||
# Linked Dossier
|
||||
linked_dossier_id = dossier.champs.find { |c| c.type_de_champ.type_champ == 'dossier_link' }.value
|
||||
expect(page).to have_link("Dossier #{linked_dossier_id}")
|
||||
|
||||
page.find_by_id('maj_infos').trigger('click')
|
||||
expect(page).to have_current_path(users_dossier_description_path(dossier.id.to_s), only_path: true)
|
||||
fill_in "champs_#{dossier.champs.first.id.to_s}", with: 'Contenu du champ 1'
|
||||
fill_in "champs_#{dossier.champs.order(:id).first.id.to_s}", with: 'Contenu du champ 1'
|
||||
page.find_by_id('modification_terminee').click
|
||||
expect(page).to have_current_path(users_dossier_recapitulatif_path(dossier.id.to_s), only_path: true)
|
||||
expect(page.find("#champ-#{dossier.champs.first.id}-value").text).to eq('Contenu du champ 1')
|
||||
expect(page.find("#champ-#{dossier.champs.order(:id).first.id}-value").text).to eq('Contenu du champ 1')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
xfeature 'As a User I want to sort and paginate dossiers', js: true do
|
||||
feature 'As a User I want to sort and paginate dossiers', js: true do
|
||||
|
||||
let(:user) { create(:user) }
|
||||
let(:procedure_for_individual) { create(:procedure, :published, :for_individual) }
|
||||
|
|
|
@ -809,6 +809,26 @@ describe Dossier do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#text_summary" do
|
||||
let(:procedure) { create(:procedure, libelle: "Démarche", organisation: "Organisation") }
|
||||
|
||||
context 'when the dossier has been initiated' do
|
||||
let(:dossier) { create :dossier, procedure: procedure, state: 'initiated', initiated_at: "31/12/2010".to_date }
|
||||
|
||||
subject { dossier.text_summary }
|
||||
|
||||
it { is_expected.to eq("Dossier déposé le 31/12/2010, sur la démarche Démarche, gérée par l'organisme Organisation") }
|
||||
end
|
||||
|
||||
context 'when the dossier has not been initiated' do
|
||||
let(:dossier) { create :dossier, procedure: procedure, state: 'draft' }
|
||||
|
||||
subject { dossier.text_summary }
|
||||
|
||||
it { is_expected.to eq("Dossier en brouillon répondant à la démarche Démarche, gérée par l'organisme Organisation") }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#update_state_dates' do
|
||||
let(:state) { 'draft' }
|
||||
let(:dossier) { create(:dossier, state: state) }
|
||||
|
|
|
@ -272,6 +272,37 @@ describe Gestionnaire, type: :model do
|
|||
it { is_expected.to be_nil }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#dossiers_with_notifications_count' do
|
||||
subject { gestionnaire.dossiers_with_notifications_count }
|
||||
|
||||
context 'when there is no notifications' do
|
||||
it { is_expected.to eq(0) }
|
||||
end
|
||||
|
||||
context 'when there is one notification for one dossier' do
|
||||
let(:notification){ create(:notification, already_read: false) }
|
||||
let!(:follow){ create(:follow, dossier: notification.dossier, gestionnaire: gestionnaire) }
|
||||
|
||||
it { is_expected.to eq(1) }
|
||||
end
|
||||
|
||||
context 'when there are many notifications for one dossier' do
|
||||
let(:notification){ create(:notification, already_read: false) }
|
||||
let(:notification2){ create(:notification, already_read: false, dossier: notification.dossier) }
|
||||
let!(:follow){ create(:follow, dossier: notification.dossier, gestionnaire: gestionnaire) }
|
||||
|
||||
it { is_expected.to eq(1) }
|
||||
end
|
||||
|
||||
context 'when there are many notifications for many dossiers' do
|
||||
let(:notification){ create(:notification, already_read: false) }
|
||||
let(:notification2){ create(:notification, already_read: false) }
|
||||
let!(:follow){ create(:follow, dossier: notification.dossier, gestionnaire: gestionnaire) }
|
||||
let!(:follow2){ create(:follow, dossier: notification2.dossier, gestionnaire: gestionnaire) }
|
||||
|
||||
it { is_expected.to eq(2) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,8 +22,4 @@ describe NotificationService do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'text_for_notif' do
|
||||
pending
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,8 +16,4 @@ describe RenderPartialService do
|
|||
|
||||
it { is_expected.to eq 'layouts/left_panels/left_panel_'+controller.to_s.parameterize + '_' + method.to_s }
|
||||
end
|
||||
|
||||
describe 'left_panel_exist?' do
|
||||
pending
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,6 +7,14 @@ describe 'users/description/champs/dossier_link.html.haml', type: :view do
|
|||
render 'users/description/champs/dossier_link.html.haml', champ: champ
|
||||
end
|
||||
|
||||
context 'in all cases' do
|
||||
let!(:champ) { create(:champ, type_de_champ: type_champ, value: nil) }
|
||||
|
||||
it 'should render an input for the dossier link' do
|
||||
expect(rendered).to have_css("input[type=number][placeholder='Numéro de dossier']")
|
||||
end
|
||||
end
|
||||
|
||||
context 'When no dossier is provided' do
|
||||
let!(:champ) { create(:champ, type_de_champ: type_champ, value: nil) }
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ describe 'users/description/champs/render_list_champs.html.haml', type: :view do
|
|||
render 'users/description/champs/render_list_champs.html.haml', champs: Champ.all, order_place: 0
|
||||
end
|
||||
|
||||
it 'should render a number input with the right data-attribute' do
|
||||
it 'should render the _dossier_link partial' do
|
||||
expect(view).to render_template(partial: 'users/description/champs/_dossier_link',
|
||||
locals: { champ: champ })
|
||||
end
|
||||
|
|
|
@ -24,12 +24,6 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
|
|||
expect(rendered).to have_selector('#messages')
|
||||
end
|
||||
|
||||
it 'le numéro de dossier est présent' do
|
||||
pending 'move to test layout'
|
||||
expect(rendered).to have_selector('#dossier_id')
|
||||
expect(rendered).to have_content(dossier_id)
|
||||
end
|
||||
|
||||
describe 'les liens de modifications' do
|
||||
context 'lien description' do
|
||||
it 'le lien vers description est présent' do
|
||||
|
|
Loading…
Reference in a new issue