diff --git a/app/assets/stylesheets/tags.scss b/app/assets/stylesheets/tags.scss index 577b375d7..5eda8aeeb 100644 --- a/app/assets/stylesheets/tags.scss +++ b/app/assets/stylesheets/tags.scss @@ -5,18 +5,11 @@ $colors: "green-tilleul-verveine", "green-bourgeon", "green-emeraude", "green-menthe", - "green-archipel", "blue-ecume", - "blue-cumulus", "purple-glycine", "pink-macaron", - "pink-tuile", "yellow-tournesol", - "yellow-moutarde", - "orange-terre-battue", "brown-cafe-creme", - "brown-caramel", - "brown-opera", "beige-gris-galet"; @@ -35,3 +28,15 @@ $colors: "green-tilleul-verveine", color: var(--text-action-high-#{$color}); } } + +.grid-tags { + display: grid; + grid-template-columns: repeat(2, 1fr); +} + +@media (min-width: 62em) { + .grid-tags { + display: grid; + grid-template-columns: repeat(5, 1fr); + } +} diff --git a/app/models/label.rb b/app/models/label.rb index bebfddf21..785507a80 100644 --- a/app/models/label.rb +++ b/app/models/label.rb @@ -6,9 +6,11 @@ class Label < ApplicationRecord NAME_MAX_LENGTH = 30 GENERIC_LABELS = [ - { name: 'à relancer', color: 'brown_caramel' }, - { name: 'complet', color: 'green_bourgeon' }, - { name: 'prêt pour validation', color: 'green_archipel' } + { name: 'À examiner', color: 'purple_glycine' }, + { name: 'À relancer', color: 'green_tilleul_verveine' }, + { name: 'Complet', color: 'green_emeraude' }, + { name: 'À signer', color: 'blue_ecume' }, + { name: 'Urgent', color: 'pink_macaron' } ] enum color: { @@ -16,18 +18,11 @@ class Label < ApplicationRecord green_bourgeon: "green-bourgeon", green_emeraude: "green-emeraude", green_menthe: "green-menthe", - green_archipel: "green-archipel", blue_ecume: "blue-ecume", - blue_cumulus: "blue-cumulus", purple_glycine: "purple-glycine", pink_macaron: "pink-macaron", - pink_tuile: "pink-tuile", yellow_tournesol: "yellow-tournesol", - yellow_moutarde: "yellow-moutarde", - orange_terre_battue: "orange-terre-battue", brown_cafe_creme: "brown-cafe-creme", - brown_caramel: "brown-caramel", - brown_opera: "brown-opera", beige_gris_galet: "beige-gris-galet" } diff --git a/app/views/administrateurs/procedure_labels/_form.html.haml b/app/views/administrateurs/procedure_labels/_form.html.haml index a37eb26c5..c36b3d643 100644 --- a/app/views/administrateurs/procedure_labels/_form.html.haml +++ b/app/views/administrateurs/procedure_labels/_form.html.haml @@ -1,8 +1,16 @@ = form_with model: label, url: admin_procedure_procedure_labels_path(@procedure, id: @label.id), local: true do |f| = render Dsfr::InputComponent.new(form: f, attribute: :name, input_type: :text_field, opts: { maxlength: ProcedureLabel::NAME_MAX_LENGTH}) - = f.label :color, class: 'fr-label' do - = t('activerecord.attributes.procedure_label.color') - = render EditableChamp::AsteriskMandatoryComponent.new - = f.select :color, options_for_select(@colors_collection, selected: @label.color), {prompt: 'Choisir une couleur'}, {class: 'fr-select'} + + %fieldset.fr-fieldset + %legend.fr-fieldset__legend.fr-fieldset__legend--regular + = t('activerecord.attributes.procedure_label.color') + = render EditableChamp::AsteriskMandatoryComponent.new + + .grid-tags + - @colors_collection.each do |color| + .fr-fieldset__element + .fr-radio-group + = f.radio_button :color, color, checked: (label.color == color.underscore) + = f.label :color, value: color, class: "fr-label fr-tag fr-tag--sm fr-tag--#{color}" = render Procedure::FixedFooterComponent.new(procedure: @procedure, form: f) diff --git a/spec/controllers/administrateurs/procedures_controller_spec.rb b/spec/controllers/administrateurs/procedures_controller_spec.rb index 03e87e346..469fc8b2f 100644 --- a/spec/controllers/administrateurs/procedures_controller_spec.rb +++ b/spec/controllers/administrateurs/procedures_controller_spec.rb @@ -515,8 +515,8 @@ describe Administrateurs::ProceduresController, type: :controller do end it "create generic labels" do - expect(subject.labels.size).to eq(3) - expect(subject.labels.first.name).to eq('à relancer') + expect(subject.labels.size).to eq(5) + expect(subject.labels.first.name).to eq('À examiner') end end diff --git a/spec/controllers/instructeurs/dossiers_controller_spec.rb b/spec/controllers/instructeurs/dossiers_controller_spec.rb index c543ba69b..3ec50f3cc 100644 --- a/spec/controllers/instructeurs/dossiers_controller_spec.rb +++ b/spec/controllers/instructeurs/dossiers_controller_spec.rb @@ -1529,7 +1529,7 @@ describe Instructeurs::DossiersController, type: :controller do dossier.reload expect(dossier.dossier_labels.count).to eq(1) - expect(subject.body).to include('fr-tag--brown-caramel') + expect(subject.body).to include('fr-tag--purple-glycine') expect(subject.body).not_to include('Ajouter un label') end end diff --git a/spec/controllers/instructeurs/procedures_controller_spec.rb b/spec/controllers/instructeurs/procedures_controller_spec.rb index c14575ef5..8fcd18be9 100644 --- a/spec/controllers/instructeurs/procedures_controller_spec.rb +++ b/spec/controllers/instructeurs/procedures_controller_spec.rb @@ -663,10 +663,10 @@ describe Instructeurs::ProceduresController, type: :controller do it 'displays correctly labels in instructeur table' do expect(response.body).to include("Labels") - expect(response.body).to have_selector('ul.fr-tags-group li span.fr-tag', text: 'à relancer') - expect(response.body).to have_selector('ul.fr-tags-group li span.fr-tag', text: 'complet') - expect(response.body).not_to have_selector('ul li span.fr-tag', text: 'prêt pour validation') - expect(response.body).to have_selector('span.fr-tag', text: 'prêt pour validation') + expect(response.body).to have_selector('ul.fr-tags-group li span.fr-tag', text: 'À examiner') + expect(response.body).to have_selector('ul.fr-tags-group li span.fr-tag', text: 'À relancer') + expect(response.body).not_to have_selector('ul li span.fr-tag', text: 'Urgent') + expect(response.body).to have_selector('span.fr-tag', text: 'Urgent') end end end diff --git a/spec/system/instructeurs/instruction_spec.rb b/spec/system/instructeurs/instruction_spec.rb index 9517afd80..098878767 100644 --- a/spec/system/instructeurs/instruction_spec.rb +++ b/spec/system/instructeurs/instruction_spec.rb @@ -281,26 +281,26 @@ describe 'Instructing a dossier:', js: true do visit instructeur_dossier_path(procedure, dossier) click_on 'Ajouter un label' - check 'à relancer', allow_label_click: true - expect(page).to have_css('.fr-tag', text: "à relancer", count: 2) + check 'À relancer', allow_label_click: true + expect(page).to have_css('.fr-tag', text: "À relancer", count: 2) expect(dossier.dossier_labels.count).to eq(1) expect(page).not_to have_text('Ajouter un label') find('span.dropdown button.dropdown-button').click - expect(page).to have_checked_field('à relancer') - check 'complet', allow_label_click: true + expect(page).to have_checked_field('À relancer') + check 'Complet', allow_label_click: true - expect(page).to have_css('.fr-tag', text: "complet", count: 2) + expect(page).to have_css('.fr-tag', text: "Complet", count: 2) expect(dossier.dossier_labels.count).to eq(2) find('span.dropdown button.dropdown-button').click - uncheck 'à relancer', allow_label_click: true + uncheck 'À relancer', allow_label_click: true - expect(page).to have_unchecked_field('à relancer') - expect(page).to have_checked_field('complet') - expect(page).to have_css('.fr-tag', text: "à relancer", count: 1) - expect(page).to have_css('.fr-tag', text: "complet", count: 2) + expect(page).to have_unchecked_field('À relancer') + expect(page).to have_checked_field('Complet') + expect(page).to have_css('.fr-tag', text: "À relancer", count: 1) + expect(page).to have_css('.fr-tag', text: "Complet", count: 2) expect(dossier.dossier_labels.count).to eq(1) end end diff --git a/spec/views/instructeur/dossiers/show.html.haml_spec.rb b/spec/views/instructeur/dossiers/show.html.haml_spec.rb index 056ab6622..3a567c551 100644 --- a/spec/views/instructeur/dossiers/show.html.haml_spec.rb +++ b/spec/views/instructeur/dossiers/show.html.haml_spec.rb @@ -227,7 +227,7 @@ describe 'instructeurs/dossiers/show', type: :view do 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") + expect(subject).not_to have_text("À examiner") end end @@ -235,9 +235,9 @@ describe 'instructeurs/dossiers/show', type: :view do it 'displays button with text to add label' do expect(subject).to have_text("Ajouter un label") expect(subject).to have_selector("button.dropdown-button") - expect(subject).to have_text("à relancer", count: 1) + expect(subject).to have_text("À examiner", count: 1) within('.dropdown') do - expect(subject).to have_text("à relancer", count: 1) + expect(subject).to have_text("À examiner", count: 1) end end end @@ -250,9 +250,9 @@ describe 'instructeurs/dossiers/show', type: :view do it 'displays labels and button without text to add label' do expect(subject).not_to have_text("Ajouter un label") expect(subject).to have_selector("button.dropdown-button") - expect(subject).to have_text("à relancer", count: 2) + expect(subject).to have_text("À examiner", count: 2) within('.dropdown') do - expect(subject).to have_text("à relancer", count: 1) + expect(subject).to have_text("À examiner", count: 1) end end end