amelioration(ChorusComponent): ameliore le rendu de la tuile si celle ci n'est que partiellement rempli
This commit is contained in:
parent
9c2e8d266c
commit
857c1f0c21
7 changed files with 51 additions and 15 deletions
|
@ -7,7 +7,7 @@ class Procedure::Card::ChorusComponent < ApplicationComponent
|
|||
@procedure.chorusable?
|
||||
end
|
||||
|
||||
def error_messages
|
||||
[]
|
||||
def complete?
|
||||
@procedure.chorus_configuration.complete?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
.fr-col-6.fr-col-md-4.fr-col-lg-3.chorus-component
|
||||
= link_to edit_admin_procedure_chorus_path(@procedure), class: 'fr-tile fr-enlarge-link', title: 'Configurer le cadre budgetaire Chorus' do
|
||||
.fr-tile__body.flex.column.align-center.justify-between
|
||||
- if error_messages.present?
|
||||
%div
|
||||
%span.icon.refuse
|
||||
%p.fr-tile-status-error À modifier
|
||||
- elsif @count == 0
|
||||
- if !@procedure.chorus_configuration.complete?
|
||||
%div
|
||||
%span.icon.clock
|
||||
%p.fr-tile-status-todo À compléter
|
||||
|
|
|
@ -49,4 +49,12 @@ class ChorusConfiguration
|
|||
api_result = api_result.symbolize_keys
|
||||
"#{api_result[:label]} - #{api_result[:code]}"
|
||||
end
|
||||
|
||||
def complete?
|
||||
[
|
||||
centre_de_coup,
|
||||
domaine_fonctionnel,
|
||||
referentiel_de_programmation
|
||||
].all?(&:present?)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
|
||||
.container
|
||||
%h1.mb-2
|
||||
%h1.fr-h1
|
||||
Cadre budgétaire
|
||||
|
||||
= render Procedure::ChorusFormComponent.new(procedure: @procedure)
|
||||
|
|
|
@ -57,7 +57,7 @@ describe Administrateurs::ChorusController, type: :controller do
|
|||
let(:referentiel_de_programmation) { '{"code":"010101010101","label":"DOTATIONS+CARPA+AJ+ET+AUTRES+INTERVENTIONS","description":null,"code_programme":"101"}' }
|
||||
let(:chorus_configuration_params) do
|
||||
{
|
||||
centre_de_coup:, domaine_fonctionnel:, referentiel_de_programmation:,
|
||||
centre_de_coup:, domaine_fonctionnel:, referentiel_de_programmation:
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -422,6 +422,22 @@ FactoryBot.define do
|
|||
trait :svr do
|
||||
sva_svr { SVASVRConfiguration.new(decision: :svr).attributes }
|
||||
end
|
||||
|
||||
trait :empty_chorus do
|
||||
chorus { ChorusConfiguration.new }
|
||||
end
|
||||
|
||||
trait :partial_chorus do
|
||||
chorus { ChorusConfiguration.new(centre_de_coup: { a: 1 }) }
|
||||
end
|
||||
|
||||
trait :filled_chorus do
|
||||
chorus do
|
||||
ChorusConfiguration.new(centre_de_coup: { a: 1 },
|
||||
domaine_fonctionnel: { b: 2 },
|
||||
referentiel_de_programmation: { c: 3 })
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
describe ChorusConfiguration do
|
||||
subject { create(:procedure) }
|
||||
it { is_expected.to be_valid }
|
||||
|
||||
context 'empty' do
|
||||
subject { create(:procedure, chorus: {}) }
|
||||
subject { create(:procedure, :empty_chorus) }
|
||||
it { is_expected.to be_valid }
|
||||
end
|
||||
|
||||
context 'partially filled chorus_configuration' do
|
||||
subject { create(:procedure, chorus: { 'centre_de_cout' => '1' }) }
|
||||
subject { create(:procedure, :partial_chorus) }
|
||||
it { is_expected.to be_valid }
|
||||
end
|
||||
|
||||
context 'fully filled chorus_configuration' do
|
||||
subject { create(:procedure, chorus: { 'centre_de_coup' => {}, 'domaine_fonctionnel' => {}, 'referentiel_de_programmation' => {} }) }
|
||||
subject { create(:procedure, :filled_chorus) }
|
||||
it { is_expected.to be_valid }
|
||||
end
|
||||
|
||||
|
@ -33,4 +30,23 @@ describe ChorusConfiguration do
|
|||
end.not_to raise_error
|
||||
end
|
||||
end
|
||||
|
||||
describe '#complete?' do
|
||||
subject { procedure.chorus_configuration.complete? }
|
||||
|
||||
context 'without data' do
|
||||
let(:procedure) { create(:procedure, :empty_chorus) }
|
||||
it { is_expected.to be_falsey }
|
||||
end
|
||||
|
||||
context 'with partial data' do
|
||||
let(:procedure) { create(:procedure, :partial_chorus) }
|
||||
it { is_expected.to be_falsey }
|
||||
end
|
||||
|
||||
context 'with all data' do
|
||||
let(:procedure) { create(:procedure, :filled_chorus) }
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue