refactor(dossier): use size and empty? instead of count

This commit is contained in:
Paul Chavard 2022-07-13 11:08:54 +02:00 committed by Paul Chavard
parent 1657605ef1
commit 9fec11bfd0

View file

@ -16,10 +16,10 @@
- drafts = dossiers.merge(Dossier.state_brouillon) - drafts = dossiers.merge(Dossier.state_brouillon)
- not_drafts = dossiers.merge(Dossier.state_not_brouillon) - not_drafts = dossiers.merge(Dossier.state_not_brouillon)
- if dossiers.count == 0 - if dossiers.empty?
= link_to t('views.commencer.show.start_procedure'), url_for_new_dossier(@revision), class: ['button large expand primary'] = link_to t('views.commencer.show.start_procedure'), url_for_new_dossier(@revision), class: ['button large expand primary']
- elsif drafts.count == 1 && not_drafts.count == 0 - elsif drafts.size == 1 && not_drafts.empty?
- dossier = drafts.first - dossier = drafts.first
%h2.huge-title= t('views.commencer.show.already_draft') %h2.huge-title= t('views.commencer.show.already_draft')
%p %p
@ -27,7 +27,7 @@
= link_to t('views.commencer.show.continue_file'), brouillon_dossier_path(dossier), class: ['button large expand primary'] = link_to t('views.commencer.show.continue_file'), brouillon_dossier_path(dossier), class: ['button large expand primary']
= link_to t('views.commencer.show.start_new_file'), url_for_new_dossier(@revision), class: ['button large expand'] = link_to t('views.commencer.show.start_new_file'), url_for_new_dossier(@revision), class: ['button large expand']
- elsif not_drafts.count == 1 - elsif not_drafts.size == 1
- dossier = not_drafts.first - dossier = not_drafts.first
%h2.huge-title= t('views.commencer.show.already_not_draft') %h2.huge-title= t('views.commencer.show.already_not_draft')
%p %p