Skip to content

Commit

Permalink
Documented the peculiarities with the remaining five views
Browse files Browse the repository at this point in the history
31 out of 36 views now use the shared
"specialist_document_form.html.erb" view exclusively. These
remaining five views can't yet use the shared form (for a variety
of reasons), though in the case of the "flood and coastal erosion
risk management" finder I was able to pull in the shared view for
the main bulk of the form, and then there's just a small bit of
proprietary code underneath.

These five views now have TODO comments to explore later. It would
be great to eliminate all of the edge cases and have everything
using the shared view. I can't afford to spend any more time on
these edge cases at present.
  • Loading branch information
ChrisBAshton committed Dec 31, 2024
1 parent 8ef8f49 commit ab92846
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<%= f.url_field :continuation_link, class: 'form-control' %>
<% end %>
<%= render layout: "shared/form_group", locals: { f: f, field: :will_continue_on, label: 'Will continue' } do %>
<% # TODO: this field is the reason why we can't use the shared form yet %>
<%= f.text_field :will_continue_on, class: 'form-control' %>
<% end %>
<%= render layout: "shared/form_group", locals: { f: f, field: :types_of_support, label: 'Types of support offered' } do %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<%= render "shared/form_group", f: f, field: :sifting_status do %>
<%= f.select :sifting_status, facet_options(f, :sifting_status), {}, { class: "form-control" } %>
<% end %>
<% # TODO: this bit of logic prevents us moving to the shared view %>
<% withdrawn_date_display = f.object.withdrawn_sifting_status? ? "block" : "none" %>
<div class="withdrawn-date-wrapper" style="display:<%= withdrawn_date_display %>">
<%= render "shared/date_fields", f: f, field: :withdrawn_date, format: :statutory_instrument %>
Expand All @@ -21,6 +22,8 @@
}
%>
<% end %>

<% # TODO: find a way of making organisation management schema-driven %>
<%= render "shared/form_group", f: f, field: :primary_publishing_organisation, label: "Publishing organisation" do %>
<%= f.select :primary_publishing_organisation,
organisations_options,
Expand All @@ -47,6 +50,8 @@
}
%>
<% end %>

<% # TODO: this bit of JS prevents us moving to the shared view %>
<% content_for :document_ready do %>
var $withdrawnDateEl = $(".withdrawn-date-wrapper");
var $withdrawnDateFields = $("input[id^='statutory_instrument_withdrawn_date']");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,43 +1,7 @@
<%= render layout: "shared/form_group", locals: { f: f, field: :category } do %>
<%= f.select :flood_and_coastal_erosion_category,
f.object.facet_options(:flood_and_coastal_erosion_category),
{},
{ class: "form-control" }
%>
<% end %>

<%= render layout: "shared/date_fields", locals: { f: f, field: :date_of_start, format: :flood_and_coastal_erosion_risk_management_research_report } do %>
<% end %>

<%= render layout: "shared/date_fields", locals: { f: f, field: :date_of_completion, format: :flood_and_coastal_erosion_risk_management_research_report } do %>
<% end %>

<%= render layout: "shared/form_group", locals: { f: f, field: :project_code } do %>
<%= f.text_field :project_code, class: "form-control" %>
<% end %>

<%= render layout: "shared/form_group", locals: { f: f, field: :project_status } do %>
<%= f.select :project_status,
f.object.facet_options(:project_status),
{},
{ class: "form-control" }
%>
<% end %>

<%= render layout: "shared/form_group", locals: { f: f, field: :topics } do %>
<%= f.select :topics,
f.object.facet_options(:topics),
{},
{
class: "select2 form-control",
multiple: true,
data: {
placeholder: "Select topics"
}
}
%>
<%= render layout: "shared/specialist_document_form", locals: { f: f } do %>
<% end %>

<% # TODO: find a way of making organisation management schema-driven %>
<%= render "shared/form_group", f: f, field: :primary_publishing_organisation, label: "Publishing organisation" do %>
<%= f.select :primary_publishing_organisation,
organisations_options,
Expand All @@ -51,7 +15,6 @@
}
%>
<% end %>

<%= render "shared/form_group", f: f, field: :organisations, label: "Other associated organisations" do %>
<%= f.select :organisations,
organisations_options,
Expand Down
3 changes: 3 additions & 0 deletions app/views/metadata_fields/_licences.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
%>
<% end %>

<% # TODO: find a way of making organisation management schema-driven %>
<%= render "shared/form_group", f: f, field: :primary_publishing_organisation, label: "Publishing organisation" do %>
<%= f.select :primary_publishing_organisation,
organisations_options,
Expand Down Expand Up @@ -55,6 +56,8 @@
%>
<% end %>

<% # TODO: rendering a subset of the facet fields above (and a subset below) the proprietary code in this file %>
<% # makes it difficult to use the shared view %>
<div class="additional-field-context-section">
<h2>How users apply</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<% end %>
<%= render layout: "shared/date_fields", locals: { f: f, field: :first_published_at, format: :research_for_development_output } do %>
<% end %>
<% # TODO: this field prevents us moving to the shared view. It uses this weird 'ResearchForDevelopmentOutputsHelper' helper %>
<%= render layout: 'shared/form_group', locals: { f: f, field: :review_status, label: 'Review status' } do %>
<%= f.select :review_status, review_status_options,
{},
Expand Down

0 comments on commit ab92846

Please sign in to comment.