Merge pull request #2154 from betagouv/dev

2018-06-27-01
This commit is contained in:
Frederic Merizen 2018-06-27 10:41:13 +02:00 committed by GitHub
commit d90377a176
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 189 additions and 46 deletions

View file

@ -32,6 +32,9 @@ gem 'haml-rails'
# bootstrap saas # bootstrap saas
gem 'bootstrap-sass', '~> 3.3.5' gem 'bootstrap-sass', '~> 3.3.5'
# Automatically set a class on active links
gem 'active_link_to'
# Pagination # Pagination
gem 'kaminari' gem 'kaminari'

View file

@ -44,6 +44,9 @@ GEM
erubi (~> 1.4) erubi (~> 1.4)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3) rails-html-sanitizer (~> 1.0, >= 1.0.3)
active_link_to (1.0.5)
actionpack
addressable
active_model_serializers (0.10.7) active_model_serializers (0.10.7)
actionpack (>= 4.1, < 6) actionpack (>= 4.1, < 6)
activemodel (>= 4.1, < 6) activemodel (>= 4.1, < 6)
@ -785,6 +788,7 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
aasm aasm
active_link_to
active_model_serializers active_model_serializers
administrate administrate
apipie-rails apipie-rails
@ -877,4 +881,4 @@ DEPENDENCIES
xray-rails xray-rails
BUNDLED WITH BUNDLED WITH
1.16.1 1.16.2

View file

@ -14,3 +14,4 @@ $light-green: lighten($green, 25%);
$dark-green: darken($green, 20%); $dark-green: darken($green, 20%);
$orange: #F28900; $orange: #F28900;
$orange-bg: lighten($orange, 35%); $orange-bg: lighten($orange, 35%);
$light-yellow: #FFFFDE;

View file

@ -6,6 +6,12 @@
border: 1px solid $border-grey; border: 1px solid $border-grey;
margin-bottom: $default-spacer * 2; margin-bottom: $default-spacer * 2;
.card-title {
font-weight: bold;
font-size: 20px;
margin-bottom: $default-spacer * 2;
}
&.featured { &.featured {
border-top: 8px solid $blue; border-top: 8px solid $blue;
@ -14,9 +20,16 @@
} }
} }
.card-title { &.feedback {
font-weight: bold; max-width: 600px;
font-size: 20px; margin: 30px auto;
margin-bottom: $default-spacer * 2; padding: ($default-spacer * 2) ($default-spacer * 4);
font-size: small;
border: 1px dashed $border-grey;
background: $light-yellow;
.card-title {
margin-bottom: $default-spacer;
}
} }
} }

View file

@ -0,0 +1,5 @@
.dossiers-headers {
.new-demarche {
float: right;
}
}

View file

@ -77,3 +77,7 @@
padding-right: $default-spacer; padding-right: $default-spacer;
} }
} }
.dossiers-table-empty {
text-align: center;
}

View file

