feat(routing): add warning for groups with same rule
This commit is contained in:
parent
3b204faaae
commit
b059e905cd
4 changed files with 28 additions and 2 deletions
|
@ -23,6 +23,8 @@
|
|||
%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?
|
||||
%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
|
||||
#{gi.dossiers.visible_by_administration.size}
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
%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?
|
||||
%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
|
||||
.fr-mr-2w.no-wrap si le champ
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
# procedure_id :bigint not null
|
||||
#
|
||||
class GroupeInstructeur < ApplicationRecord
|
||||
include Logic
|
||||
DEFAUT_LABEL = 'défaut'
|
||||
belongs_to :procedure, -> { with_discarded }, inverse_of: :groupe_instructeurs, optional: false
|
||||
has_many :assign_tos, dependent: :destroy
|
||||
|
@ -87,7 +88,20 @@ class GroupeInstructeur < ApplicationRecord
|
|||
def routing_to_configure?
|
||||
rule = routing_rule
|
||||
return true if !(rule.is_a?(Logic::Eq) && rule.left.is_a?(Logic::ChampValue) && rule.right.is_a?(Logic::Constant))
|
||||
!routing_rule_matches_tdc?
|
||||
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))
|
||||
end
|
||||
|
||||
def groups_with_same_rule
|
||||
return if routing_rule.nil?
|
||||
other_groupe_instructeurs
|
||||
.filter { |gi| !gi.routing_rule.nil? && gi.routing_rule.right != empty && gi.routing_rule == routing_rule }
|
||||
.map(&:label)
|
||||
.join(', ')
|
||||
end
|
||||
|
||||
def other_groupe_instructeurs
|
||||
|
|
|
@ -49,13 +49,14 @@ describe 'The routing with rules', js: true do
|
|||
expect(page).to have_select("value", selected: "scientifique")
|
||||
end
|
||||
|
||||
scenario 'Routage personnalisé' do
|
||||
scenario 'Routage avancé' do
|
||||
steps_to_routing_configuration
|
||||
|
||||
choose('Avancé', allow_label_click: true)
|
||||
click_on 'Continuer'
|
||||
|
||||
expect(page).to have_text('Gestion des groupes')
|
||||
expect(page).to have_text('à configurer')
|
||||
|
||||
# update defaut groupe
|
||||
click_on 'défaut'
|
||||
|
@ -112,9 +113,16 @@ describe 'The routing with rules', js: true do
|
|||
|
||||
click_on 'littéraire'
|
||||
|
||||
within('.target') { select('Spécialité') }
|
||||
within('.value') { select('scientifique') }
|
||||
|
||||
expect(page).to have_text('règle déjà attribuée à scientifique')
|
||||
|
||||
within('.target') { select('Spécialité') }
|
||||
within('.value') { select('littéraire') }
|
||||
|
||||
expect(page).not_to have_text('règle déjà attribuée à scientifique')
|
||||
|
||||
procedure.groupe_instructeurs.where(closed: false).each { |gi| wait_until { gi.reload.routing_rule.present? } }
|
||||
|
||||
# add a group without routing rules
|
||||
|
|
Loading…
Reference in a new issue