Browse Source

WIP

pull/469/head
Dushan Despotovic 3 years ago committed by Kat
parent
commit
13632db97b
  1. 12
      app/controllers/form_controller.rb
  2. 10
      app/frontend/application.js
  3. 6
      app/frontend/styles/application.scss
  4. 4
      app/views/case_logs/_tasklist.html.erb
  5. 33
      app/views/form/review.html.erb
  6. 51
      config/forms/2021_2022.json
  7. 1
      config/routes.rb
  8. 2
      db/schema.rb
  9. 1
      package.json
  10. 34
      spec/features/form/review_page_spec.rb
  11. 7
      spec/features/form/tasklist_page_spec.rb
  12. 2
      webpack.config.js
  13. 22
      yarn.lock

12
app/controllers/form_controller.rb

@ -1,7 +1,7 @@
class FormController < ApplicationController
before_action :authenticate_user!
before_action :find_resource, only: [:submit_form]
before_action :find_resource_by_named_id, except: [:submit_form]
before_action :find_resource, only: [:submit_form, :review]
before_action :find_resource_by_named_id, except: [:submit_form, :review]
def submit_form
if @case_log
@ -37,6 +37,14 @@ class FormController < ApplicationController
end
end
def review
if @case_log
render "form/review"
else
render_not_found
end
end
FormHandler.instance.forms.each do |_key, form|
form.pages.map do |page|
define_method(page.id) do |_errors = {}|

10
app/frontend/application.js

@ -12,9 +12,15 @@ import "custom-event-polyfill"
import "intersection-observer"
//
// Import GOV.UK Frontend
import GOVUKFrontend from 'govuk-frontend'
// Import GOV.UK Prototype Components
import GOVUKPrototypeComponents from 'govuk-prototype-components'
require.context("govuk-frontend/govuk/assets")
import { initAll } from "govuk-frontend"
import "./styles/application.scss"
import "./controllers"
initAll()
GOVUKFrontend.initAll()
GOVUKPrototypeComponents.initAll()

6
app/frontend/styles/application.scss

@ -10,7 +10,11 @@ $govuk-font-url-function: frontend-font-url;
$govuk-image-url-function: frontend-image-url;
$govuk-global-styles: true;
@import "~govuk-frontend/govuk/all";
// Import GOV.UK Frontend
@import "govuk-frontend/govuk/all";
// Import GOV.UK Prototype Components
// @import "govuk-prototype-components/x-govuk/all";
@import "accessible-autocomplete";
@import "button";

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

@ -24,3 +24,7 @@
</li>
<% end %>
</ol>
<h2 class="govuk-heading-m">Review and submit</h2>
<p>Review your answers and submit this log to the Department of Levelling Up, Housing & Communities.</p>
<%= govuk_button_link_to 'Review lettings log', "/logs/#{@case_log.id}/review" %>

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

@ -0,0 +1,33 @@
<% content_for :title, "Review lettings log" %>
<% content_for :breadcrumbs, govuk_breadcrumbs(breadcrumbs: {
"Logs" => "/logs",
"Log #{@case_log.id.to_s}" => "/logs/" + @case_log.id.to_s,
"Review lettings log" => ""
}) %>
<%= turbo_frame_tag "case_log_form", target: "_top" do %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds-from-desktop">
<h1 class="govuk-heading-xl">
<%= content_for(:title) %>
</h1>
<% @case_log.form.sections.map do |section| %>
<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">
<h3 class="x-govuk-summary-card__title"><%= subsection.label %></h3>
</div>
<div class="x-govuk-summary-card__body">
<dl class="govuk-summary-list">
<% subsection.applicable_questions(@case_log).each do |question| %>
<%= render partial: 'form/check_answers_table', locals: { question: question, case_log: @case_log } %>
<% end %>
</dl>
</div>
</div>
<% end %>
<% end %>
</div>
</div>
<% end %>

51
config/forms/2021_2022.json

@ -1110,6 +1110,21 @@
}
],
"pages": {
"declaration": {
"header": "",
"description": "",
"questions": {
"declaration": {
"check_answer_label": "",
"header": "Submit this lettings log ",
"hint_text": "",
"type": "checkbox",
"answer_options": {
"declaration": "The tenant has seen the Department for Levelling Up, Housing & Communities (DLUHC) privacy notice"
}
}
}
},
"household_members": {
"header": "",
"description": "",
@ -5690,42 +5705,6 @@
}
}
}
},
"submission": {
"label": "Submission",
"subsections": {
"declaration": {
"label": "Declaration",
"depends_on": [
{
"setup": "completed",
"household_characteristics": "completed",
"household_situation": "completed",
"household_needs": "completed",
"tenancy_information": "completed",
"property_information": "completed",
"income_and_benefits": "completed"
}
],
"pages": {
"declaration": {
"header": "",
"description": "",
"questions": {
"declaration": {
"check_answer_label": "",
"header": "Submit this lettings log ",
"hint_text": "",
"type": "checkbox",
"answer_options": {
"declaration": "The tenant has seen the Department for Levelling Up, Housing & Communities (DLUHC) privacy notice"
}
}
}
}
}
}
}
}
}
}

1
config/routes.rb

@ -77,6 +77,7 @@ Rails.application.routes.draw do
member do
post "form", to: "form#submit_form"
get "review", to: "form#review"
end
FormHandler.instance.forms.each do |_key, form|

2
db/schema.rb

