-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2490 from alphagov/497_Edit-page_Related-external…
…-links 497 edit page related external links
- Loading branch information
Showing
11 changed files
with
386 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
app/views/editions/secondary_nav_tabs/_related_external_links.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<%= header_for("Related external links") %> | ||
|
||
<%= form_for @edition.artefact, url: update_related_external_links_edition_path(@resource) do %> | ||
<% | ||
if @edition.artefact.external_links.count == 0 | ||
items = [{ | ||
fields: render(partial: "secondary_nav_tabs/related_external_links/add-another_fieldset", locals: { index: 0, id: nil }), | ||
destroy_checkbox: render(partial: "secondary_nav_tabs/related_external_links/add-another_checkbox", locals: {index: 0}), | ||
}] | ||
empty = render(partial: "secondary_nav_tabs/related_external_links/add-another_fieldset", locals: { index: 1, id: nil }) | ||
else | ||
items = @edition.artefact.external_links.each_with_index.map do | external_link, index | | ||
{ | ||
fields: render(partial: "secondary_nav_tabs/related_external_links/add-another_fieldset", locals: { index:, id: external_link.id }), | ||
destroy_checkbox: render(partial: "secondary_nav_tabs/related_external_links/add-another_checkbox", locals: {index: index}), | ||
} | ||
end | ||
empty = render(partial: "secondary_nav_tabs/related_external_links/add-another_fieldset", locals: { index: @edition.artefact.external_links.count, id: nil }) | ||
end | ||
%> | ||
|
||
<%= render "govuk_publishing_components/components/add_another", { | ||
fieldset_legend: "Link", | ||
add_button_text: "Add another link", | ||
items: items, | ||
empty: empty, | ||
} %> | ||
|
||
<%= render "govuk_publishing_components/components/inset_text", { | ||
text: "After saving, changes to related external links will be visible on the site the next time this publication is published.", | ||
} %> | ||
|
||
<%= render "govuk_publishing_components/components/button", { | ||
text: "Save", | ||
} %> | ||
<% end %> | ||
</div> | ||
</div> |
5 changes: 5 additions & 0 deletions
5
app/views/editions/secondary_nav_tabs/related_external_links/_add-another_checkbox.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<%= render "govuk_publishing_components/components/checkboxes", { | ||
name: "artefact[external_links_attributes][#{index}][_destroy]", | ||
id: "artefact_external_links_attributes_#{index}__destroy", | ||
items: [{label: "Delete", value: "1" }], | ||
} %> |
24 changes: 24 additions & 0 deletions
24
app/views/editions/secondary_nav_tabs/related_external_links/_add-another_fieldset.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<% if id %> | ||
<%= hidden_field_tag "artefact[external_links_attributes][#{index}][id]", id %> | ||
<% end %> | ||
|
||
<%= render "govuk_publishing_components/components/input", { | ||
label: { | ||
text: "Title", | ||
bold: true, | ||
}, | ||
name: "artefact[external_links_attributes][#{index}][title]", | ||
id: "artefact_external_links_attributes_#{index}_title", | ||
value: @edition.artefact.external_links[index].present? ? @edition.artefact.external_links[index].title : "", | ||
} %> | ||
|
||
<%= render "govuk_publishing_components/components/input", { | ||
label: { | ||
text: "URL", | ||
bold: true, | ||
}, | ||
name: "artefact[external_links_attributes][#{index}][url]", | ||
id: "artefact_external_links_attributes_#{index}_url", | ||
value: @edition.artefact.external_links[index].present? ? @edition.artefact.external_links[index].url : "", | ||
hint: "Example: https://gov.uk", | ||
} %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.