diff --git a/app/components/procedure/groupes_management_component/groupes_management_component.html.haml b/app/components/procedure/groupes_management_component/groupes_management_component.html.haml index ff4d1e72c..ced294476 100644 --- a/app/components/procedure/groupes_management_component/groupes_management_component.html.haml +++ b/app/components/procedure/groupes_management_component/groupes_management_component.html.haml @@ -24,9 +24,9 @@ %span= gi.label - if gi.closed %p.fr-badge.fr-badge--info.fr-badge--sm.fr-ml-1w inactif - - elsif gi.routing_to_configure? - %p.fr-badge.fr-badge--warning.fr-badge--sm.fr-ml-1w à configurer - - elsif gi.non_unic_rule? + - elsif gi.invalid_rule? + %p.fr-badge.fr-badge--warning.fr-badge--sm.fr-ml-1w règle invalide + - elsif gi.non_unique_rule? %p.fr-badge.fr-badge--warning.fr-badge--sm.fr-ml-1w règle déjà attribuée à #{gi.groups_with_same_rule} %span.fr-mr-1w diff --git a/app/components/procedure/groupes_search_component/groupes_search_component.fr.yml b/app/components/procedure/groupes_search_component/groupes_search_component.fr.yml new file mode 100644 index 000000000..f0bcae559 --- /dev/null +++ b/app/components/procedure/groupes_search_component/groupes_search_component.fr.yml @@ -0,0 +1,5 @@ +--- +fr: + to_configure_filter: + one: "Filtrer %{count} groupe à configurer" + other: "Filtrer les %{count} groupes à configurer" diff --git a/app/components/procedure/groupes_search_component/groupes_search_component.html.haml b/app/components/procedure/groupes_search_component/groupes_search_component.html.haml index 5d8829ab0..02de529ad 100644 --- a/app/components/procedure/groupes_search_component/groupes_search_component.html.haml +++ b/app/components/procedure/groupes_search_component/groupes_search_component.html.haml @@ -16,6 +16,10 @@ = form_with(url: admin_procedure_groupe_instructeurs_path(@procedure), method: :get, data: { controller: 'autosubmit' }) do |f| - .fr-checkbox-group.fr-ml-2w.fr-py-1w + .fr-checkbox-group.fr-ml-1w.fr-py-1w + .title.font-weight-bold.fr-mb-1w + %span.fr-icon-filter-fill.fr-icon--sm.fr-mr-1w{ 'aria-hidden': 'true' } + Filtre + = f.check_box :filter, checked: @filter_value - = f.label :filter, "#{ @to_configure_count } à configurer" + = f.label :filter, t('.to_configure_filter', count: @to_configure_count) diff --git a/app/components/procedure/one_groupe_management_component/one_groupe_management_component.html.haml b/app/components/procedure/one_groupe_management_component/one_groupe_management_component.html.haml index ba27c62c5..3df93fb48 100644 --- a/app/components/procedure/one_groupe_management_component/one_groupe_management_component.html.haml +++ b/app/components/procedure/one_groupe_management_component/one_groupe_management_component.html.haml @@ -31,9 +31,9 @@ .flex %p.fr-mb-1w.fr-mr-2w Routage - - if @groupe_instructeur.routing_to_configure? - %p.fr-mb-1w.fr-badge.fr-badge--warning.fr-badge--sm à configurer - - elsif @groupe_instructeur.non_unic_rule? + - if @groupe_instructeur.invalid_rule? + %p.fr-mb-1w.fr-badge.fr-badge--warning.fr-badge--sm règle invalide + - elsif @groupe_instructeur.non_unique_rule? %p.fr-mb-1w.fr-badge.fr-badge--warning.fr-badge--sm règle déjà attribuée à #{@groupe_instructeur.groups_with_same_rule} .flex.align-baseline.fr-mb-1w diff --git a/app/models/groupe_instructeur.rb b/app/models/groupe_instructeur.rb index cc1de88a6..ee8e26fad 100644 --- a/app/models/groupe_instructeur.rb +++ b/app/models/groupe_instructeur.rb @@ -86,14 +86,18 @@ class GroupeInstructeur < ApplicationRecord end def routing_to_configure? + invalid_rule? || non_unique_rule? + end + + def invalid_rule? rule = routing_rule return true if !(rule.is_a?(Logic::Eq) && rule.left.is_a?(Logic::ChampValue) && rule.right.is_a?(Logic::Constant)) return true if !routing_rule_matches_tdc? end - def non_unic_rule? - return false if routing_to_configure? - routing_rule.in?((procedure.groupe_instructeurs - [self]).map(&:routing_rule)) + def non_unique_rule? + return false if invalid_rule? + routing_rule.in?(other_groupe_instructeurs.map(&:routing_rule)) end def groups_with_same_rule diff --git a/app/models/routing_engine.rb b/app/models/routing_engine.rb index 2fa1a9032..a0a671d33 100644 --- a/app/models/routing_engine.rb +++ b/app/models/routing_engine.rb @@ -2,7 +2,7 @@ module RoutingEngine def self.compute(dossier) return if dossier.forced_groupe_instructeur - matching_groupe = dossier.procedure.groupe_instructeurs.active.reject(&:routing_to_configure?).find do |gi| + matching_groupe = dossier.procedure.groupe_instructeurs.active.reject(&:invalid_rule?).find do |gi| gi.routing_rule&.compute(dossier.champs) end matching_groupe ||= dossier.procedure.defaut_groupe_instructeur diff --git a/spec/components/procedures/one_group_management_component_spec.rb b/spec/components/procedures/one_group_management_component_spec.rb index d412e637a..bebdc6ef4 100644 --- a/spec/components/procedures/one_group_management_component_spec.rb +++ b/spec/components/procedures/one_group_management_component_spec.rb @@ -23,7 +23,7 @@ describe Procedure::OneGroupeManagementComponent, type: :component do procedure.reload subject end - it { expect(page).to have_text('à configurer') } + it { expect(page).to have_text('règle invalide') } end end end diff --git a/spec/controllers/administrateurs/groupe_instructeurs_controller_spec.rb b/spec/controllers/administrateurs/groupe_instructeurs_controller_spec.rb index 55c14964e..255fc7a67 100644 --- a/spec/controllers/administrateurs/groupe_instructeurs_controller_spec.rb +++ b/spec/controllers/administrateurs/groupe_instructeurs_controller_spec.rb @@ -66,7 +66,7 @@ describe Administrateurs::GroupeInstructeursController, type: :controller do it do expect(response).to have_http_status(:ok) - expect(response.body).to include('à configurer') + expect(response.body).to include('règle invalide') end end @@ -81,7 +81,7 @@ describe Administrateurs::GroupeInstructeursController, type: :controller do it do expect(response).to have_http_status(:ok) - expect(response.body).not_to include('à configurer') + expect(response.body).not_to include('règle invalide') end end @@ -96,7 +96,7 @@ describe Administrateurs::GroupeInstructeursController, type: :controller do it do expect(response).to have_http_status(:ok) - expect(response.body).to include('à configurer') + expect(response.body).to include('règle invalide') end end end diff --git a/spec/system/routing/rules_full_scenario_spec.rb b/spec/system/routing/rules_full_scenario_spec.rb index a3bc9cdf1..e349def0a 100644 --- a/spec/system/routing/rules_full_scenario_spec.rb +++ b/spec/system/routing/rules_full_scenario_spec.rb @@ -36,7 +36,7 @@ describe 'The routing with rules', js: true do expect(page).to have_text('Gestion des groupes') expect(page).to have_text('3 groupes') - expect(page).not_to have_text('À configurer') + expect(page).not_to have_text('à configurer') click_on 'littéraire' expect(page).to have_select("targeted_champ", selected: "Spécialité") @@ -56,7 +56,7 @@ describe 'The routing with rules', js: true do click_on 'Continuer' expect(page).to have_text('Gestion des groupes') - expect(page).to have_text('à configurer') + expect(page).to have_text('règle invalide') # update defaut groupe click_on 'défaut'