Browse Source

minor refactor for readability (#1330)

pull/1494/head
Arthur Campbell 2 years ago committed by GitHub
parent
commit
3f66561c12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      app/models/form/subsection.rb
  2. 6
      app/models/log.rb

8
app/models/form/subsection.rb

@ -35,6 +35,10 @@ class Form::Subsection
:in_progress :in_progress
end end
def complete?(log)
status(log) == :completed
end
def is_incomplete?(log) def is_incomplete?(log)
%i[not_started in_progress].include?(status(log)) %i[not_started in_progress].include?(status(log))
end end
@ -58,4 +62,8 @@ class Form::Subsection
end end
end end
end end
def not_displayed_in_tasklist?(log)
!displayed_in_tasklist?(log)
end
end end

6
app/models/log.rb

@ -130,14 +130,12 @@ private
end end
def all_fields_completed? def all_fields_completed?
subsection_statuses = form.subsections.map { |subsection| subsection.status(self) if subsection.displayed_in_tasklist?(self) }.uniq.compact form.subsections.all? { |subsection| subsection.complete?(self) || subsection.not_displayed_in_tasklist?(self) }
subsection_statuses == [:completed]
end end
def all_fields_nil? def all_fields_nil?
not_started_statuses = %i[not_started cannot_start_yet] not_started_statuses = %i[not_started cannot_start_yet]
subsection_statuses = form.subsections.map { |subsection| subsection.status(self) }.uniq form.subsections.all? { |subsection| not_started_statuses.include? subsection.status(self) }
subsection_statuses.all? { |status| not_started_statuses.include?(status) }
end end
def reset_invalidated_dependent_fields! def reset_invalidated_dependent_fields!

Loading…
Cancel
Save