@ -321,9 +321,9 @@ ActiveRecord::Schema[7.0].define(version: 202202071123100) do
t.integer "failed_attempts", default: 0
t.string "unlock_token"
t.datetime "locked_at", precision: nil
t.string "phone"
t.boolean "is_dpo", default: false
t.boolean "is_key_contact", default: false
t.string "phone"
t.integer "second_factor_attempts_count", default: 0
t.string "encrypted_otp_secret_key"
t.string "encrypted_otp_secret_key_iv"

1
package.json

@ -23,6 +23,7 @@
"custom-event-polyfill": "^1.0.7",
"file-loader": "^6.2.0",
"govuk-frontend": "^4.0.1",
"govuk-prototype-components": "^0.1.5",
"html5shiv": "^3.7.3",
"intersection-observer": "^0.12.0",
"mini-css-extract-plugin": "^2.6.0",

34
spec/features/form/review_page_spec.rb

@ -0,0 +1,34 @@
require "rails_helper"
require_relative "helpers"
RSpec.describe "Form Review Page" do
include Helpers
let(:user) { FactoryBot.create(:user) }
let(:completed_unsubmitted_case_log) do
FactoryBot.create(
:case_log,
:completed,
status: 1,
owning_organisation: user.organisation,
managing_organisation: user.organisation,
)
end
before do
sign_in user
end
context "when the user wishes to review their case log" do
it "the review page can be visited by URL" do
visit("/logs/#{completed_unsubmitted_case_log.id}/review")
expect(page).to have_content("Review lettings log")
end
it "the review page allows the user to submit a completed case log" do
visit("/logs/#{completed_unsubmitted_case_log.id}/review")
click_button("Submit lettings log")
expect(page).to have_content("Success")
expect(page).to have_content("Log #{completed_unsubmitted_case_log.id} has been submitted")
end
end
end

7
spec/features/form/tasklist_page_spec.rb

@ -42,4 +42,11 @@ RSpec.describe "Task List" do
visit("/logs/#{empty_case_log.id}")
expect(page).to have_link("Skip to next incomplete section", href: /#household-characteristics/)
end
it "has a review section which has a button that allows the data inputter to review the case log" do
visit("/logs/#{case_log.id}")
expect(page).to have_content("Review your answers and submit this log to the Department of Levelling Up, Housing & Communities.")
click_link(text: "Review lettings log")
expect(page).to have_current_path("/logs/#{case_log.id}/review")
end
end

2
webpack.config.js

@ -43,7 +43,7 @@ module.exports = {
],
},
resolve: {
modules: ['node_modules', 'node_modules/govuk-frontend/govuk']
modules: ['node_modules', 'node_modules/govuk-frontend/govuk', 'node_modules/govuk-prototype-components/x-govuk']
},
output: {
filename: "[name].js",

22
yarn.lock

@ -1156,7 +1156,7 @@
resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d"
integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==
accessible-autocomplete@^2.0.3:
accessible-autocomplete@^2.0.3, accessible-autocomplete@^2.0.4:
version "2.0.4"
resolved "https://registry.yarnpkg.com/accessible-autocomplete/-/accessible-autocomplete-2.0.4.tgz#e295256c8d268b97c5ab456a1cb084b553ed3eb0"
integrity sha512-2p0txrSpvs5wXFUeQJHMheDPTZVSEmiUHWlEPb7vJnv2Dd1xPfoLnBQQMfNbTSit2pL/9sSQYESuD2Yyohd4Yw==
@ -1639,6 +1639,11 @@ events@^3.2.0:
resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400"
integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==
eventslibjs@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/eventslibjs/-/eventslibjs-1.2.0.tgz#5d242b1d71d7376b999611448e91b7947d8cb9d0"
integrity sha512-nui7FHXHeeZjWkQ1dZ4R3RchkT+164+y1/puiOY1Zc3CPU9W8XzAzdhqvuVQ4EJt7F/W94O5U26/oVFpBOPY3w==
execa@^5.0.0:
version "5.1.1"
resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd"
@ -1789,6 +1794,16 @@ govuk-frontend@^4.0.1:
resolved "https://registry.yarnpkg.com/govuk-frontend/-/govuk-frontend-4.0.1.tgz#bceff58ecb399272cba32bd2b357fe16198e3249"
integrity sha512-X+B88mqYHoxAz0ID87Uxo3oHqdKBRnNHd3Cz8+u8nvQUAsrEzROFLK+t7sAu7e+fKqCCrJyIgx6Cmr6dIGnohQ==
govuk-prototype-components@^0.1.5:
version "0.1.5"
resolved "https://registry.yarnpkg.com/govuk-prototype-components/-/govuk-prototype-components-0.1.5.tgz#e420c3200660fc6ff0f4df66474e8796ec446d37"
integrity sha512-ssUW5qcxnyJ9B+TRafRjLdeMmAK67cC5TE5TzkVhoMDzdYTQWzfp+FtFg2SFM0dO9pAc1npMVxZ8rUxEA174IQ==
dependencies:
accessible-autocomplete "^2.0.4"
eventslibjs "^1.2.0"
govuk-frontend "^4.0.1"
lodash "^4.17.21"
graceful-fs@^4.1.2, graceful-fs@^4.2.4, graceful-fs@^4.2.9:
version "4.2.10"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c"
@ -2036,6 +2051,11 @@ lru-cache@^7.4.0:
version "7.8.1"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-7.8.1.tgz#68ee3f4807a57d2ba185b7fd90827d5c21ce82bb"
integrity sha512-E1v547OCgJvbvevfjgK9sNKIVXO96NnsTsFPBlg4ZxjhsJSODoH9lk8Bm0OxvHNm6Vm5Yqkl/1fErDxhYL8Skg==
lodash@^4.17.21:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
make-dir@^3.0.2, make-dir@^3.1.0:
version "3.1.0"

Loading…
Cancel
Save