@@ -3,8 +3,12 @@ def initialize(form:)
33 @form = form
44 end
55
6- def mandatory_tasks_completed?
7- incomplete_tasks . empty?
6+ def mandatory_tasks_completed? ( ignore_missing_welsh : false )
7+ if ignore_missing_welsh
8+ incomplete_tasks . reject { |task | task == :missing_welsh_translations } . empty?
9+ else
10+ incomplete_tasks . empty?
11+ end
812 end
913
1014 def incomplete_tasks
@@ -15,6 +19,7 @@ def incomplete_tasks
1519 missing_contact_details : support_contact_details_status ,
1620 share_preview_not_completed : share_preview_status ,
1721 missing_welsh_translations : welsh_language_status ,
22+ missing_submission_email : submission_email_status ,
1823 } . reject { |_k , v | %i[ completed optional ] . include? ( v ) } . keys
1924 end
2025
@@ -32,6 +37,21 @@ def task_statuses
3237 share_preview_status :,
3338 make_live_status :,
3439 welsh_language_status :,
40+ submission_email_status :,
41+ confirm_submission_email_status :,
42+ }
43+ end
44+
45+ def incomplete_email_tasks
46+ {
47+ missing_submission_email : submission_email_status ,
48+ } . reject { |_k , v | v == :completed } . keys
49+ end
50+
51+ def email_task_statuses
52+ {
53+ submission_email_status :,
54+ confirm_submission_email_status :,
3555 }
3656 end
3757
@@ -114,7 +134,12 @@ def make_live_status
114134 end
115135
116136 def make_live_status_for_draft
117- mandatory_tasks_completed? ? :not_started : :cannot_start
137+ # If the form has a live Welsh version, we ignore missing Welsh translations
138+ # and show the make live task and link. In this case, we will show a warning
139+ # message on the make live page asking the user to update the Welsh before
140+ # the form can be made live.
141+ ignore_missing_welsh = @form . live_welsh_form_document . present?
142+ mandatory_tasks_completed? ( ignore_missing_welsh :) ? :not_started : :cannot_start
118143 end
119144
120145 def welsh_translations_invalid
@@ -123,4 +148,22 @@ def welsh_translations_invalid
123148 translation_input . invalid?
124149 end
125150 end
151+
152+ def submission_email_status
153+ {
154+ email_set_without_confirmation : :completed ,
155+ not_started : :not_started ,
156+ sent : :in_progress ,
157+ confirmed : :completed ,
158+ } [ @form . email_confirmation_status ]
159+ end
160+
161+ def confirm_submission_email_status
162+ {
163+ email_set_without_confirmation : :completed ,
164+ not_started : :cannot_start ,
165+ sent : :not_started ,
166+ confirmed : :completed ,
167+ } [ @form . email_confirmation_status ]
168+ end
126169end
0 commit comments