feat(routing): to_configure include invalid_rule and non_unic_rule
This commit is contained in:
parent
1b5f3a67eb
commit
0c3426228f
9 changed files with 31 additions and 18 deletions
|
@ -24,9 +24,9 @@
|
||||||
%span= gi.label
|
%span= gi.label
|
||||||
- if gi.closed
|
- if gi.closed
|
||||||
%p.fr-badge.fr-badge--info.fr-badge--sm.fr-ml-1w inactif
|
%p.fr-badge.fr-badge--info.fr-badge--sm.fr-ml-1w inactif
|
||||||
- elsif gi.routing_to_configure?
|
- elsif gi.invalid_rule?
|
||||||
%p.fr-badge.fr-badge--warning.fr-badge--sm.fr-ml-1w à configurer
|
%p.fr-badge.fr-badge--warning.fr-badge--sm.fr-ml-1w règle invalide
|
||||||
- elsif gi.non_unic_rule?
|
- 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}
|
%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
|
%span.fr-mr-1w
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
fr:
|
||||||
|
to_configure_filter:
|
||||||
|
one: "Filtrer %{count} groupe à configurer"
|
||||||
|
other: "Filtrer les %{count} groupes à configurer"
|
|
@ -16,6 +16,10 @@
|
||||||
= form_with(url: admin_procedure_groupe_instructeurs_path(@procedure),
|
= form_with(url: admin_procedure_groupe_instructeurs_path(@procedure),
|
||||||
method: :get,
|
method: :get,
|
||||||
data: { controller: 'autosubmit' }) do |f|
|
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.check_box :filter, checked: @filter_value
|
||||||
= f.label :filter, "#{ @to_configure_count } à configurer"
|
= f.label :filter, t('.to_configure_filter', count: @to_configure_count)
|
||||||
|
|
|
@ -31,9 +31,9 @@
|
||||||
|
|
||||||
.flex
|
.flex
|
||||||
%p.fr-mb-1w.fr-mr-2w Routage
|
%p.fr-mb-1w.fr-mr-2w Routage
|
||||||
- if @groupe_instructeur.routing_to_configure?
|
- if @groupe_instructeur.invalid_rule?
|
||||||
%p.fr-mb-1w.fr-badge.fr-badge--warning.fr-badge--sm à configurer
|
%p.fr-mb-1w.fr-badge.fr-badge--warning.fr-badge--sm règle invalide
|
||||||
- elsif @groupe_instructeur.non_unic_rule?
|
- 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}
|
%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
|
.flex.align-baseline.fr-mb-1w
|
||||||
|
|
|
@ -86,14 +86,18 @@ class GroupeInstructeur < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def routing_to_configure?
|
def routing_to_configure?
|
||||||
|
invalid_rule? || non_unique_rule?
|
||||||
|
end
|
||||||
|
|
||||||
|
def invalid_rule?
|
||||||
rule = routing_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 !(rule.is_a?(Logic::Eq) && rule.left.is_a?(Logic::ChampValue) && rule.right.is_a?(Logic::Constant))
|
||||||
return true if !routing_rule_matches_tdc?
|
return true if !routing_rule_matches_tdc?
|
||||||
end
|
end
|
||||||
|
|
||||||
def non_unic_rule?
|
def non_unique_rule?
|
||||||
return false if routing_to_configure?
|
return false if invalid_rule?
|
||||||
routing_rule.in?((procedure.groupe_instructeurs - [self]).map(&:routing_rule))
|
routing_rule.in?(other_groupe_instructeurs.map(&:routing_rule))
|
||||||
end
|
end
|
||||||
|
|
||||||
def groups_with_same_rule
|
def groups_with_same_rule
|
||||||
|
|
|
@ -2,7 +2,7 @@ module RoutingEngine
|
||||||
def self.compute(dossier)
|
def self.compute(dossier)
|
||||||
return if dossier.forced_groupe_instructeur
|
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)
|
gi.routing_rule&.compute(dossier.champs)
|
||||||
end
|
end
|
||||||
matching_groupe ||= dossier.procedure.defaut_groupe_instructeur
|
matching_groupe ||= dossier.procedure.defaut_groupe_instructeur
|
||||||
|
|
|
@ -23,7 +23,7 @@ describe Procedure::OneGroupeManagementComponent, type: :component do
|
||||||
procedure.reload
|
procedure.reload
|
||||||
subject
|
subject
|
||||||
end
|
end
|
||||||
it { expect(page).to have_text('à configurer') }
|
it { expect(page).to have_text('règle invalide') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -66,7 +66,7 @@ describe Administrateurs::GroupeInstructeursController, type: :controller do
|
||||||
|
|
||||||
it do
|
it do
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(response.body).to include('à configurer')
|
expect(response.body).to include('règle invalide')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ describe Administrateurs::GroupeInstructeursController, type: :controller do
|
||||||
|
|
||||||
it do
|
it do
|
||||||
expect(response).to have_http_status(:ok)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ describe Administrateurs::GroupeInstructeursController, type: :controller do
|
||||||
|
|
||||||
it do
|
it do
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(response.body).to include('à configurer')
|
expect(response.body).to include('règle invalide')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -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('Gestion des groupes')
|
||||||
expect(page).to have_text('3 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'
|
click_on 'littéraire'
|
||||||
expect(page).to have_select("targeted_champ", selected: "Spécialité")
|
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'
|
click_on 'Continuer'
|
||||||
|
|
||||||
expect(page).to have_text('Gestion des groupes')
|
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
|
# update defaut groupe
|
||||||
click_on 'défaut'
|
click_on 'défaut'
|
||||||
|
|
Loading…
Reference in a new issue