perf(user dossier): batch hide/show element finding

This commit is contained in:
simon lehericey 2022-10-10 21:02:28 +02:00 committed by LeSim
parent 205dece4d5
commit 437ac44143
2 changed files with 12 additions and 10 deletions

View file

@ -1,5 +1,6 @@
- @dossier.champs.filter(&:conditional?).each do |champ|
- if champ.visible?
= turbo_stream.show champ.input_group_id
- else
= turbo_stream.hide champ.input_group_id
- to_shows, to_hides = @dossier.champs.filter(&:conditional?).partition(&:visible?)
- if to_shows.present?
= turbo_stream.show_all(to_shows.map { "##{_1.input_group_id}" }.join(','))
- if to_hides.present?
= turbo_stream.hide_all(to_hides.map { "##{_1.input_group_id}" }.join(','))

View file

@ -1,5 +1,6 @@
- @dossier.champs.filter(&:conditional?).each do |champ|
- if champ.visible?
= turbo_stream.show champ.input_group_id
- else
= turbo_stream.hide champ.input_group_id
- to_shows, to_hides = @dossier.champs.filter(&:conditional?).partition(&:visible?)
- if to_shows.present?
= turbo_stream.show_all(to_shows.map { "##{_1.input_group_id}" }.join(','))
- if to_hides.present?
= turbo_stream.hide_all(to_hides.map { "##{_1.input_group_id}" }.join(','))