feat(Procedure::Cards::IneligibleDossier): add an ineligibilite dossier card to procedure dashboard
This commit is contained in:
parent
810d272be2
commit
12d23f1498
8 changed files with 77 additions and 1 deletions
|
@ -61,7 +61,7 @@ class Conditions::ConditionsComponent < ApplicationComponent
|
|||
|
||||
def available_targets_for_select
|
||||
@source_tdcs
|
||||
.filter { |tdc| ChampValue::MANAGED_TYPE_DE_CHAMP.values.include?(tdc.type_champ) }
|
||||
.filter(&:conditionable?)
|
||||
.map { |tdc| [tdc.libelle, champ_value(tdc.stable_id).to_json] }
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
class Procedure::Card::IneligibiliteDossierComponent < ApplicationComponent
|
||||
def initialize(procedure:)
|
||||
@procedure = procedure
|
||||
end
|
||||
|
||||
def ready?
|
||||
@procedure.draft_revision
|
||||
.conditionable_types_de_champ
|
||||
.present?
|
||||
end
|
||||
|
||||
def error?
|
||||
!@procedure.draft_revision.validate(:ineligibilite_rules_editor)
|
||||
end
|
||||
|
||||
def completed?
|
||||
@procedure.draft_revision.ineligibilite_enabled
|
||||
end
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
fr:
|
||||
title: Inéligibilité des dossiers
|
||||
state:
|
||||
pending: Champs à configurer
|
||||
ready: À configurer
|
||||
completed: Activé
|
||||
subtitle: Gérez vos critères d’inéligibilité en fonction des champs du formulaire
|
|
@ -0,0 +1,15 @@
|
|||
.fr-col-6.fr-col-md-4.fr-col-lg-3
|
||||
= link_to edit_admin_procedure_ineligibilite_rules_path(@procedure), class: 'fr-tile fr-enlarge-link' do
|
||||
.fr-tile__body.flex.column.align-center.justify-between
|
||||
- if !ready?
|
||||
%p.fr-badge.fr-badge--warning= t('.state.pending')
|
||||
- elsif error?
|
||||
%p.fr-badge.fr-badge--error À modifier
|
||||
- elsif !completed?
|
||||
%p.fr-badge.fr-badge--info= t('.state.ready')
|
||||
- else
|
||||
%p.fr-badge.fr-badge--success= t('.state.completed')
|
||||
%div
|
||||
%h3.fr-h6.fr-mt-10v= t('.title')
|
||||
%p.fr-tile-subtitle= t('.subtitle')
|
||||
%p.fr-btn.fr-btn--tertiary= t('views.shared.actions.edit')
|
|
@ -251,6 +251,10 @@ class ProcedureRevision < ApplicationRecord
|
|||
types_de_champ_public.filter(&:routable?)
|
||||
end
|
||||
|
||||
def conditionable_types_de_champ
|
||||
types_de_champ_for(scope: :public).filter(&:conditionable?)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def compute_estimated_fill_duration
|
||||
|
|
|
@ -657,6 +657,10 @@ class TypeDeChamp < ApplicationRecord
|
|||
type_champ.in?(ROUTABLE_TYPES)
|
||||
end
|
||||
|
||||
def conditionable?
|
||||
Logic::ChampValue::MANAGED_TYPE_DE_CHAMP.values.include?(type_champ)
|
||||
end
|
||||
|
||||
def invalid_regexp?
|
||||
self.errors.delete(:expression_reguliere)
|
||||
self.errors.delete(:expression_reguliere_exemple_text)
|
||||
|
|
|
@ -71,6 +71,7 @@
|
|||
= render Procedure::Card::PresentationComponent.new(procedure: @procedure)
|
||||
= render Procedure::Card::ZonesComponent.new(procedure: @procedure) if Rails.application.config.ds_zonage_enabled
|
||||
= render Procedure::Card::ChampsComponent.new(procedure: @procedure)
|
||||
= render Procedure::Card::IneligibiliteDossierComponent.new(procedure: @procedure)
|
||||
= render Procedure::Card::ServiceComponent.new(procedure: @procedure, administrateur: current_administrateur)
|
||||
= render Procedure::Card::AdministrateursComponent.new(procedure: @procedure)
|
||||
= render Procedure::Card::InstructeursComponent.new(procedure: @procedure)
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
describe Procedure::Card::IneligibiliteDossierComponent, type: :component do
|
||||
describe 'render' do
|
||||
subject do
|
||||
render_inline(described_class.new(procedure: procedure))
|
||||
end
|
||||
|
||||
context 'when none of types_de_champ_public supports conditional' do
|
||||
let(:procedure) { create(:procedure, types_de_champ_public: []) }
|
||||
|
||||
it 'render missing setup' do
|
||||
subject
|
||||
expect(page).to have_text('Champs manquant')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when at least one of types_de_champ_public support conditional' do
|
||||
let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :yes_no }]) }
|
||||
|
||||
it 'render the template' do
|
||||
subject
|
||||
expect(page).to have_text('À configurer')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue