dont display tags on show if no label in procedure
This commit is contained in:
parent
84c2965edf
commit
1a3f73eb01
2 changed files with 27 additions and 16 deletions
|
@ -26,21 +26,22 @@
|
|||
%p.fr-mb-1w
|
||||
%small L’usager 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 }
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue