Skip to content

Commit 37f69d5

Browse files
committed
Add tasks for making individual languages live
1 parent 737bc08 commit 37f69d5

7 files changed

Lines changed: 424 additions & 44 deletions

File tree

app/services/form_task_list_service.rb

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,20 @@ def group_upgrade_url
193193

194194
def make_form_live_section_tasks
195195
[
196-
{
197-
task_name: share_preview_task_name,
198-
path: share_preview_path(@form.id),
199-
status: @task_statuses[:share_preview_status],
200-
active: @form.pages.any?,
201-
},
202-
make_live_task,
203-
]
196+
share_preview_task,
197+
(make_live_task unless display_make_languages_live_tasks?),
198+
(make_only_english_live_task if display_make_languages_live_tasks?),
199+
(make_only_welsh_live_task if display_make_languages_live_tasks?),
200+
].compact
201+
end
202+
203+
def share_preview_task
204+
{
205+
task_name: share_preview_task_name,
206+
path: share_preview_path(@form.id),
207+
status: @task_statuses[:share_preview_status],
208+
active: @form.pages.any?,
209+
}
204210
end
205211

206212
def make_live_task
@@ -215,6 +221,34 @@ def make_live_task
215221
}
216222
end
217223

224+
def make_only_english_live_task
225+
status = @task_statuses[:make_live_status]
226+
can_make_form_live = @form.can_make_language_live?(language: "en")
227+
228+
{
229+
task_name: I18n.t("forms.task_list_create.make_form_live_section.make_english_form_live"),
230+
path: can_make_form_live ? make_language_live_path(@form.id, language: "en") : "",
231+
status: status,
232+
active: can_make_form_live,
233+
}
234+
end
235+
236+
def make_only_welsh_live_task
237+
status = @task_statuses[:make_only_welsh_live_status]
238+
can_make_form_live = @form.can_make_language_live?(language: "cy")
239+
240+
{
241+
task_name: I18n.t("forms.task_list_create.make_form_live_section.make_welsh_form_live"),
242+
path: can_make_form_live ? make_language_live_path(@form.id, language: "cy") : "",
243+
status: status,
244+
active: can_make_form_live,
245+
}
246+
end
247+
248+
def display_make_languages_live_tasks?
249+
@form.live_welsh_form_document.blank?
250+
end
251+
218252
def live_title_name
219253
return I18n.t("forms.task_list_create.make_form_live_section.title") if @form.is_archived?
220254

app/services/task_status_service.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ def all_task_statuses
3636
batch_submissions_status:,
3737
share_preview_status:,
3838
make_live_status:,
39+
make_only_english_live_status:,
40+
make_only_welsh_live_status:,
3941
welsh_language_status:,
4042
submission_email_status:,
4143
confirm_submission_email_status:,
@@ -139,6 +141,20 @@ def make_live_status
139141
:completed if @form.has_live_version
140142
end
141143

144+
def make_only_english_live_status
145+
return :not_started if @form.can_make_language_live?(language: "en")
146+
return :completed if @form.state == "live"
147+
148+
:cannot_start
149+
end
150+
151+
def make_only_welsh_live_status
152+
return :not_started if @form.can_make_language_live?(language: "cy")
153+
return :completed if @form.live_welsh_form_document.present?
154+
155+
:cannot_start
156+
end
157+
142158
def make_live_status_for_draft
143159
# If the form has a live Welsh version, we ignore missing Welsh translations
144160
# and show the make live task and link. In this case, we will show a warning

config/locales/en.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,9 @@ en:
546546
547547
A group admin can request to upgrade the group so forms can be made live. You can <a href="%{group_members_path}">view the members of the group</a> to find a group admin.
548548
no_org_admin: You cannot make this form live because it’s in a ‘trial’ group.
549+
make_english_form_live: Make your English form live
549550
make_live: Make your form live
551+
make_welsh_form_live: Make your Welsh form live
550552
share_preview: Share a preview of your draft form
551553
title: Make your form live
552554
user_cannot_administer:

spec/features/form/make_changes_live_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
then_i_see_the_page_to_edit_the_draft
2222
then_i_edit_the_name_of_the_form
2323
then_i_mark_the_share_preview_step_as_completed
24-
when_i_click_make_your_changes_live
25-
then_i_see_a_page_to_confirm_making_the_draft_live
24+
when_i_click_make_your_english_form_live
25+
then_i_see_a_page_to_confirm_making_the_english_form_live
2626
when_i_choose_yes
2727
then_i_see_a_confirmation_that_the_changes_are_live
2828
end
@@ -58,14 +58,14 @@ def then_i_mark_the_share_preview_step_as_completed
5858
click_link_or_button "Save and continue"
5959
end
6060

61-
def when_i_click_make_your_changes_live
62-
click_link "Make your changes live"
61+
def when_i_click_make_your_english_form_live
62+
click_link "Make your English form live"
6363
end
6464

65-
def then_i_see_a_page_to_confirm_making_the_draft_live
66-
expect(page.find("h1")).to have_text "Make your changes live"
65+
def then_i_see_a_page_to_confirm_making_the_english_form_live
66+
expect(page.find("h1")).to have_text "Make your English form live"
6767
expect(page.find("h1")).to have_text updated_name
68-
expect(page).to have_text "Are you sure you want to make your draft live?"
68+
expect(page).to have_text "Are you sure you want to make your English form live?"
6969
expect_page_to_have_no_axe_errors(page)
7070
end
7171

spec/models/form_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,8 @@
10201020
welsh_language_status: :optional,
10211021
share_preview_status: :completed,
10221022
make_live_status: :completed,
1023+
make_only_english_live_status: :completed,
1024+
make_only_welsh_live_status: :cannot_start,
10231025
}
10241026
expect(form.all_task_statuses).to eq expected_hash
10251027
end

0 commit comments

Comments
 (0)