dont display tags on show if no label in procedure

This commit is contained in:
Lisa Durand 2024-10-16 16:38:16 +02:00
parent 84c2965edf
commit 1a3f73eb01
No known key found for this signature in database
GPG key ID: 0DF91F2CA1E8B816
2 changed files with 27 additions and 16 deletions

View file

@ -26,21 +26,22 @@
%p.fr-mb-1w
%small Lusager a supprimé son compte. Vous pouvez archiver puis supprimer le dossier.
.fr-mb-3w
- if dossier.procedure_labels.present?
- dossier.procedure_labels.each do |label|
= tag_label(label.name, label.color)
- if dossier.procedure.procedure_labels.present?
.fr-mb-3w
- if dossier.procedure_labels.present?
- dossier.procedure_labels.each do |label|
= tag_label(label.name, label.color)
= render Dropdown::MenuComponent.new(wrapper: :span, button_options: { class: ['fr-btn--sm fr-btn--tertiary-no-outline fr-pl-1v']}, menu_options: { class: ['dropdown-label left-aligned'] }) do |menu|
- if dossier.procedure_labels.empty?
- menu.with_button_inner_html do
Ajouter un label
= render Dropdown::MenuComponent.new(wrapper: :span, button_options: { class: ['fr-btn--sm fr-btn--tertiary-no-outline fr-pl-1v']}, menu_options: { class: ['dropdown-label left-aligned'] }) do |menu|
- if dossier.procedure_labels.empty?
- menu.with_button_inner_html do
Ajouter un label
- menu.with_form do
= form_with(url: dossier_labels_instructeur_dossier_path(dossier_id: dossier.id, procedure_id: dossier.procedure.id), method: :post, class: 'fr-p-3w', data: { controller: 'autosubmit', turbo: 'true' }) do |f|
%fieldset.fr-fieldset.fr-mt-2w.fr-mb-0
= f.collection_check_boxes :procedure_label_id, dossier.procedure.procedure_labels, :id, :name, include_hidden: false do |b|
.fr-fieldset__element
.fr-checkbox-group.fr-checkbox-group--sm.fr-mb-1w
= b.check_box(checked: DossierLabel.find_by(dossier_id: dossier.id, procedure_label_id: b.value).present? )
= b.label(class: "fr-label fr-tag fr-tag--sm fr-tag--#{b.object.color}") { b.text }
- menu.with_form do
= form_with(url: dossier_labels_instructeur_dossier_path(dossier_id: dossier.id, procedure_id: dossier.procedure.id), method: :post, class: 'fr-p-3w', data: { controller: 'autosubmit', turbo: 'true' }) do |f|
%fieldset.fr-fieldset.fr-mt-2w.fr-mb-0
= f.collection_check_boxes :procedure_label_id, dossier.procedure.procedure_labels, :id, :name, include_hidden: false do |b|
.fr-fieldset__element
.fr-checkbox-group.fr-checkbox-group--sm.fr-mb-1w
= b.check_box(checked: DossierLabel.find_by(dossier_id: dossier.id, procedure_label_id: b.value).present? )
= b.label(class: "fr-label fr-tag fr-tag--sm fr-tag--#{b.object.color}") { b.text }

View file

@ -221,6 +221,16 @@ describe 'instructeurs/dossiers/show', type: :view do
describe "Dossier labels" do
let(:procedure) { create(:procedure, :with_labels) }
let(:dossier) { create(:dossier, :en_construction, procedure:) }
context "Procedure without labels" do
let(:procedure_without_labels) { create(:procedure) }
let(:dossier) { create(:dossier, :en_construction, procedure: procedure_without_labels) }
it 'does not display button to add label or dropdown' do
expect(subject).not_to have_text("Ajouter un label")
expect(subject).not_to have_text("à relancer")
end
end
context "Dossier without labels" do
it 'displays button with text to add label' do
expect(subject).to have_text("Ajouter un label")