Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate add another usage to govuk_publishing_components impementation #9644

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
192 changes: 0 additions & 192 deletions app/assets/javascripts/admin/modules/add-another.js

This file was deleted.

2 changes: 1 addition & 1 deletion app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//= require govuk_publishing_components/dependencies
//= require govuk_publishing_components/analytics-ga4
//= require govuk_publishing_components/components/accordion
//= require govuk_publishing_components/components/add-another
//= require govuk_publishing_components/components/copy-to-clipboard
//= require govuk_publishing_components/components/govspeak
//= require govuk_publishing_components/components/reorderable-list
Expand All @@ -23,7 +24,6 @@
//= require admin/analytics-modules/ga4-page-view-tracking.js
//= require admin/analytics-modules/ga4-paste-tracker.js

//= require admin/modules/add-another
//= require admin/modules/document-history-paginator
//= require admin/modules/locale-switcher
//= require admin/modules/navbar-toggle
Expand Down
12 changes: 0 additions & 12 deletions app/assets/stylesheets/admin/views/_add-another.scss

This file was deleted.

22 changes: 0 additions & 22 deletions app/assets/stylesheets/admin/views/_contacts.scss

This file was deleted.

2 changes: 0 additions & 2 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ $govuk-page-width: 1140px;

@import "./admin/views/components/worldwide_offices/index/office-summary-card-component";

@import "./admin/views/add-another";
@import "./admin/views/audit-trail";
@import "./admin/views/contacts";
@import "./admin/views/dashboard-index";
@import "./admin/views/document-history-tab";
@import "./admin/views/document-collection-group-memberships-index";
Expand Down
21 changes: 21 additions & 0 deletions app/views/admin/contacts/_contact_number_fields.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<%= contact_form.fields_for :contact_numbers, contact_number do |contact_number_form| %>
<%= render "govuk_publishing_components/components/input", {
label: {
text: "Label",
},
name: "#{name}[contact_numbers_attributes][#{index}][label]",
id: "#{id}_contact_numbers_attributes_#{index}_label",
heading_size: "m",
value: contact_number_form.object.label,
} %>

<%= render "govuk_publishing_components/components/input", {
label: {
text: "Number",
},
name: "#{name}[contact_numbers_attributes][#{index}][number]",
id: "#{id}_contact_numbers_attributes_#{index}_number",
heading_size: "m",
value: contact_number_form.object.number,
} %>
<% end %>
35 changes: 10 additions & 25 deletions app/views/admin/contacts/_form_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -101,30 +101,15 @@
heading_level: 2,
heading_size: "l",
} do %>
<div data-module="AddAnother" data-add-text="Add phone number">
<%= contact_form.fields_for :contact_numbers, contact_form.object.contact_numbers do |contact_number_form| %>
<div class=" js-duplicate-fields-set govuk-!-margin-bottom-4">
<%= render "govuk_publishing_components/components/input", {
label: {
text: "Label",
},
name: "#{name}[contact_numbers_attributes][#{contact_number_form.index}][label]",
id: "#{id}_contact_numbers_attributes_#{contact_number_form.index}_label",
heading_size: "m",
value: contact_number_form.object.label,
} %>

<%= render "govuk_publishing_components/components/input", {
label: {
text: "Number",
},
name: "#{name}[contact_numbers_attributes][#{contact_number_form.index}][number]",
id: "#{id}_contact_numbers_attributes_#{contact_number_form.index}_number",
heading_size: "m",
value: contact_number_form.object.number,
} %>
</div>
<% end %>
</div>
<%= render "govuk_publishing_components/components/add_another", {
add_button_text: "Add phone number",
items: contact_form.object.contact_numbers.each_with_index.map do |contact_number, index|
{
fields: render(partial: "contact_number_fields", locals: { contact_form:, contact_number:, index:, name:, id: }),
destroy_checkbox: render("govuk_publishing_components/components/checkboxes", { name: "#{name}[contact_numbers_attributes][#{index}][_destroy]", items: [{label: "Delete", value: "1" }]})
}
end,
empty: render(partial: "contact_number_fields", locals: { contact_form:, contact_number: ContactNumber.new, index: contact_form.object.contact_numbers.length, name:, id: }),
} %>
<% end %>
</div>
12 changes: 12 additions & 0 deletions app/views/admin/fatality_notices/_casualty_fields.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<%= form.fields_for :fatality_notice_casualties, casualty do |fatality_form| %>
<%= render "govuk_publishing_components/components/textarea", {
label: {
text: "Personal details",
bold: true,
},
value: fatality_form.object.personal_details,
name: "edition[fatality_notice_casualties_attributes][#{index}][personal_details]",
id: "edition_fatality_notice_casualties_#{index}_personal_details",
rows: 2,
} %>
<% end %>
26 changes: 10 additions & 16 deletions app/views/admin/fatality_notices/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,15 @@

<h4 class="govuk-heading-m">Casualties (required)</h4>

<div data-module="AddAnother" data-add-text="Add another person" class="govuk-!-margin-bottom-4">
<%= form.fields_for :fatality_notice_casualties do |fatality_form| %>
<div class="js-duplicate-fields-set govuk-!-margin-top-4">
<%= render "govuk_publishing_components/components/textarea", {
label: {
text: "Personal details",
bold: true,
},
value: fatality_form.object.personal_details,
name: "edition[fatality_notice_casualties_attributes][#{fatality_form.index}][personal_details]",
id: "edition_fatality_notice_casualties_#{fatality_form.index}_personal_details",
rows: 2,
} %>
</div>
<% end %>
</div>
<%= render "govuk_publishing_components/components/add_another", {
add_button_text: "Add another person",
items: form.object.fatality_notice_casualties.each_with_index.map do |casualty, index|
{
fields: render(partial: "casualty_fields", locals: { form:, casualty:, index: }),
destroy_checkbox: render("govuk_publishing_components/components/checkboxes", { name: "edition[fatality_notice_casualties_attributes][#{index}][_destroy]", items: [{label: "Delete", value: "1" }]})
}
end,
empty: render(partial: "casualty_fields", locals: { form:, casualty: FatalityNoticeCasualty.new, index: form.object.fatality_notice_casualties.length }),
} %>
<% end %>
<% end %>
2 changes: 1 addition & 1 deletion app/views/admin/organisation_translations/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
},
} %>
<%= render "admin/shared/featured_link_fields", form: form %>
<%= render "admin/shared/featured_links_fields", form: form %>

<div class="govuk-button-group govuk-!-margin-top-8">
<%= render "govuk_publishing_components/components/button", {
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/organisations/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@
margin_bottom: 3,
} %>
<%= render "admin/shared/featured_link_fields", form: form, remove_banner: true %>
<%= render "admin/shared/featured_links_fields", form: form, remove_banner: true %>
</div>
<% end %>

Expand Down
Loading
Loading