Skip to content

Commit e4d7227

Browse files
committed
Query can_be_associated_with_topical_events before rendering form
Currently, the topical event form rendering is only gate-kept around the temporary 'Flipflop' feature flag whilst config-driven topical events are under development. And this flag only controls the 'topical event documents' association rendering, rather than the legacy 'topical event' association. If/when we come to migrate topical events, we'll need to consolidate the two controller test helper methods: - should_allow_association_with_topical_event_documents_when_configurable_document_types_enabled - should_allow_association_with_topical_events ...which should be made easier by making use of the can_be_associated_with_topical_events conditional.
1 parent 1250f4b commit e4d7227

File tree

1 file changed

+37
-34
lines changed

1 file changed

+37
-34
lines changed
Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,38 @@
1-
<% cache_if edition.topical_event_ids.empty?, "#{taggable_topical_events_cache_digest}-design-system" do %>
2-
<%= render "govuk_publishing_components/components/select_with_search", {
3-
id: "edition_topical_event_ids",
4-
name: "edition[topical_event_ids][]",
5-
include_blank: true,
6-
label: "Topical events",
7-
heading_size: "m",
8-
options: TopicalEvent.order(:name).map do |topical_event|
9-
{
10-
text: topical_event.name,
11-
value: topical_event.id,
12-
selected: edition.topical_event_ids.include?(topical_event.id),
13-
}
14-
end,
15-
multiple: true,
16-
} %>
17-
<% end %>
18-
<% if Flipflop.enabled?(:configurable_document_types) %>
19-
<%= render "govuk_publishing_components/components/select_with_search", {
20-
id: "edition_topical_event_document_ids",
21-
name: "edition[topical_event_document_ids][]",
22-
include_blank: true,
23-
label: "Topical events (experimental)",
24-
hint: "Topical events created via the documents menu will appear here",
25-
heading_size: "m",
26-
options: StandardEdition.where(configurable_document_type: "topical_event").order(:title).map do |topical_event|
27-
{
28-
text: topical_event.title,
29-
value: topical_event.document_id,
30-
selected: edition.topical_event_document_ids.include?(topical_event.document_id),
31-
}
32-
end,
33-
multiple: true,
34-
} %>
1+
<% if edition.can_be_associated_with_topical_events? %>
2+
<h2 class="govuk-heading-m">Topical events</h2>
3+
<% cache_if edition.topical_event_ids.empty?, "#{taggable_topical_events_cache_digest}-design-system" do %>
4+
<%= render "govuk_publishing_components/components/select_with_search", {
5+
id: "edition_topical_event_ids",
6+
name: "edition[topical_event_ids][]",
7+
include_blank: true,
8+
label: "Topical events",
9+
heading_size: "m",
10+
options: TopicalEvent.order(:name).map do |topical_event|
11+
{
12+
text: topical_event.name,
13+
value: topical_event.id,
14+
selected: edition.topical_event_ids.include?(topical_event.id),
15+
}
16+
end,
17+
multiple: true,
18+
} %>
19+
<% end %>
20+
<% if Flipflop.enabled?(:configurable_document_types) %>
21+
<%= render "govuk_publishing_components/components/select_with_search", {
22+
id: "edition_topical_event_document_ids",
23+
name: "edition[topical_event_document_ids][]",
24+
include_blank: true,
25+
label: "Topical events (experimental)",
26+
hint: "Topical events created via the documents menu will appear here",
27+
heading_size: "m",
28+
options: StandardEdition.where(configurable_document_type: "topical_event").order(:title).map do |topical_event|
29+
{
30+
text: topical_event.title,
31+
value: topical_event.document_id,
32+
selected: edition.topical_event_document_ids.include?(topical_event.document_id),
33+
}
34+
end,
35+
multiple: true,
36+
} %>
37+
<% end %>
3538
<% end %>

0 commit comments

Comments
 (0)