refactor(admin): fix exports invitation list, also use dsfr toggle
This commit is contained in:
parent
77f88bbbbe
commit
bae0009120
4 changed files with 110 additions and 112 deletions
|
@ -46,17 +46,3 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.force-table-100 {
|
|
||||||
width: calc(100vw);
|
|
||||||
}
|
|
||||||
|
|
||||||
.fr-table--bordered {
|
|
||||||
.table {
|
|
||||||
&.hoverable {
|
|
||||||
tbody tr:hover {
|
|
||||||
background-color: var(--hover);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Dsfr::ToggleComponent < ApplicationComponent
|
class Dsfr::ToggleComponent < ApplicationComponent
|
||||||
|
attr_reader :target
|
||||||
|
attr_reader :title
|
||||||
|
attr_reader :hint
|
||||||
|
attr_reader :toggle_labels
|
||||||
|
attr_reader :disabled
|
||||||
|
attr_reader :data
|
||||||
|
attr_reader :extra_class_names
|
||||||
|
|
||||||
def initialize(form:, target:, title:, disabled: nil, hint: nil, toggle_labels: { checked: 'Activé', unchecked: 'Désactivé' }, opt: nil, extra_class_names: nil)
|
def initialize(form:, target:, title:, disabled: nil, hint: nil, toggle_labels: { checked: 'Activé', unchecked: 'Désactivé' }, opt: nil, extra_class_names: nil)
|
||||||
@form = form
|
@form = form
|
||||||
@target = target
|
@target = target
|
||||||
|
@ -8,9 +16,13 @@ class Dsfr::ToggleComponent < ApplicationComponent
|
||||||
@hint = hint
|
@hint = hint
|
||||||
@disabled = disabled
|
@disabled = disabled
|
||||||
@toggle_labels = toggle_labels
|
@toggle_labels = toggle_labels
|
||||||
@opt = opt
|
@data = opt
|
||||||
@extra_class_names = extra_class_names
|
@extra_class_names = extra_class_names
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :toggle_labels, :extra_class_names
|
private
|
||||||
|
|
||||||
|
def input_id
|
||||||
|
dom_id(@form.object, target)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
%div{ class: "fr-toggle fr-toggle--label-left #{extra_class_names}" }
|
%div{ class: "fr-toggle fr-toggle--label-left #{extra_class_names}" }
|
||||||
= @form.check_box @target, class: 'fr-toggle__input', disabled: @disabled,
|
= @form.check_box target, class: 'fr-toggle__input', disabled:, data:, id: input_id
|
||||||
data: @opt
|
= @form.label target,
|
||||||
= @form.label @target,
|
title,
|
||||||
@title,
|
for: input_id,
|
||||||
data: { 'fr-checked-label': toggle_labels[:checked], 'fr-unchecked-label': toggle_labels[:unchecked] },
|
data: { 'fr-checked-label': toggle_labels[:checked], 'fr-unchecked-label': toggle_labels[:unchecked] },
|
||||||
class: 'fr-toggle__label'
|
class: 'fr-toggle__label'
|
||||||
- if @hint
|
|
||||||
%p.fr-hint-text= @hint
|
- if hint
|
||||||
|
%p.fr-hint-text= hint
|
||||||
|
|
|
@ -4,8 +4,7 @@
|
||||||
['Avis externes']] }
|
['Avis externes']] }
|
||||||
|
|
||||||
.fr-container
|
.fr-container
|
||||||
%h1.fr-h2
|
%h1 Avis externes
|
||||||
Avis externes
|
|
||||||
|
|
||||||
= render Dsfr::CalloutComponent.new(title: nil) do |c|
|
= render Dsfr::CalloutComponent.new(title: nil) do |c|
|
||||||
- c.with_body do
|
- c.with_body do
|
||||||
|
@ -15,106 +14,106 @@
|
||||||
title: t('.experts_doc.title'),
|
title: t('.experts_doc.title'),
|
||||||
**external_link_attributes)
|
**external_link_attributes)
|
||||||
|
|
||||||
%ul.fr-toggle__list
|
%fieldset.fr-fieldset
|
||||||
%li
|
.fr-fieldset__element
|
||||||
= form_for @procedure,
|
%ul.fr-toggle__list
|
||||||
method: :put,
|
%li
|
||||||
url: allow_expert_review_admin_procedure_path(@procedure),
|
= form_for @procedure,
|
||||||
data: { controller: 'autosubmit', turbo: 'true' } do |f|
|
method: :put,
|
||||||
|
url: allow_expert_review_admin_procedure_path(@procedure),
|
||||||
|
data: { controller: 'autosubmit', turbo: 'true' } do |f|
|
||||||
|
|
||||||
= render Dsfr::ToggleComponent.new(form: f,
|
= render Dsfr::ToggleComponent.new(form: f,
|
||||||
target: :allow_expert_review,
|
target: :allow_expert_review,
|
||||||
title: t('.titles.allow_invite_experts'),
|
title: t('.titles.allow_invite_experts'),
|
||||||
hint: t('.descriptions.allow_invite_experts'),
|
hint: t('.descriptions.allow_invite_experts'),
|
||||||
disabled: false,
|
disabled: false,
|
||||||
extra_class_names: 'fr-toggle--border-bottom')
|
extra_class_names: 'fr-toggle--border-bottom')
|
||||||
|
|
||||||
- if @procedure.allow_expert_review?
|
- if @procedure.allow_expert_review?
|
||||||
%li
|
%li
|
||||||
= form_for @procedure,
|
= form_for @procedure,
|
||||||
method: :put,
|
method: :put,
|
||||||
url: allow_expert_messaging_admin_procedure_path(@procedure),
|
url: allow_expert_messaging_admin_procedure_path(@procedure),
|
||||||
data: { controller: 'autosubmit', turbo: 'true' } do |f|
|
data: { controller: 'autosubmit', turbo: 'true' } do |f|
|
||||||
|
|
||||||
= render Dsfr::ToggleComponent.new(form: f,
|
= render Dsfr::ToggleComponent.new(form: f,
|
||||||
target: :allow_expert_messaging,
|
target: :allow_expert_messaging,
|
||||||
title: t('.titles.allow_expert_messaging'),
|
title: t('.titles.allow_expert_messaging'),
|
||||||
hint: t('.descriptions.allow_expert_messaging'),
|
hint: t('.descriptions.allow_expert_messaging'),
|
||||||
disabled: false,
|
disabled: false,
|
||||||
extra_class_names: 'fr-toggle--border-bottom')
|
extra_class_names: 'fr-toggle--border-bottom')
|
||||||
|
|
||||||
%li
|
%li
|
||||||
= form_for @procedure,
|
= form_for @procedure,
|
||||||
method: :put,
|
method: :put,
|
||||||
url: experts_require_administrateur_invitation_admin_procedure_path(@procedure),
|
url: experts_require_administrateur_invitation_admin_procedure_path(@procedure),
|
||||||
data: { controller: 'autosubmit', turbo: 'true' } do |f|
|
data: { controller: 'autosubmit', turbo: 'true' } do |f|
|
||||||
|
|
||||||
= render Dsfr::ToggleComponent.new(form: f,
|
= render Dsfr::ToggleComponent.new(form: f,
|
||||||
target: :experts_require_administrateur_invitation,
|
target: :experts_require_administrateur_invitation,
|
||||||
title: t('.titles.manage_procedure_experts'),
|
title: t('.titles.manage_procedure_experts'),
|
||||||
hint: t('.descriptions.manage_procedure_experts'),
|
hint: t('.descriptions.manage_procedure_experts'),
|
||||||
disabled: false)
|
disabled: false)
|
||||||
|
|
||||||
|
|
||||||
- if @procedure.experts_require_administrateur_invitation?
|
- if @procedure.experts_require_administrateur_invitation?
|
||||||
.card
|
.card
|
||||||
= render Procedure::InvitationWithTypoComponent.new(maybe_typos: @maybe_typos, url: admin_procedure_experts_path(@procedure), title: "Avant d'ajouter l'email à la liste d'expert prédéfinie, veuillez confirmer" )
|
= render Procedure::InvitationWithTypoComponent.new(maybe_typos: @maybe_typos, url: admin_procedure_experts_path(@procedure), title: "Avant d'ajouter l'email à la liste d'expert prédéfinie, veuillez confirmer" )
|
||||||
= form_for :experts_procedure,
|
= form_for :experts_procedure,
|
||||||
url: admin_procedure_experts_path(@procedure),
|
url: admin_procedure_experts_path(@procedure),
|
||||||
html: { class: 'form' } do |f|
|
html: { class: 'form' } do |f|
|
||||||
|
|
||||||
.instructeur-wrapper
|
.instructeur-wrapper
|
||||||
%p#experts-emails Entrez les adresses emails des experts que vous souhaitez ajouter à la liste prédéfinie
|
%p#experts-emails Entrez les adresses emails des experts que vous souhaitez ajouter à la liste prédéfinie
|
||||||
%react-fragment
|
%react-fragment
|
||||||
= render ReactComponent.new "ComboBox/MultiComboBox",
|
= render ReactComponent.new "ComboBox/MultiComboBox",
|
||||||
id: 'emails',
|
id: 'emails',
|
||||||
name: 'emails[]',
|
name: 'emails[]',
|
||||||
allows_custom_value: true,
|
allows_custom_value: true,
|
||||||
'aria-label': 'Emails',
|
'aria-label': 'Emails',
|
||||||
'aria-describedby': 'experts-emails'
|
'aria-describedby': 'experts-emails'
|
||||||
|
|
||||||
= f.submit 'Ajouter à la liste', class: 'fr-btn'
|
= f.submit 'Ajouter à la liste', class: 'fr-btn'
|
||||||
|
|
||||||
- if @experts_procedure.present?
|
- if @experts_procedure.present?
|
||||||
.fr-table.fr-table--no-caption.fr-table--layout-fixed.fr-mt-3w
|
.fr-table.fr-table--no-caption.fr-table--layout-fixed.fr-mt-3w
|
||||||
%table
|
%table
|
||||||
%thead
|
%thead
|
||||||
|
%tr
|
||||||
|
%th Liste des experts
|
||||||
|
%th Nombre d’avis
|
||||||
|
- if @procedure.experts_require_administrateur_invitation
|
||||||
|
%th Notifier des décisions sur les dossiers
|
||||||
|
- if @procedure.experts_require_administrateur_invitation
|
||||||
|
%th Action
|
||||||
|
%tbody
|
||||||
|
- @experts_procedure.each do |expert_procedure|
|
||||||
%tr
|
%tr
|
||||||
%th Liste des experts
|
%td
|
||||||
%th Nombre d’avis
|
= dsfr_icon('fr-icon-user-fill')
|
||||||
|
= expert_procedure.expert.email
|
||||||
|
%td.fr-cell--center
|
||||||
|
= expert_procedure.avis.count
|
||||||
- if @procedure.experts_require_administrateur_invitation
|
- if @procedure.experts_require_administrateur_invitation
|
||||||
%th Notifier des décisions sur les dossiers
|
%td.fr-cell--center
|
||||||
|
= form_for expert_procedure,
|
||||||
|
url: admin_procedure_expert_path(id: expert_procedure),
|
||||||
|
method: :put,
|
||||||
|
data: { controller: 'autosubmit', turbo: 'true' } do |f|
|
||||||
|
= render Dsfr::ToggleComponent.new(form: f,
|
||||||
|
title: "Notifier",
|
||||||
|
target: :allow_decision_access,
|
||||||
|
)
|
||||||
- if @procedure.experts_require_administrateur_invitation
|
- if @procedure.experts_require_administrateur_invitation
|
||||||
%th Action
|
%td.actions= button_to 'Retirer',
|
||||||
%tbody
|
admin_procedure_expert_path(id: expert_procedure, procedure: @procedure),
|
||||||
- @experts_procedure.each do |expert_procedure|
|
method: :delete,
|
||||||
%tr
|
data: { confirm: "Êtes-vous sûr de vouloir révoquer l'expert « #{expert_procedure.expert.email} » de la démarche #{expert_procedure.procedure.libelle} ? Les instructeurs ne pourront plus lui demander d’avis" },
|
||||||
%td
|
class: 'fr-btn fr-btn--secondary'
|
||||||
= dsfr_icon('fr-icon-user-fill')
|
- else
|
||||||
= expert_procedure.expert.email
|
.blank-tab
|
||||||
%td.text-center
|
%h2.empty-text Aucun expert invité pour le moment.
|
||||||
= expert_procedure.avis.count
|
%p.empty-text-details Les instructeurs de cette démarche n’ont pas encore fait appel aux experts.
|
||||||
- if @procedure.experts_require_administrateur_invitation
|
|
||||||
%td.text-center
|
|
||||||
= form_for expert_procedure,
|
|
||||||
url: admin_procedure_expert_path(id: expert_procedure),
|
|
||||||
method: :put,
|
|
||||||
data: { turbo: true },
|
|
||||||
html: { class: 'form procedure-form__column--form no-background' } do |f|
|
|
||||||
%label.toggle-switch{ data: { controller: 'autosubmit' } }
|
|
||||||
= f.check_box :allow_decision_access, class: 'toggle-switch-checkbox'
|
|
||||||
%span.toggle-switch-control.round
|
|
||||||
%span.toggle-switch-label.on
|
|
||||||
%span.toggle-switch-label.off
|
|
||||||
- if @procedure.experts_require_administrateur_invitation
|
|
||||||
%td.actions= button_to 'retirer',
|
|
||||||
admin_procedure_expert_path(id: expert_procedure, procedure: @procedure),
|
|
||||||
method: :delete,
|
|
||||||
data: { confirm: "Êtes-vous sûr de vouloir révoquer l'expert « #{expert_procedure.expert.email} » de la démarche #{expert_procedure.procedure.libelle} ? Les instructeurs ne pourront plus lui demander d’avis" },
|
|
||||||
class: 'fr-btn fr-btn--secondary'
|
|
||||||
- else
|
|
||||||
.blank-tab
|
|
||||||
%h2.empty-text Aucun expert invité pour le moment.
|
|
||||||
%p.empty-text-details Les instructeurs de cette démarche n’ont pas encore fait appel aux experts.
|
|
||||||
|
|
||||||
= render Procedure::FixedFooterComponent.new(procedure: @procedure)
|
= render Procedure::FixedFooterComponent.new(procedure: @procedure)
|
||||||
|
|
Loading…
Reference in a new issue