Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctif: ETQ admin, je souhaite pouvoir utiliser des champs public pour conditionner une annotation privée #10503

Conversation

mfo
Copy link
Contributor

@mfo mfo commented Jun 10, 2024

No description provided.

…hamp_public on condition for types_de_champ_private
Copy link

codecov bot commented Jun 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.88%. Comparing base (5ef29a2) to head (27b86f9).
Report is 27 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10503      +/-   ##
==========================================
- Coverage   80.89%   80.88%   -0.01%     
==========================================
  Files        1211     1211              
  Lines       25612    25635      +23     
  Branches     4623     4632       +9     
==========================================
+ Hits        20719    20736      +17     
- Misses       4893     4899       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@colinux colinux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pas tout pigé, mais d'après les tests ça a l'air bien ;)

Comment on lines 9 to 18
tdcs
.map.with_index
.filter_map { |tdc, i| tdc.condition? ? [tdc, i] : nil }
.map do |tdc, i|
[tdc, tdc.condition.errors(public_tdcs.take(i))]
[tdc, tdc.condition.errors(tdcs.take(i))]
end
.filter { |_tdc, errors| errors.present? }
.each do |tdc, _error_hash|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiens à l'occas on pourra essayer de refactorer cet enchainement pour éviter autant de boucles et allocations

Copy link
Member

@colinux colinux Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

peut-être que ça marche :

Suggested change
tdcs
.map.with_index
.filter_map { |tdc, i| tdc.condition? ? [tdc, i] : nil }
.map do |tdc, i|
[tdc, tdc.condition.errors(public_tdcs.take(i))]
[tdc, tdc.condition.errors(tdcs.take(i))]
end
.filter { |_tdc, errors| errors.present? }
.each do |tdc, _error_hash|
tdcs.each_with_index do |tdc, i|
next unless tdc.condition?
errors = tdc.condition.errors(tdcs.take(i))
next if errors.blank?
procedure.errors.add(
attribute,
procedure.errors.generate_message(attribute, :invalid_condition, { value: tdc.libelle }),
type_de_champ: tdc
)
end

Comment on lines 423 to 425

it 'validates that types de champ private condition works types de champ public and private' do
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it 'validates that types de champ private condition works types de champ public and private' do
end

@mfo mfo force-pushed the US/fix-condition-validator-on-private-champ-using-public-tdc branch 3 times, most recently from 71c418e to e238c9b Compare June 10, 2024 08:37
@mfo mfo enabled auto-merge June 10, 2024 08:37
@mfo mfo force-pushed the US/fix-condition-validator-on-private-champ-using-public-tdc branch from e238c9b to 86bb346 Compare June 10, 2024 09:24
…blic on condition for types_de_champ_private
@mfo mfo force-pushed the US/fix-condition-validator-on-private-champ-using-public-tdc branch from 86bb346 to 27b86f9 Compare June 10, 2024 09:26
@mfo mfo added this pull request to the merge queue Jun 10, 2024
Merged via the queue into demarches-simplifiees:main with commit ab522a3 Jun 10, 2024
18 checks passed
@mfo mfo deleted the US/fix-condition-validator-on-private-champ-using-public-tdc branch June 10, 2024 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants