Merge pull request #2402 from tchak/refactor-procedure-show
Refactor publish dialog
This commit is contained in:
commit
8bd418e122
13 changed files with 90 additions and 72 deletions
|
@ -1,13 +1,9 @@
|
||||||
$(document).on('turbolinks:load', buttons_archived);
|
$(document).on('click', 'button#archive-procedure', function() {
|
||||||
|
$('button#archive-procedure').hide();
|
||||||
|
$('#confirm').show();
|
||||||
|
});
|
||||||
|
|
||||||
function buttons_archived(){
|
$(document).on('click', '#confirm #cancel', function() {
|
||||||
$("button#archive").on('click', function(){
|
$('button#archive-procedure').show();
|
||||||
$("button#archive").hide();
|
$('#confirm').hide();
|
||||||
$("#confirm").show();
|
});
|
||||||
});
|
|
||||||
|
|
||||||
$("#confirm #cancel").on('click', function(){
|
|
||||||
$("button#archive").show();
|
|
||||||
$("#confirm").hide();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
class ProcedureDecorator < Draper::Decorator
|
class ProcedureDecorator < Draper::Decorator
|
||||||
delegate_all
|
delegate_all
|
||||||
|
|
||||||
def lien
|
|
||||||
h.commencer_url(procedure_path: path) if path.present?
|
|
||||||
end
|
|
||||||
|
|
||||||
def created_at_fr
|
def created_at_fr
|
||||||
created_at.localtime.strftime('%d/%m/%Y %H:%M')
|
created_at.localtime.strftime('%d/%m/%Y %H:%M')
|
||||||
end
|
end
|
||||||
|
|
24
app/helpers/procedure_helper.rb
Normal file
24
app/helpers/procedure_helper.rb
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
module ProcedureHelper
|
||||||
|
def procedure_lien(procedure)
|
||||||
|
if procedure.procedure_path.present?
|
||||||
|
if procedure.brouillon_avec_lien?
|
||||||
|
commencer_test_url(procedure_path: procedure.path)
|
||||||
|
else
|
||||||
|
commencer_url(procedure_path: procedure.path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def procedure_libelle(procedure)
|
||||||
|
parts = [procedure.libelle]
|
||||||
|
if procedure.brouillon?
|
||||||
|
parts << '(brouillon)'
|
||||||
|
end
|
||||||
|
parts.join(' ')
|
||||||
|
end
|
||||||
|
|
||||||
|
def procedure_modal_text(procedure, key)
|
||||||
|
action = procedure.archivee? ? :reopen : :publish
|
||||||
|
t(action, scope: [:modal, :publish, key])
|
||||||
|
end
|
||||||
|
end
|
|
@ -18,7 +18,7 @@
|
||||||
%td= link_to(procedure.id, admin_procedure_href)
|
%td= link_to(procedure.id, admin_procedure_href)
|
||||||
%td.col-xs-6= link_to(procedure.libelle, admin_procedure_href)
|
%td.col-xs-6= link_to(procedure.libelle, admin_procedure_href)
|
||||||
- if procedure.publiee?
|
- if procedure.publiee?
|
||||||
%td.procedure-lien= link_to(procedure.lien, procedure.lien)
|
%td.procedure-lien= link_to(procedure_lien(procedure), procedure_lien(procedure))
|
||||||
- if procedure.publiee_ou_archivee?
|
- if procedure.publiee_ou_archivee?
|
||||||
%td= link_to(procedure.published_at_fr, admin_procedure_href)
|
%td= link_to(procedure.published_at_fr, admin_procedure_href)
|
||||||
- else
|
- else
|
||||||
|
|
|
@ -6,24 +6,21 @@
|
||||||
%button.close{ "aria-label" => "Close", "data-dismiss" => "modal", :type => "button" }
|
%button.close{ "aria-label" => "Close", "data-dismiss" => "modal", :type => "button" }
|
||||||
%span{ "aria-hidden" => "true" } ×
|
%span{ "aria-hidden" => "true" } ×
|
||||||
%h4#myModalLabel.modal-title
|
%h4#myModalLabel.modal-title
|
||||||
= @procedure.archivee? ? 'Réactiver' : 'Publier'
|
= procedure_modal_text(@procedure, :title)
|
||||||
la procédure
|
|
||||||
%span#publish-modal-title
|
%span#publish-modal-title
|
||||||
.modal-body
|
.modal-body
|
||||||
Vous vous apprêtez à
|
= procedure_modal_text(@procedure, :body)
|
||||||
= @procedure.archivee? ? 'republier' : 'publier'
|
|
||||||
votre procédure au public.
|
|
||||||
- if !@procedure.archivee?
|
- if !@procedure.archivee?
|
||||||
%b
|
%b
|
||||||
Elle ne pourra plus être modifiée à l'issue de cette publication.
|
Elle ne pourra plus être modifiée à l’issue de cette publication.
|
||||||
%br
|
%br
|
||||||
Afin de faciliter l'accès à la procédure, vous êtes invité à personnaliser l'adresse d'accès si vous le souhaitez.
|
Afin de faciliter l’accès à la procédure, vous êtes invité à personnaliser l’adresse d'accès si vous le souhaitez.
|
||||||
%br
|
%br
|
||||||
.form-group
|
.form-group
|
||||||
%br
|
%br
|
||||||
%h4 Lien de la procédure
|
%h4 Lien de la procédure
|
||||||
%p.center
|
%p.center
|
||||||
= "#{root_url}commencer/"
|
= commencer_url(procedure_path: '')
|
||||||
= text_field_tag('procedure_path', @procedure.default_path,
|
= text_field_tag('procedure_path', @procedure.default_path,
|
||||||
id: 'procedure_path',
|
id: 'procedure_path',
|
||||||
placeholder: 'Chemin vers la procédure',
|
placeholder: 'Chemin vers la procédure',
|
||||||
|
@ -34,15 +31,13 @@
|
||||||
#path_is_mine.text-warning.center.message
|
#path_is_mine.text-warning.center.message
|
||||||
Ce lien est déjà utilisé par une de vos procédure.
|
Ce lien est déjà utilisé par une de vos procédure.
|
||||||
%br
|
%br
|
||||||
Si vous voulez l'utiliser, l'ancienne procédure sera archivée (plus accessible du public).
|
Si vous voulez l’utiliser, l’ancienne procédure sera archivée (plus accessible du public).
|
||||||
#path_is_not_mine.text-danger.center.message
|
#path_is_not_mine.text-danger.center.message
|
||||||
Ce lien est déjà utilisé par une procédure.
|
Ce lien est déjà utilisé par une procédure.
|
||||||
%br
|
%br
|
||||||
Vous ne pouvez pas l'utiliser car il appartient à un autre administrateur.
|
Vous ne pouvez pas l’utiliser car il appartient à un autre administrateur.
|
||||||
#path_is_invalid.text-danger.center.message
|
#path_is_invalid.text-danger.center.message
|
||||||
= t('activerecord.errors.models.procedure_path.attributes.path.format')
|
= t('activerecord.errors.models.procedure_path.attributes.path.format')
|
||||||
.modal-footer
|
.modal-footer
|
||||||
= submit_tag "#{@procedure.archivee? ? 'Réactiver' : 'Publier'}", class: %w(btn btn btn-success),
|
= submit_tag procedure_modal_text(@procedure, :submit), class: %w(btn btn btn-success), disabled: :disabled, id: 'publish'
|
||||||
id: 'publish',
|
= button_tag "Annuler", class: %w(btn btn btn-default), data: { dismiss: :modal }, id: 'cancel'
|
||||||
disabled: :disabled
|
|
||||||
= button_tag 'Annuler', class: %w(btn btn btn-default), id: 'cancel', data: { dismiss: 'modal' }
|
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
= render partial: 'admin/closed_mail_template_attestation_inconsistency_alert'
|
= render partial: 'admin/closed_mail_template_attestation_inconsistency_alert'
|
||||||
.row.white-back
|
.row.white-back
|
||||||
#procedure_show
|
#procedure_show
|
||||||
|
= render partial: '/admin/procedures/modal_publish'
|
||||||
|
= render partial: '/admin/procedures/modal_transfer'
|
||||||
|
|
||||||
- if procedure.brouillon?
|
- if procedure.brouillon?
|
||||||
- if procedure.gestionnaires.empty? || procedure.service.nil?
|
- if procedure.gestionnaires.empty? || procedure.service.nil?
|
||||||
- missing_elements = []
|
- missing_elements = []
|
||||||
|
@ -11,32 +14,26 @@
|
||||||
- if procedure.service.nil?
|
- if procedure.service.nil?
|
||||||
- missing_elements << 'un service'
|
- missing_elements << 'un service'
|
||||||
- message = "Affectez #{missing_elements.join(' et ')} à votre procédure."
|
- message = "Affectez #{missing_elements.join(' et ')} à votre procédure."
|
||||||
%a.action_button.btn.btn-success#publish-procedure{ style: 'float: right; margin-top: 10px;', disabled: 'disabled', 'data-toggle' => :tooltip, 'data-placement' => :bottom, title: message }
|
%a.action_button.btn.btn-success#disabled-publish-procedure{ data: { toggle: :tooltip, placement: :bottom }, style: 'float: right; margin-top: 10px;', disabled: true, title: message }
|
||||||
%i.fa.fa-eraser
|
%i.fa.fa-eraser
|
||||||
Publier
|
Publier
|
||||||
- else
|
- else
|
||||||
%a.btn.btn-success#publish-procedure{ "data-target" => "#publish-modal", "data-toggle" => "modal", :type => "button", style: 'float: right; margin-top: 10px;' }
|
%a.btn.btn-success#publish-procedure{ data: { target: '#publish-modal', toggle: :modal }, type: 'button', style: 'float: right; margin-top: 10px;' }
|
||||||
%i.fa.fa-eraser
|
%i.fa.fa-eraser
|
||||||
Publier
|
Publier
|
||||||
|
|
||||||
= render partial: '/admin/procedures/modal_publish'
|
%a.btn.btn-default#transfer-procedure{ data: { target: '#transfer-modal', toggle: :modal }, type: 'button', style: 'float: right; margin-top: 10px; margin-right: 10px;' }
|
||||||
|
|
||||||
%a#transfer.btn.btn-small.btn-default{ "data-target" => "#transferModal", "data-toggle" => "modal", :type => "button", style: 'float: right; margin-top: 10px; margin-right: 10px;' }
|
|
||||||
%i.fa.fa-exchange
|
%i.fa.fa-exchange
|
||||||
Envoyer une copie
|
Envoyer une copie
|
||||||
|
|
||||||
= render partial: '/admin/procedures/modal_transfer'
|
|
||||||
|
|
||||||
- if procedure.archivee?
|
- if procedure.archivee?
|
||||||
%a#reenable.btn.btn-small.btn-default.text-info{ "data-target" => "#publish-modal", "data-toggle" => "modal", :type => "button", style: 'float: right; margin-top: 10px;' }
|
%a.btn.btn-default#reopen-procedure{ data: { target: '#publish-modal', toggle: :modal }, type: 'button', style: 'float: right; margin-top: 10px; margin-right: 10px;' }
|
||||||
%i.fa.fa-eraser
|
%i.fa.fa-rocket
|
||||||
Réactiver
|
Réactiver
|
||||||
|
|
||||||
= render partial: '/admin/procedures/modal_publish'
|
|
||||||
|
|
||||||
- elsif procedure.publiee?
|
- elsif procedure.publiee?
|
||||||
= form_tag admin_procedure_archive_path(procedure_id: procedure.id, archive: !procedure.archivee?), method: :put, style: 'float: right; margin-top: 10px;' do
|
= form_tag admin_procedure_archive_path(procedure_id: procedure.id), method: :put, style: 'float: right; margin-top: 10px;' do
|
||||||
%button#archive.btn.btn-small.btn-default.text-info{ type: :button }
|
%button#archive-procedure.btn.btn-small.btn-default.text-info{ type: :button }
|
||||||
%i.fa.fa-eraser
|
%i.fa.fa-eraser
|
||||||
Archiver
|
Archiver
|
||||||
#confirm
|
#confirm
|
||||||
|
@ -55,11 +52,14 @@
|
||||||
%div
|
%div
|
||||||
%h3 Lien procédure
|
%h3 Lien procédure
|
||||||
%div{ style: 'margin-left: 3%;' }
|
%div{ style: 'margin-left: 3%;' }
|
||||||
- if procedure.publiee_ou_archivee?
|
- if procedure.archivee?
|
||||||
= link_to procedure.lien, sanitize_url(procedure.lien), target: :blank
|
%b
|
||||||
|
Cette procédure est archivée et n’est donc pas accessible par le public.
|
||||||
|
- elsif procedure.brouillon_avec_lien? || procedure.publiee?
|
||||||
|
= link_to procedure_lien(procedure), sanitize_url(procedure_lien(procedure)), target: :blank
|
||||||
- else
|
- else
|
||||||
%b
|
%b
|
||||||
Cette procédure n'a pas encore été publiée et n'est donc pas accessible par le public.
|
Cette procédure n’a pas encore de lien, et n’est donc pas accessible par le public.
|
||||||
|
|
||||||
%br
|
%br
|
||||||
%h3 Détails
|
%h3 Détails
|
||||||
|
@ -144,7 +144,7 @@
|
||||||
%h3 Supprimer la procédure
|
%h3 Supprimer la procédure
|
||||||
.alert.alert-danger
|
.alert.alert-danger
|
||||||
%p
|
%p
|
||||||
Attention : la suppression d'une procédure est définitive.
|
Attention : la suppression d’une procédure est définitive.
|
||||||
- dossiers_count = procedure.dossiers.count
|
- dossiers_count = procedure.dossiers.count
|
||||||
- if dossiers_count > 0
|
- if dossiers_count > 0
|
||||||
%p
|
%p
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
.procedure-details
|
.procedure-details
|
||||||
%p.procedure-title
|
%p.procedure-title
|
||||||
= p.libelle
|
= procedure_libelle p
|
||||||
|
|
||||||
%ul.procedure-stats.flex
|
%ul.procedure-stats.flex
|
||||||
%li
|
%li
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
role: 'img', 'aria-label': "logo de la procédure #{@procedure.libelle}" }
|
role: 'img', 'aria-label': "logo de la procédure #{@procedure.libelle}" }
|
||||||
|
|
||||||
.procedure-header
|
.procedure-header
|
||||||
%h1= @procedure.libelle
|
%h1= procedure_libelle @procedure
|
||||||
%ul.tabs
|
%ul.tabs
|
||||||
%li{ class: (@statut == 'a-suivre') ? 'active' : nil }>
|
%li{ class: (@statut == 'a-suivre') ? 'active' : nil }>
|
||||||
= link_to(gestionnaire_procedure_path(@procedure, statut: 'a-suivre')) do
|
= link_to(gestionnaire_procedure_path(@procedure, statut: 'a-suivre')) do
|
||||||
|
|
|
@ -36,6 +36,18 @@ fr:
|
||||||
apipie:
|
apipie:
|
||||||
api_documentation: "Documentation de l'API demarches-simplifiees.fr"
|
api_documentation: "Documentation de l'API demarches-simplifiees.fr"
|
||||||
|
|
||||||
|
modal:
|
||||||
|
publish:
|
||||||
|
title:
|
||||||
|
publish: Publier la procédure
|
||||||
|
reopen: Réactiver la procédure
|
||||||
|
body:
|
||||||
|
publish: Vous vous apprêtez à publier votre procédure au public.
|
||||||
|
reopen: Vous vous apprêtez à réactiver votre procédure.
|
||||||
|
submit:
|
||||||
|
publish: Publier
|
||||||
|
reopen: Réactiver
|
||||||
|
|
||||||
number:
|
number:
|
||||||
currency:
|
currency:
|
||||||
format:
|
format:
|
||||||
|
|
|
@ -627,8 +627,8 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when procedure is archived' do
|
context 'when procedure is archived' do
|
||||||
|
let!(:procedure3) { create(:procedure, :archived, administrateur: admin2) }
|
||||||
before do
|
before do
|
||||||
procedure3.update_attribute :archived_at, Time.now
|
|
||||||
subject
|
subject
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,6 @@ describe ProcedureDecorator do
|
||||||
|
|
||||||
subject { procedure.decorate }
|
subject { procedure.decorate }
|
||||||
|
|
||||||
describe 'lien' do
|
|
||||||
subject { super().lien }
|
|
||||||
it { is_expected.to match(/fake_path/) }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'created_at_fr' do
|
describe 'created_at_fr' do
|
||||||
subject { super().created_at_fr }
|
subject { super().created_at_fr }
|
||||||
it { is_expected.to eq('24/12/2015 14:10') }
|
it { is_expected.to eq('24/12/2015 14:10') }
|
||||||
|
|
|
@ -94,8 +94,8 @@ feature 'As an administrateur I wanna create a new procedure', js: true do
|
||||||
|
|
||||||
click_on 'onglet-infos'
|
click_on 'onglet-infos'
|
||||||
expect(page).to have_current_path(admin_procedure_path(Procedure.first))
|
expect(page).to have_current_path(admin_procedure_path(Procedure.first))
|
||||||
expect(page).to have_selector('#publish-procedure')
|
expect(page).to have_selector('#disabled-publish-procedure')
|
||||||
expect(page.find_by_id('publish-procedure')[:disabled]).to eq('true')
|
expect(page.find_by_id('disabled-publish-procedure')[:disabled]).to eq('true')
|
||||||
|
|
||||||
click_on 'onglet-accompagnateurs'
|
click_on 'onglet-accompagnateurs'
|
||||||
expect(page).to have_current_path(admin_procedure_accompagnateurs_path(Procedure.first))
|
expect(page).to have_current_path(admin_procedure_accompagnateurs_path(Procedure.first))
|
||||||
|
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe 'admin/procedures/show.html.haml', type: :view do
|
describe 'admin/procedures/show.html.haml', type: :view do
|
||||||
let(:archived_at) { nil }
|
let(:archived_at) { nil }
|
||||||
let(:procedure) { create(:procedure, archived_at: archived_at) }
|
let(:procedure) { create(:procedure, :with_service, archived_at: archived_at) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
assign(:facade, AdminProceduresShowFacades.new(procedure.decorate))
|
assign(:facade, AdminProceduresShowFacades.new(procedure.decorate))
|
||||||
|
@ -16,9 +16,9 @@ describe 'admin/procedures/show.html.haml', type: :view do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'publish button is not visible' do
|
describe 'publish button is not visible' do
|
||||||
it { expect(rendered).not_to have_css('a#publish') }
|
it { expect(rendered).not_to have_css('a#publish-procedure') }
|
||||||
it { expect(rendered).not_to have_css('button#archive') }
|
it { expect(rendered).not_to have_css('button#archive-procedure') }
|
||||||
it { expect(rendered).not_to have_css('a#reenable') }
|
it { expect(rendered).not_to have_css('a#reopen-procedure') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -30,12 +30,12 @@ describe 'admin/procedures/show.html.haml', type: :view do
|
||||||
|
|
||||||
describe 'publish button is visible' do
|
describe 'publish button is visible' do
|
||||||
it { expect(rendered).to have_css('a#publish-procedure') }
|
it { expect(rendered).to have_css('a#publish-procedure') }
|
||||||
it { expect(rendered).not_to have_css('button#archive') }
|
it { expect(rendered).not_to have_css('button#archive-procedure') }
|
||||||
it { expect(rendered).not_to have_css('a#reenable') }
|
it { expect(rendered).not_to have_css('a#reopen-procedure') }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'procedure link is not present' do
|
describe 'procedure link is not present' do
|
||||||
it { expect(rendered).to have_content('Cette procédure n\'a pas encore été publiée et n\'est donc pas accessible par le public.') }
|
it { expect(rendered).to have_content('Cette procédure n’a pas encore de lien, et n’est donc pas accessible par le public.') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -48,9 +48,9 @@ describe 'admin/procedures/show.html.haml', type: :view do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'archive button is visible', js: true do
|
describe 'archive button is visible', js: true do
|
||||||
it { expect(rendered).not_to have_css('a#publish') }
|
it { expect(rendered).not_to have_css('a#publish-procedure') }
|
||||||
it { expect(rendered).to have_css('button#archive') }
|
it { expect(rendered).to have_css('button#archive-procedure') }
|
||||||
it { expect(rendered).not_to have_css('a#reenable') }
|
it { expect(rendered).not_to have_css('a#reopen-procedure') }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'procedure link is present' do
|
describe 'procedure link is present' do
|
||||||
|
@ -67,13 +67,13 @@ describe 'admin/procedures/show.html.haml', type: :view do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'Re-enable button is visible' do
|
describe 'Re-enable button is visible' do
|
||||||
it { expect(rendered).not_to have_css('a#publish') }
|
it { expect(rendered).not_to have_css('a#publish-procedure') }
|
||||||
it { expect(rendered).not_to have_css('button#archive') }
|
it { expect(rendered).not_to have_css('button#archive-procedure') }
|
||||||
it { expect(rendered).to have_css('a#reenable') }
|
it { expect(rendered).to have_css('a#reopen-procedure') }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'procedure link is present' do
|
describe 'procedure link is present' do
|
||||||
it { expect(rendered).to have_content(commencer_url(procedure_path: procedure.path)) }
|
it { expect(rendered).to have_content('Cette procédure est archivée et n’est donc pas accessible par le public.') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue