Merge pull request #9546 from tchak/enable-private-conditional
feat(dossier): enable conditional annotations
This commit is contained in:
commit
df621cdeae
3 changed files with 18 additions and 9 deletions
|
@ -117,10 +117,6 @@ class TypesDeChampEditor::ChampComponent < ApplicationComponent
|
||||||
revision.types_de_champ.any?(&:legacy_number?)
|
revision.types_de_champ.any?(&:legacy_number?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def conditional_enabled?
|
|
||||||
!type_de_champ.private?
|
|
||||||
end
|
|
||||||
|
|
||||||
def options_for_character_limit
|
def options_for_character_limit
|
||||||
[
|
[
|
||||||
[t('.character_limit.unlimited'), nil],
|
[t('.character_limit.unlimited'), nil],
|
||||||
|
|
|
@ -116,8 +116,7 @@
|
||||||
.type-de-champ-add-button{ id: dom_id(coordinate, :type_de_champ_add_button), class: class_names(hidden: !coordinate.empty?) }
|
.type-de-champ-add-button{ id: dom_id(coordinate, :type_de_champ_add_button), class: class_names(hidden: !coordinate.empty?) }
|
||||||
= render TypesDeChampEditor::AddChampButtonComponent.new(revision: coordinate.revision, parent: coordinate, is_annotation: coordinate.private?)
|
= render TypesDeChampEditor::AddChampButtonComponent.new(revision: coordinate.revision, parent: coordinate, is_annotation: coordinate.private?)
|
||||||
|
|
||||||
- if conditional_enabled?
|
= render(TypesDeChampEditor::ConditionsComponent.new(tdc: type_de_champ, upper_tdcs: @upper_coordinates.map(&:type_de_champ), procedure_id: procedure.id))
|
||||||
= render(TypesDeChampEditor::ConditionsComponent.new(tdc: type_de_champ, upper_tdcs: @upper_coordinates.map(&:type_de_champ), procedure_id: procedure.id))
|
|
||||||
|
|
||||||
.type-de-champ-add-button{ class: class_names(root: !coordinate.child?) }
|
.type-de-champ-add-button{ class: class_names(root: !coordinate.child?) }
|
||||||
= render TypesDeChampEditor::AddChampButtonComponent.new(revision: coordinate.revision, parent: coordinate&.parent, is_annotation: coordinate.private?, after_stable_id: type_de_champ.stable_id)
|
= render TypesDeChampEditor::AddChampButtonComponent.new(revision: coordinate.revision, parent: coordinate&.parent, is_annotation: coordinate.private?, after_stable_id: type_de_champ.stable_id)
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
describe 'Instructing a dossier:', js: true, retry: 3 do
|
describe 'Instructing a dossier:', js: true, retry: 3 do
|
||||||
include ActiveJob::TestHelper
|
include ActiveJob::TestHelper
|
||||||
|
include Logic
|
||||||
|
|
||||||
let(:password) { SECURE_PASSWORD }
|
let(:password) { SECURE_PASSWORD }
|
||||||
let!(:instructeur) { create(:instructeur, password: password) }
|
let!(:instructeur) { create(:instructeur, password: password) }
|
||||||
|
|
||||||
let!(:procedure) { create(:procedure, :with_type_de_champ, :published, instructeurs: [instructeur]) }
|
let!(:procedure) { create(:procedure, :published, instructeurs: [instructeur], types_de_champ_private: [{ type: 'checkbox', libelle: 'Yes/No', stable_id: 99 }, { libelle: 'Nom', condition: ds_eq(champ_value(99), constant(true)) }]) }
|
||||||
let!(:dossier) { create(:dossier, :en_construction, :with_entreprise, procedure: procedure) }
|
let!(:dossier) { create(:dossier, :en_construction, :with_entreprise, procedure: procedure) }
|
||||||
context 'the instructeur is also a user' do
|
context 'the instructeur is also a user' do
|
||||||
scenario 'a instructeur can fill a dossier' do
|
scenario 'a instructeur can fill a dossier' do
|
||||||
|
@ -26,7 +27,7 @@ describe 'Instructing a dossier:', js: true, retry: 3 do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'A instructeur can accept a dossier', :js do
|
scenario 'A instructeur can accept a dossier' do
|
||||||
log_in(instructeur.email, password)
|
log_in(instructeur.email, password)
|
||||||
|
|
||||||
expect(page).to have_current_path(instructeur_procedures_path)
|
expect(page).to have_current_path(instructeur_procedures_path)
|
||||||
|
@ -75,6 +76,19 @@ describe 'Instructing a dossier:', js: true, retry: 3 do
|
||||||
expect(page).not_to have_button('Repasser en instruction')
|
expect(page).not_to have_button('Repasser en instruction')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario 'An instructeur can add anotations' do
|
||||||
|
log_in(instructeur.email, password)
|
||||||
|
|
||||||
|
visit instructeur_dossier_path(procedure, dossier)
|
||||||
|
click_on 'Annotations privées'
|
||||||
|
|
||||||
|
expect(page).not_to have_field 'Nom', visible: true
|
||||||
|
check 'Yes/No', allow_label_click: true
|
||||||
|
expect(page).to have_field 'Nom'
|
||||||
|
fill_in 'Nom', with: 'John Doe'
|
||||||
|
expect(page).to have_text 'Annotations enregistrées'
|
||||||
|
end
|
||||||
|
|
||||||
scenario 'An instructeur can destroy a dossier from view' do
|
scenario 'An instructeur can destroy a dossier from view' do
|
||||||
log_in(instructeur.email, password)
|
log_in(instructeur.email, password)
|
||||||
|
|
||||||
|
@ -159,7 +173,7 @@ describe 'Instructing a dossier:', js: true, retry: 3 do
|
||||||
expect(page).to have_text(instructeur2.email)
|
expect(page).to have_text(instructeur2.email)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'A instructeur can send a dossier to several instructeurs', js: true, retry: 3 do
|
scenario 'A instructeur can send a dossier to several instructeurs' do
|
||||||
instructeur_2 = create(:instructeur)
|
instructeur_2 = create(:instructeur)
|
||||||
instructeur_3 = create(:instructeur)
|
instructeur_3 = create(:instructeur)
|
||||||
procedure.defaut_groupe_instructeur.instructeurs << [instructeur_2, instructeur_3]
|
procedure.defaut_groupe_instructeur.instructeurs << [instructeur_2, instructeur_3]
|
||||||
|
|
Loading…
Reference in a new issue