Skip to content

Commit e84c517

Browse files
committed
Update list of forms to include indication of Welsh versions
form list now includes text underneath the form name to indicate if the form has a welsh version, and if that version is live archived or draft
1 parent 3a3938d commit e84c517

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

app/presenters/form_list_presenter.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def head
5050

5151
def rows
5252
rows = forms.sort_by { |form| [form.name.downcase, form.created_at] }.map do |form|
53-
row = [{ text: form_name_link(form) },
53+
row = [{ text: form_name_link(form) + welsh_status(form) },
5454
{ text: find_creator_name(form) },
5555
{ text: form_status_tags(form), numeric: true }]
5656

@@ -74,6 +74,16 @@ def change_group_link(form)
7474
)
7575
end
7676

77+
def welsh_status(form)
78+
if form.live_welsh_form_document.present?
79+
"<p class=\"govuk-!-margin-bottom-1 govuk-!-margin-top-2 govuk-hint\">With Welsh Version</p>".html_safe
80+
elsif form.archived_welsh_form_document.present?
81+
"<p class=\"govuk-!-margin-bottom-1 govuk-!-margin-top-2 govuk-hint\">With archived Welsh version</p>".html_safe
82+
elsif form.available_languages.include? "cy"
83+
"<p class=\"govuk-!-margin-bottom-1 govuk-!-margin-top-2 govuk-hint\">With Welsh draft</p>".html_safe
84+
end
85+
end
86+
7787
def form_status_tags(form)
7888
# Create an instance of controller. We are using ApplicationController here.
7989
view_context = ApplicationController.new.view_context

spec/presenters/form_list_presenter_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,25 @@
114114
expect(rows[3][0][:text]).to eq("<a class=\"govuk-link\" href=\"/forms/2\">b</a>")
115115
end
116116
end
117+
118+
context "when a welsh version of the form exists" do
119+
let(:forms) do
120+
[
121+
create(:form, :live, :with_welsh_translation, id: 1, name: "form with a live Welsh Version"),
122+
create(:form, :archived, :with_welsh_translation, id: 2, name: "form with an archived Welsh version"),
123+
create(:form, id: 3, name: "form with Welsh draft", available_languages: %w[cy en]),
124+
create(:form, id: 4, name: "form with no Welsh version"),
125+
]
126+
end
127+
128+
it "appends the correct text" do
129+
rows = presenter.data[:rows]
130+
expect(rows[0][0][:text]).to eq("<a class=\"govuk-link\" href=\"/forms/1/live\">form with a live Welsh Version</a><p class=\"govuk-!-margin-bottom-1 govuk-!-margin-top-2 govuk-hint\">With Welsh Version</p>")
131+
expect(rows[1][0][:text]).to eq("<a class=\"govuk-link\" href=\"/forms/2/archived\">form with an archived Welsh version</a><p class=\"govuk-!-margin-bottom-1 govuk-!-margin-top-2 govuk-hint\">With archived Welsh version</p>")
132+
expect(rows[2][0][:text]).to eq("<a class=\"govuk-link\" href=\"/forms/4\">form with no Welsh version</a>")
133+
expect(rows[3][0][:text]).to eq("<a class=\"govuk-link\" href=\"/forms/3\">form with Welsh draft</a><p class=\"govuk-!-margin-bottom-1 govuk-!-margin-top-2 govuk-hint\">With Welsh draft</p>")
134+
end
135+
end
117136
end
118137
end
119138
end

0 commit comments

Comments
 (0)