Browse Source

Reload the GOV UK frontend JS

pull/235/head
Stéphane Meny 3 years ago committed by baarkerlounger
parent
commit
916431a272
  1. 14
      app/models/form/page.rb
  2. 4
      app/views/form/page.html.erb
  3. 8
      app/webpacker/controllers/govukfrontend_controller.js

14
app/models/form/page.rb

@ -28,13 +28,13 @@ class Form::Page
end
# We expect to render only one radio question (with conditionals)
def questions_to_render
if questions.first.type == "radio"
[questions.first]
else
questions
end
end
# def questions_to_render
# if questions.first.type == "radio"
# [questions.first]
# else
# questions
# end
# end
private

4
app/views/form/page.html.erb

@ -11,6 +11,8 @@
) %>
<% end %>
<div data-controller="govukfrontend"></div>
<%= turbo_frame_tag "case_log_form", target: "_top" do %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds-from-desktop">
@ -29,7 +31,7 @@
<%= form_with model: @case_log, url: form_case_log_path(@case_log), method: "post" do |f| %>
<%= f.govuk_error_summary %>
<% @page.questions_to_render.map do |question| %>
<% @page.questions.map do |question| %>
<div id=<%= question.id + "_div " %> >
<% if question.read_only? %>
<hr class="govuk-section-break govuk-section-break--visible govuk-section-break--m">

8
app/webpacker/controllers/govukfrontend_controller.js

@ -0,0 +1,8 @@
import {initAll} from "govuk-frontend";
import {Controller} from "@hotwired/stimulus";
export default class extends Controller {
connect() {
initAll()
}
}
Loading…
Cancel
Save