Refactor publish dialog
This commit is contained in:
parent
559984c351
commit
b57c22cafe
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(){
|
||||
$("button#archive").on('click', function(){
|
||||
$("button#archive").hide();
|
||||
$("#confirm").show();
|
||||
});
|
||||
|
||||
$("#confirm #cancel").on('click', function(){
|
||||
$("button#archive").show();
|
||||
$("#confirm").hide();
|
||||
});
|
||||
}
|
||||
$(document).on('click', '#confirm #cancel', function() {
|
||||
$('button#archive-procedure').show();
|
||||
$('#confirm').hide();
|
||||
});
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
class ProcedureDecorator < Draper::Decorator
|
||||
delegate_all
|
||||
|
||||
def lien
|
||||
h.commencer_url(procedure_path: path) if path.present?
|
||||
end
|
||||
|
||||
def created_at_fr
|
||||
created_at.localtime.strftime('%d/%m/%Y %H:%M')
|
||||
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.col-xs-6= link_to(procedure.libelle, admin_procedure_href)
|
||||
- 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?
|
||||
%td= link_to(procedure.published_at_fr, admin_procedure_href)
|
||||
- else
|
||||
|
|
|
@ -6,24 +6,21 @@
|
|||
%button.close{ "aria-label" => "Close", "data-dismiss" => "modal", :type => "button" }
|
||||
%span{ "aria-hidden" => "true" } ×
|
||||
%h4#myModalLabel.modal-title
|
||||
= @procedure.archivee? ? 'Réactiver' : 'Publier'
|
||||
la procédure
|
||||
= procedure_modal_text(@procedure, :title)
|
||||
%span#publish-modal-title
|
||||
.modal-body
|
||||
Vous vous apprêtez à
|
||||
= @procedure.archivee? ? 'republier' : 'publier'
|
||||
votre procédure au public.
|
||||
= procedure_modal_text(@procedure, :body)
|
||||
- if !@procedure.archivee?
|
||||
%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
|
||||
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
|
||||
.form-group
|
||||
%br
|
||||
%h4 Lien de la procédure
|
||||
%p.center
|
||||
= "#{root_url}commencer/"
|
||||
= commencer_url(procedure_path: '')
|
||||
= text_field_tag('procedure_path', @procedure.default_path,
|
||||
id: 'procedure_path',
|
||||
placeholder: 'Chemin vers la procédure',
|
||||
|
@ -34,15 +31,13 @@
|
|||
#path_is_mine.text-warning.center.message
|
||||
Ce lien est déjà utilisé par une de vos procédure.
|
||||
%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
|
||||
Ce lien est déjà utilisé par une procédure.
|
||||
%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
|
||||
= t('activerecord.errors.models.procedure_path.attributes.path.format')
|
||||
.modal-footer
|
||||
= submit_tag "#{@procedure.archivee? ? 'Réactiver' : 'Publier'}", class: %w(btn btn btn-success),
|
||||
id: 'publish',
|
||||
disabled: :disabled
|
||||
= button_tag 'Annuler', class: %w(btn btn btn-default), id: 'cancel', data: { dismiss: 'modal' }
|
||||
= submit_tag procedure_modal_text(@procedure, :submit), class: %w(btn btn btn-success), disabled: :disabled, id: 'publish'
|
||||
= button_tag "Annuler", class: %w(btn btn btn-default), data: { dismiss: :modal }, id: 'cancel'
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
= render partial: 'admin/closed_mail_template_attestation_inconsistency_alert'
|
||||
.row.white-back
|
||||
#procedure_show
|
||||
= render partial: '/admin/procedures/modal_publish'
|
||||
= render partial: '/admin/procedures/modal_transfer'
|
||||
|
||||
- if procedure.brouillon?
|
||||
- if procedure.gestionnaires.empty? || procedure.service.nil?
|
||||
- missing_elements = []
|
||||
|
@ -11,32 +14,26 @@
|
|||
- if procedure.service.nil?
|
||||
- missing_elements << 'un service'
|
||||
- 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
|
||||
Publier
|
||||
- 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
|
||||
Publier
|
||||
|
||||
= render partial: '/admin/procedures/modal_publish'
|
||||
|
||||
%a#transfer.btn.btn-small.btn-default{ "data-target" => "#transferModal", "data-toggle" => "modal", :type => "button", style: 'float: right; margin-top: 10px; margin-right: 10px;' }
|
||||
%a.btn.btn-default#transfer-procedure{ data: { target: '#transfer-modal', toggle: :modal }, type: 'button', style: 'float: right; margin-top: 10px; margin-right: 10px;' }
|
||||
%i.fa.fa-exchange
|
||||
Envoyer une copie
|
||||
|
||||
= render partial: '/admin/procedures/modal_transfer'
|
||||
|
||||
- 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;' }
|
||||
%i.fa.fa-eraser
|
||||
%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-rocket
|
||||
Réactiver
|
||||
|
||||
= render partial: '/admin/procedures/modal_publish'
|
||||
|
||||
- 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
|
||||
%button#archive.btn.btn-small.btn-default.text-info{ type: :button }
|
||||
= form_tag admin_procedure_archive_path(procedure_id: procedure.id), method: :put, style: 'float: right; margin-top: 10px;' do
|
||||
%button#archive-procedure.btn.btn-small.btn-default.text-info{ type: :button }
|
||||
%i.fa.fa-eraser
|
||||
Archiver
|
||||
#confirm
|
||||
|
@ -55,11 +52,14 @@
|
|||
%div
|
||||
%h3 Lien procédure
|
||||
%div{ style: 'margin-left: 3%;' }
|
||||
- if procedure.publiee_ou_archivee?
|
||||
= link_to procedure.lien, sanitize_url(procedure.lien), target: :blank
|
||||
- if procedure.archivee?
|
||||
%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
|
||||
%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
|
||||
%h3 Détails
|
||||
|
@ -144,7 +144,7 @@
|
|||
%h3 Supprimer la procédure
|
||||
.alert.alert-danger
|
||||
%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
|
||||
- if dossiers_count > 0
|
||||
%p
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
.procedure-details
|
||||
%p.procedure-title
|
||||
= p.libelle
|
||||
= procedure_libelle p
|
||||
|
||||
%ul.procedure-stats.flex
|
||||
%li
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
role: 'img', 'aria-label': "logo de la procédure #{@procedure.libelle}" }
|
||||
|
||||
.procedure-header
|
||||
%h1= @procedure.libelle
|
||||
%h1= procedure_libelle @procedure
|
||||
%ul.tabs
|
||||
%li{ class: (@statut == 'a-suivre') ? 'active' : nil }>
|
||||
= link_to(gestionnaire_procedure_path(@procedure, statut: 'a-suivre')) do
|
||||
|
|
|
@ -36,6 +36,18 @@ fr:
|
|||
apipie:
|
||||
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:
|
||||
currency:
|
||||
format:
|
||||
|
|
|
@ -627,8 +627,8 @@ describe Admin::ProceduresController, type: :controller do
|
|||
end
|
||||
|
||||
context 'when procedure is archived' do
|
||||
let!(:procedure3) { create(:procedure, :archived, administrateur: admin2) }
|
||||
before do
|
||||
procedure3.update_attribute :archived_at, Time.now
|
||||
subject
|
||||
end
|
||||
|
||||
|
|
|
@ -7,11 +7,6 @@ describe ProcedureDecorator do
|
|||
|
||||
subject { procedure.decorate }
|
||||
|
||||
describe 'lien' do
|
||||
subject { super().lien }
|
||||
it { is_expected.to match(/fake_path/) }
|
||||
end
|
||||
|
||||
describe 'created_at_fr' do
|
||||
subject { super().created_at_fr }
|
||||
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'
|
||||
expect(page).to have_current_path(admin_procedure_path(Procedure.first))
|
||||
expect(page).to have_selector('#publish-procedure')
|
||||
expect(page.find_by_id('publish-procedure')[:disabled]).to eq('true')
|
||||
expect(page).to have_selector('#disabled-publish-procedure')
|
||||
expect(page.find_by_id('disabled-publish-procedure')[:disabled]).to eq('true')
|
||||
|
||||
click_on 'onglet-accompagnateurs'
|
||||
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
|
||||
let(:archived_at) { nil }
|
||||
let(:procedure) { create(:procedure, archived_at: archived_at) }
|
||||
let(:procedure) { create(:procedure, :with_service, archived_at: archived_at) }
|
||||
|
||||
before do
|
||||
assign(:facade, AdminProceduresShowFacades.new(procedure.decorate))
|
||||
|
@ -16,9 +16,9 @@ describe 'admin/procedures/show.html.haml', type: :view do
|
|||
end
|
||||
|
||||
describe 'publish button is not visible' do
|
||||
it { expect(rendered).not_to have_css('a#publish') }
|
||||
it { expect(rendered).not_to have_css('button#archive') }
|
||||
it { expect(rendered).not_to have_css('a#reenable') }
|
||||
it { expect(rendered).not_to have_css('a#publish-procedure') }
|
||||
it { expect(rendered).not_to have_css('button#archive-procedure') }
|
||||
it { expect(rendered).not_to have_css('a#reopen-procedure') }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -30,12 +30,12 @@ describe 'admin/procedures/show.html.haml', type: :view do
|
|||
|
||||
describe 'publish button is visible' do
|
||||
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('a#reenable') }
|
||||
it { expect(rendered).not_to have_css('button#archive-procedure') }
|
||||
it { expect(rendered).not_to have_css('a#reopen-procedure') }
|
||||
end
|
||||
|
||||
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
|
||||
|
@ -48,9 +48,9 @@ describe 'admin/procedures/show.html.haml', type: :view do
|
|||
end
|
||||
|
||||
describe 'archive button is visible', js: true do
|
||||
it { expect(rendered).not_to have_css('a#publish') }
|
||||
it { expect(rendered).to have_css('button#archive') }
|
||||
it { expect(rendered).not_to have_css('a#reenable') }
|
||||
it { expect(rendered).not_to have_css('a#publish-procedure') }
|
||||
it { expect(rendered).to have_css('button#archive-procedure') }
|
||||
it { expect(rendered).not_to have_css('a#reopen-procedure') }
|
||||
end
|
||||
|
||||
describe 'procedure link is present' do
|
||||
|
@ -67,13 +67,13 @@ describe 'admin/procedures/show.html.haml', type: :view do
|
|||
end
|
||||
|
||||
describe 'Re-enable button is visible' do
|
||||
it { expect(rendered).not_to have_css('a#publish') }
|
||||
it { expect(rendered).not_to have_css('button#archive') }
|
||||
it { expect(rendered).to have_css('a#reenable') }
|
||||
it { expect(rendered).not_to have_css('a#publish-procedure') }
|
||||
it { expect(rendered).not_to have_css('button#archive-procedure') }
|
||||
it { expect(rendered).to have_css('a#reopen-procedure') }
|
||||
end
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue