Browse Source

WIP

pull/469/head
Dushan Despotovic 3 years ago
parent
commit
cc35a483e5
  1. 9
      app/controllers/form_controller.rb
  2. 1
      app/models/form/question.rb
  3. 12
      app/views/case_logs/_success.html.erb
  4. 4
      app/views/case_logs/index.html.erb
  5. 8
      app/views/form/review.html.erb
  6. 6
      config/forms/2021_2022.json

9
app/controllers/form_controller.rb

@ -5,6 +5,10 @@ class FormController < ApplicationController
def submit_form
if @case_log
if is_referrer_review?
@case_log.update!(@case_log.attributes)
redirect_to(send(case_logs_path, @case_log))
else
@page = @case_log.form.get_page(params[:case_log][:page])
responses_for_page = responses_for_page(@page)
if @case_log.update(responses_for_page)
@ -110,4 +114,9 @@ private
referrer = request.headers["HTTP_REFERER"].presence || ""
referrer.present? && CGI.parse(referrer.split("?")[-1]).present? && CGI.parse(referrer.split("?")[-1])["referrer"][0] == "check_answers"
end
def is_referrer_review?
referrer = request.headers["HTTP_REFERER"].presence || ""
referrer.present? && referrer.split("/")[-1].present? && referrer.split("/")[-1] == "review"
end
end

1
app/models/form/question.rb

@ -168,6 +168,7 @@ private
def checkbox_answer_label(case_log)
answer = []
return "Yes" if id == "declaration" && value_is_yes?(case_log["declaration"])
answer_options.each { |key, options| value_is_yes?(case_log[key]) ? answer << options["value"] : nil }
answer.join(", ")
end

12
app/views/case_logs/_success.html.erb

@ -0,0 +1,12 @@
<div class="govuk-notification-banner govuk-notification-banner--success" role="alert" aria-labelledby="govuk-notification-banner-title" data-module="govuk-notification-banner">
<div class="govuk-notification-banner__header">
<h2 class="govuk-notification-banner__title" id="govuk-notification-banner-title">
Success
</h2>
</div>
<div class="govuk-notification-banner__content">
<h3 class="govuk-notification-banner__heading">
Log <%= case_log.id %> has been submitted
</h3>
</div>
</div>

4
app/views/case_logs/index.html.erb

@ -1,5 +1,9 @@
<% content_for :title, "Logs" %>
<% if @case_log.present? %>
<%= render partial: "success", locals: { case_log: @case_log } %>
<% end %>
<h1 class="govuk-heading-l">
<%= content_for(:title) %>
</h1>

8
app/views/form/review.html.erb

@ -12,7 +12,7 @@
<%= content_for(:title) %>
</h1>
<% @case_log.form.sections.map do |section| %>
<h2 class="govuk-heading-m"><%= section.label %></h2>
<h2 class="govuk-heading-m"><%= section.label %></h2>
<% section.subsections.map do |subsection| %>
<div class="x-govuk-summary-card govuk-!-margin-bottom-6">
<div class="x-govuk-summary-card__header">
@ -28,6 +28,12 @@
</div>
<% end %>
<% end %>
<div class="govuk-inset-text">
You can submit changes to this log until the close of the current collection year, 31 March 2022.
</div>
<%= form_with model: @case_log, url: form_case_log_path(@case_log), method: "post" do |f| %>
<%= f.govuk_submit "Submit lettings log", accesskey: "s" %>
<% end %>
</div>
</div>
<% end %>

6
config/forms/2021_2022.json

@ -1115,9 +1115,9 @@
"description": "",
"questions": {
"declaration": {
"check_answer_label": "",
"header": "Submit this lettings log ",
"hint_text": "",
"check_answer_label": "Tenant has seen the privacy notice",
"header": "Department for Levelling Up, Housing & Communities privacy notice ",
"hint_text": "Make sure the tenant has seen the Department for Levelling Up, Housing & Communities (DLUHC) privacy notice before submitting this log",
"type": "checkbox",
"answer_options": {
"declaration": "The tenant has seen the Department for Levelling Up, Housing & Communities (DLUHC) privacy notice"

Loading…
Cancel
Save