@ -26,7 +26,7 @@ $landing-breakpoint: 1040px;
margin-right: 4 * $default-spacer; margin-right: 4 * $default-spacer;
img { img {
height: 36px; height: 34px;
@media (max-width: $landing-breakpoint) { @media (max-width: $landing-breakpoint) {
height: 18px; height: 18px;

View file

@ -1,5 +1,7 @@
module NewUser module NewUser
class DossiersController < UserController class DossiersController < UserController
helper_method :new_demarche_url
before_action :ensure_ownership!, except: [:index, :modifier, :update] before_action :ensure_ownership!, except: [:index, :modifier, :update]
before_action :ensure_ownership_or_invitation!, only: [:modifier, :update] before_action :ensure_ownership_or_invitation!, only: [:modifier, :update]
before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update] before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update]
@ -112,6 +114,10 @@ module NewUser
end end
end end
def new_demarche_url
"https://doc.demarches-simplifiees.fr/listes-des-demarches"
end
private private
def ensure_dossier_can_be_updated def ensure_dossier_can_be_updated

View file

@ -13,10 +13,10 @@
%ul.header-tabs %ul.header-tabs
- if current_gestionnaire.visible_procedures.count > 0 - if current_gestionnaire.visible_procedures.count > 0
%li %li
= link_to "Procédures", gestionnaire_procedures_path, class: (controller_name != 'avis') ? "tab-link active" : 'tab-link' = active_link_to "Procédures", gestionnaire_procedures_path, active: :inclusive, class: 'tab-link'
- if current_gestionnaire.avis.count > 0 - if current_gestionnaire.avis.count > 0
%li %li
= link_to gestionnaire_avis_index_path, class: (controller_name == 'avis') ? "tab-link active" : 'tab-link' do = active_link_to gestionnaire_avis_index_path, active: :inclusive, class: 'tab-link' do
Avis Avis
- avis_counter = current_gestionnaire.avis.without_answer.count - avis_counter = current_gestionnaire.avis.without_answer.count
- if avis_counter > 0 - if avis_counter > 0
@ -36,7 +36,7 @@
- if nav_bar_profile == :user - if nav_bar_profile == :user
%ul.header-tabs %ul.header-tabs
%li %li
= link_to "Mes dossiers", users_dossiers_path, class: 'tab-link' = active_link_to "Dossiers", dossiers_path, active: :inclusive, class: 'tab-link'
%ul.header-right-content %ul.header-right-content
- if nav_bar_profile == :gestionnaire && gestionnaire_signed_in? - if nav_bar_profile == :gestionnaire && gestionnaire_signed_in?

View file

@ -1,43 +1,59 @@
.dossiers-headers.sub-header .dossiers-headers.sub-header
.container .container
%h1.page-title Les dossiers = link_to "Commencer une nouvelle démarche", new_demarche_url, class: "button secondary new-demarche"
%ul.tabs - if @dossiers_invites.count == 0
- if @user_dossiers.count > 0 %h1.page-title Mes dossiers
- else
%h1.page-title Dossiers
%ul.tabs
%li{ class: (@current_tab == 'mes-dossiers') ? 'active' : nil }> %li{ class: (@current_tab == 'mes-dossiers') ? 'active' : nil }>
= link_to(dossiers_path(current_tab: 'mes-dossiers')) do = link_to(dossiers_path(current_tab: 'mes-dossiers')) do
mes dossiers mes dossiers
- if @dossiers_invites.count > 0
%li{ class: (@current_tab == 'dossiers-invites') ? 'active' : nil }> %li{ class: (@current_tab == 'dossiers-invites') ? 'active' : nil }>
= link_to(dossiers_path(current_tab: 'dossiers-invites')) do = link_to(dossiers_path(current_tab: 'dossiers-invites')) do
dossiers invités dossiers invités
.container .container
%table.table.dossiers-table.hoverable - if @dossiers.present?
%thead - if @dossiers.total_pages >= 2
%tr .card.feedback
%th.notification-col .card-title Nous avons redesigné la liste des dossiers.
%th.number-col Nº dossier %p
%th Procédure Une suggestion pour améliorer cette page&nbsp;? Votre avis nous intéresse&nbsp;! Écrivez-nous à
%th.status-col Statut = mail_to CONTACT_EMAIL, CONTACT_EMAIL, subject: "Amélioration de la liste des dossiers"
%th.updated-at-col Mis à jour \.
%tbody
- @dossiers.each do |dossier|
%tr
%td.folder-col
= link_to(modifier_dossier_path(dossier), class: 'cell-link') do
%span.icon.folder
%td.number-col
= link_to(modifier_dossier_path(dossier), class: 'cell-link') do
= dossier.id
%td
= link_to(modifier_dossier_path(dossier), class: 'cell-link') do
= dossier.procedure.libelle
%td.status-col
= link_to(modifier_dossier_path(dossier), class: 'cell-link') do
= render partial: 'shared/dossiers/status', locals: { dossier: dossier }
%td.updated-at-col
= link_to(modifier_dossier_path(dossier), class: 'cell-link') do
= dossier.updated_at.localtime.strftime("%d/%m/%Y")
= paginate(@dossiers) %table.table.dossiers-table.hoverable
%thead
%tr
%th.notification-col
%th.number-col Nº dossier
%th Procédure
%th.status-col Statut
%th.updated-at-col Mis à jour
%tbody
- @dossiers.each do |dossier|
%tr
%td.folder-col
= link_to(users_dossier_recapitulatif_path(dossier), class: 'cell-link') do
%span.icon.folder
%td.number-col
= link_to(users_dossier_recapitulatif_path(dossier), class: 'cell-link') do
= dossier.id
%td
= link_to(users_dossier_recapitulatif_path(dossier), class: 'cell-link') do
= dossier.procedure.libelle
%td.status-col
= link_to(users_dossier_recapitulatif_path(dossier), class: 'cell-link') do
= render partial: 'shared/dossiers/status', locals: { dossier: dossier }
%td.updated-at-col
= link_to(users_dossier_recapitulatif_path(dossier), class: 'cell-link') do
= dossier.updated_at.localtime.strftime("%d/%m/%Y")
= paginate(@dossiers)
- else
.dossiers-table-empty
%h2.empty-text Aucun dossier.
= link_to "Commencer une nouvelle démarche", new_demarche_url, class: "button primary"

View file

@ -84,6 +84,11 @@
Titre de la carte mise en avant Titre de la carte mise en avant
Et voici le contenu de la carte Et voici le contenu de la carte
.card.feedback
.card-title
Titre de la carte pour demander un avis
Utilisez cette carte pour informer dune nouveauté produit ou demander lavis des utilisateurs.
%h1 Table %h1 Table
%table.table %table.table

View file

@ -0,0 +1,16 @@
require Rails.root.join("lib", "tasks", "task_helper")
namespace :'2018_06_26_purge_preview_dossiers' do
task run: :environment do
# We use delete_all and manually destroy associations because its so much faster that Champ.where(dossier_id: 0).destroy_all
c_count = Commentaire.joins(:champ).where(champs: { dossier_id: 0 }).delete_all
rake_puts("Deleted #{c_count} commentaires\n")
a_count = ActiveStorage::Attachment.joins('join champs ON active_storage_attachments.record_id = champs.id').where(champs: { dossier_id: 0 }).delete_all
rake_puts("Deleted #{a_count} attachments\n")
v_count = VirusScan.joins(:champ).where(champs: { dossier_id: 0 }).delete_all
rake_puts("Deleted #{v_count} virus scans\n")
ch_count = Champ.where(dossier_id: 0).delete_all
rake_puts("Deleted #{ch_count} champs\n")
end
end

View file

@ -15,6 +15,7 @@ describe 'layouts/_new_header.html.haml', type: :view do
let(:profile) { :user } let(:profile) { :user }
it { is_expected.to have_css("a.header-logo[href=\"#{users_dossiers_path}\"]") } it { is_expected.to have_css("a.header-logo[href=\"#{users_dossiers_path}\"]") }
it { is_expected.to have_link("Dossiers", href: dossiers_path) }
end end
context 'when rendering for gestionnaire' do context 'when rendering for gestionnaire' do

View file

@ -0,0 +1,67 @@
require 'spec_helper'
describe 'new_user/dossiers/index.html.haml', type: :view do
let(:user) { create(:user) }
let(:user_dossiers) { create_list(:dossier, 2, state: 'brouillon', user: user) }
let(:dossiers_invites) { [] }
let(:current_tab) { 'mes-dossiers' }
before do
allow(view).to receive(:new_demarche_url).and_return('#')
assign(:user_dossiers, Kaminari.paginate_array(user_dossiers).page(1))
assign(:dossiers_invites, Kaminari.paginate_array(dossiers_invites).page(1))
assign(:dossiers, Kaminari.paginate_array(user_dossiers).page(1))
assign(:current_tab, current_tab)
render
end
it 'affiche la liste des dossiers' do
expect(rendered).to have_selector('.dossiers-table tbody tr', count: 2)
end
it 'affiche les informations des dossiers' do
dossier = user_dossiers.first
expect(rendered).to have_text(dossier.id)
expect(rendered).to have_text(dossier.procedure.libelle)
expect(rendered).to have_link(dossier.id, href: users_dossier_recapitulatif_path(dossier))
end
context 'quand il ny a aucun dossier' do
let(:user_dossiers) { [] }
let(:dossiers_invites) { [] }
it 'naffiche pas la table' do
expect(rendered).not_to have_selector('.dossiers-table')
end
it 'affiche un message' do
expect(rendered).to have_text('Aucun dossier')
end
end
context 'quand il ny a pas de dossiers invités' do
let(:dossiers_invites) { [] }
it 'affiche un titre adapté' do
expect(rendered).to have_selector('h1', text: 'Mes dossiers')
end
it 'naffiche pas la barre donglets' do
expect(rendered).not_to have_selector('ul.tabs')
end
end
context 'quand il y a des dossiers invités' do
let(:dossiers_invites) { create_list(:dossier, 1) }
it 'affiche un titre adapté' do
expect(rendered).to have_selector('h1', text: 'Dossiers')
end
it 'affiche la barre donglets' do
expect(rendered).to have_selector('ul.tabs')
expect(rendered).to have_selector('ul.tabs li', count: 2)
expect(rendered).to have_selector('ul.tabs li.active', count: 1)
end
end
end

View file

@ -27,14 +27,16 @@ describe 'users/dossiers/index.html.haml', type: :view do
subject { rendered } subject { rendered }
describe 'columns' do it 'displays the total count' do
it { is_expected.to have_content(decorate_dossier_at_check.id) } expect(dossiers_to_display.count).to eq total_dossiers
it { is_expected.to have_content(decorate_dossier_at_check.procedure.libelle) }
it { is_expected.to have_content(decorate_dossier_at_check.display_state) }
it { is_expected.to have_content(decorate_dossier_at_check.last_update) }
end end
it { expect(dossiers_to_display.count).to eq total_dossiers } it 'displays data in columns' do
expect(rendered).to have_content(decorate_dossier_at_check.id)
expect(rendered).to have_content(decorate_dossier_at_check.procedure.libelle)
expect(rendered).to have_content(decorate_dossier_at_check.display_state)
expect(rendered).to have_content(decorate_dossier_at_check.last_update)
end
end end
describe 'on tab en construction' do describe 'on tab en construction' do