Merge pull request #3689 from betagouv/start-new-procedure
Ajouter un bouton "Commencer un autre dossier"
This commit is contained in:
commit
f0bd560fea
15 changed files with 126 additions and 17 deletions
1
app/assets/images/icons/new-folder.svg
Normal file
1
app/assets/images/icons/new-folder.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"><g fill="none" fill-rule="evenodd"><path d="M11 6L9 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2v-6" stroke="#0069cc" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M0 0h24v24H0z"/></g><g transform="translate(8 -8)" fill="#0069cc"><rect ry="1" y="12" x="6" height="2" width="10"/><rect width="2" height="10" x="10" y="8" ry="1"/></g></svg>
|
After Width: | Height: | Size: 446 B |
|
@ -137,6 +137,8 @@
|
|||
position: relative;
|
||||
|
||||
.dropdown-button {
|
||||
white-space: nowrap;
|
||||
|
||||
&::after {
|
||||
content: "▾";
|
||||
margin-left: $default-spacer;
|
||||
|
@ -199,7 +201,7 @@
|
|||
.dropdown-items {
|
||||
li {
|
||||
display: flex;
|
||||
padding: 2 * $default-spacer;
|
||||
padding: $default-padding;
|
||||
color: $grey;
|
||||
border-bottom: 1px solid $border-grey;
|
||||
font-size: 12px;
|
||||
|
@ -219,15 +221,37 @@
|
|||
background: $light-grey;
|
||||
}
|
||||
|
||||
&.danger {
|
||||
&:hover {
|
||||
background-color: $medium-red;
|
||||
|
||||
&,
|
||||
a {
|
||||
color: $white;
|
||||
}
|
||||
|
||||
.icon {
|
||||
filter: contrast(0) brightness(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
a {
|
||||
display: flex;
|
||||
color: $grey;
|
||||
}
|
||||
|
||||
// Make child links fill the whole clickable area
|
||||
> a {
|
||||
display: flex;
|
||||
flex-grow: 1;
|
||||
margin: -$default-padding;
|
||||
padding: $default-padding;
|
||||
}
|
||||
|
||||
.icon {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
|
|
@ -79,8 +79,4 @@
|
|||
.follow-col {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.delete-col {
|
||||
width: 150px;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,10 @@
|
|||
background-image: image-url("icons/folder.svg");
|
||||
}
|
||||
|
||||
&.new-folder {
|
||||
background-image: image-url("icons/new-folder.svg");
|
||||
}
|
||||
|
||||
&.accept {
|
||||
background-image: image-url("icons/accept.svg");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
.user-dossier-actions {
|
||||
.dropdown-description {
|
||||
font-size: 14px;
|
||||
align-self: center;
|
||||
}
|
||||
}
|
|
@ -269,7 +269,7 @@ class Admin::ProceduresController < AdminController
|
|||
end
|
||||
|
||||
def procedure_params
|
||||
editable_params = [:libelle, :description, :organisation, :direction, :lien_site_web, :cadre_juridique, :deliberation, :notice, :web_hook_url, :euro_flag, :logo, :auto_archive_on]
|
||||
editable_params = [:libelle, :description, :organisation, :direction, :lien_site_web, :cadre_juridique, :deliberation, :notice, :expects_multiple_submissions, :web_hook_url, :euro_flag, :logo, :auto_archive_on]
|
||||
if @procedure&.locked?
|
||||
params.require(:procedure).permit(*editable_params)
|
||||
else
|
||||
|
|
|
@ -123,6 +123,10 @@ class Procedure < ApplicationRecord
|
|||
publiee_ou_archivee?
|
||||
end
|
||||
|
||||
def accepts_new_dossiers?
|
||||
!archivee?
|
||||
end
|
||||
|
||||
# This method is needed for transition. Eventually this will be the same as brouillon?.
|
||||
def brouillon_avec_lien?
|
||||
brouillon? && path.present?
|
||||
|
|
|
@ -116,7 +116,16 @@
|
|||
.col-md-6
|
||||
%h4 Options avancées
|
||||
|
||||
- if Flipflop.web_hook?
|
||||
= f.label :expects_multiple_submissions do
|
||||
= f.check_box :expects_multiple_submissions
|
||||
Ajuster pour le dépôt récurrent de dossiers
|
||||
%p.help-block
|
||||
%i.fa.fa-info-circle
|
||||
Si cette démarche est conçue pour qu’une même personne y dépose régulièrement plusieurs
|
||||
dossiers, l’interface est ajustée pour rendre plus facile la création de plusieurs dossiers
|
||||
à la suite.
|
||||
|
||||
- if Flipflop.web_hook?
|
||||
%label{ for: :web_hook_url } Lien de rappel HTTP (webhook)
|
||||
= f.text_field :web_hook_url, class: 'form-control', placeholder: 'https://callback.exemple.fr/'
|
||||
%p.help-block
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
%span.icon.archive
|
||||
%span.icon.unarchive
|
||||
%span.icon.folder
|
||||
%span.icon.new-folder
|
||||
%span.icon.accept
|
||||
%span.icon.refuse
|
||||
%span.icon.without-continuation
|
||||
|
|
24
app/views/users/dossiers/_dossier_actions.html.haml
Normal file
24
app/views/users/dossiers/_dossier_actions.html.haml
Normal file
|
@ -0,0 +1,24 @@
|
|||
- has_delete_action = dossier.can_be_deleted_by_user?
|
||||
- has_new_dossier_action = dossier.procedure.expects_multiple_submissions? && dossier.procedure.accepts_new_dossiers?
|
||||
|
||||
- has_actions = has_delete_action || has_new_dossier_action
|
||||
|
||||
- if has_actions
|
||||
%span.dropdown.user-dossier-actions
|
||||
%button.button.dropdown-button
|
||||
Actions
|
||||
.dropdown-content.fade-in-down
|
||||
%ul.dropdown-items
|
||||
- if has_new_dossier_action
|
||||
%li
|
||||
= link_to procedure_lien(dossier.procedure) do
|
||||
%span.icon.new-folder
|
||||
.dropdown-description
|
||||
Commencer un autre dossier
|
||||
|
||||
- if has_delete_action
|
||||
%li.danger
|
||||
= link_to ask_deletion_dossier_path(dossier), method: :post, data: { disable: true, confirm: "En continuant, vous allez supprimer ce dossier ainsi que les informations qu’il contient. Toute suppression entraine l’annulation de la démarche en cours.\n\nConfirmer la suppression ?" } do
|
||||
%span.icon.delete
|
||||
.dropdown-description
|
||||
Supprimer le dossier
|
|
@ -32,7 +32,7 @@
|
|||
%th
|
||||
%tbody
|
||||
- @dossiers.each do |dossier|
|
||||
%tr
|
||||
%tr{ data: { 'dossier-id': dossier.id } }
|
||||
%td.folder-col
|
||||
= link_to(url_for_dossier(dossier), class: 'cell-link') do
|
||||
%span.icon.folder
|
||||
|
@ -48,11 +48,8 @@
|
|||
%td.updated-at-col
|
||||
= link_to(url_for_dossier(dossier), class: 'cell-link') do
|
||||
= dossier.updated_at.strftime("%d/%m/%Y")
|
||||
%td.action-col.delete-col
|
||||
- if dossier.can_be_deleted_by_user?
|
||||
= link_to(ask_deletion_dossier_path(dossier), method: :post, class: 'button danger', data: { disable: true, confirm: "En continuant, vous allez supprimer ce dossier ainsi que les informations qu’il contient. Toute suppression entraine l’annulation de la démarche en cours.\n\nConfirmer la suppression ?" }) do
|
||||
%span.icon.delete
|
||||
Supprimer
|
||||
%td.action-col.action-col
|
||||
= render partial: 'dossier_actions', locals: { dossier: dossier }
|
||||
= paginate(@dossiers)
|
||||
|
||||
- if current_user.feedbacks.empty? || current_user.feedbacks.last.created_at < 1.month.ago
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddExpectsMultipleSubmissionsColumnToProcedure < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :procedures, :expects_multiple_submissions, :boolean, default: false, null: false
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2019_03_18_154812) do
|
||||
ActiveRecord::Schema.define(version: 2019_03_27_102357) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -478,6 +478,7 @@ ActiveRecord::Schema.define(version: 2019_03_18_154812) do
|
|||
t.boolean "juridique_required", default: true
|
||||
t.boolean "durees_conservation_required", default: true
|
||||
t.string "path"
|
||||
t.boolean "expects_multiple_submissions", default: false, null: false
|
||||
t.index ["hidden_at"], name: "index_procedures_on_hidden_at"
|
||||
t.index ["parent_procedure_id"], name: "index_procedures_on_parent_procedure_id"
|
||||
t.index ["service_id"], name: "index_procedures_on_service_id"
|
||||
|
|
|
@ -71,11 +71,15 @@ describe 'user access to the list of their dossiers' do
|
|||
|
||||
context 'when user clicks on delete button', js: true do
|
||||
scenario 'the dossier is deleted' do
|
||||
page.accept_alert('Confirmer la suppression ?') do
|
||||
find(:xpath, "//a[@href='#{ask_deletion_dossier_path(dossier_brouillon)}']").click
|
||||
within(:css, "tr[data-dossier-id=\"#{dossier_brouillon.id}\"]") do
|
||||
click_on 'Actions'
|
||||
page.accept_alert('Confirmer la suppression ?') do
|
||||
click_on 'Supprimer le dossier'
|
||||
end
|
||||
end
|
||||
|
||||
expect(page).to have_content('Votre dossier a bien été supprimé.')
|
||||
expect(page).not_to have_content(dossier_brouillon.procedure.libelle)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
33
spec/views/users/dossiers/_dossier_actions.html.haml_spec.rb
Normal file
33
spec/views/users/dossiers/_dossier_actions.html.haml_spec.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
describe 'users/dossiers/dossier_actions.html.haml', type: :view do
|
||||
let(:procedure) { create(:procedure, :published, expects_multiple_submissions: true) }
|
||||
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
||||
|
||||
subject { render 'users/dossiers/dossier_actions.html.haml', dossier: dossier }
|
||||
|
||||
it { is_expected.to have_link('Commencer un autre dossier', href: commencer_url(path: procedure.path)) }
|
||||
it { is_expected.to have_link('Supprimer le dossier', href: ask_deletion_dossier_path(dossier)) }
|
||||
|
||||
context 'when the dossier cannot be deleted' do
|
||||
let(:dossier) { create(:dossier, :accepte, procedure: procedure) }
|
||||
it { is_expected.not_to have_link('Supprimer le dossier') }
|
||||
end
|
||||
|
||||
context 'when the procedure doesn’t expect multiple submissions' do
|
||||
let(:procedure) { create(:procedure, :published, expects_multiple_submissions: false) }
|
||||
it { is_expected.not_to have_link('Commencer un autre dossier') }
|
||||
end
|
||||
|
||||
context 'when the procedure is closed' do
|
||||
let(:procedure) { create(:procedure, :archived, expects_multiple_submissions: true) }
|
||||
it { is_expected.not_to have_link('Commencer un autre dossier') }
|
||||
end
|
||||
|
||||
context 'when there are no actions to display' do
|
||||
let(:procedure) { create(:procedure, :published, expects_multiple_submissions: false) }
|
||||
let(:dossier) { create(:dossier, :accepte, procedure: procedure) }
|
||||
|
||||
it 'doesn’t render the menu at all' do
|
||||
expect(subject).not_to have_selector('.dropdown')
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue