Browse Source

Move privacy notice add final review (#469)

* WIP

* Unpleasant but works

* Alias is maybe better?

* WIP

* remove unneeded partial

* error and success when submitting

* add request specs for review page

* delete unneeded feature spec

* WIP

* Unpleasant but works

* Alias is maybe better?

* WIP

* remove unneeded partial

* error and success when submitting

* add request specs for review page

* delete unneeded feature spec

* 🤏fixes

* display when log is completed

Co-authored-by: baarkerlounger <db@slothlife.xyz>
Co-authored-by: Kat <katrina@madetech.com>
Co-authored-by: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com>
pull/488/head
Dushan 3 years ago committed by GitHub
parent
commit
2e93dd5e2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      app/controllers/form_controller.rb
  2. 6
      app/frontend/application.js
  3. 6
      app/frontend/controllers/govukfrontend_controller.js
  4. 3
      app/frontend/styles/application.scss
  5. 2
      app/models/form/question.rb
  6. 2
      app/views/case_logs/_tasklist.html.erb
  7. 5
      app/views/case_logs/edit.html.erb
  8. 34
      app/views/form/review.html.erb
  9. 51
      config/forms/2021_2022.json
  10. 1
      config/routes.rb
  11. 1
      package.json
  12. 15
      spec/features/form/tasklist_page_spec.rb
  13. 25
      spec/requests/form_controller_spec.rb
  14. 4
      webpack.config.js
  15. 32
      yarn.lock

12
app/controllers/form_controller.rb

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

6
app/frontend/application.js

@ -13,8 +13,10 @@ import "intersection-observer"
// //
require.context("govuk-frontend/govuk/assets") require.context("govuk-frontend/govuk/assets")
import { initAll } from "govuk-frontend" import GOVUKFrontend from "govuk-frontend"
import GOVUKPrototypeComponents from "govuk-prototype-components"
import "./styles/application.scss" import "./styles/application.scss"
import "./controllers" import "./controllers"
initAll() GOVUKFrontend.initAll()
GOVUKPrototypeComponents.initAll()

6
app/frontend/controllers/govukfrontend_controller.js

@ -1,8 +1,10 @@
import { initAll } from "govuk-frontend"; import GOVUKFrontend from "govuk-frontend";
import GOVUKPrototypeComponents from "govuk-prototype-components"
import { Controller } from "@hotwired/stimulus"; import { Controller } from "@hotwired/stimulus";
export default class extends Controller { export default class extends Controller {
connect() { connect() {
initAll() GOVUKFrontend.initAll()
GOVUKPrototypeComponents.initAll()
} }
} }

3
app/frontend/styles/application.scss

@ -11,7 +11,8 @@ $govuk-image-url-function: frontend-image-url;
$govuk-global-styles: true; $govuk-global-styles: true;
$govuk-new-link-styles: true; $govuk-new-link-styles: true;
@import "~govuk-frontend/govuk/all"; @import "govuk-frontend-styles";
@import "govuk-prototype-styles";
@import "accessible-autocomplete"; @import "accessible-autocomplete";
@import "button"; @import "button";

2
app/models/form/question.rb

@ -174,6 +174,8 @@ private
def checkbox_answer_label(case_log) def checkbox_answer_label(case_log)
answer = [] 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_options.each { |key, options| value_is_yes?(case_log[key]) ? answer << options["value"] : nil }
answer.join(", ") answer.join(", ")
end end

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

@ -23,4 +23,4 @@
</ul> </ul>
</li> </li>
<% end %> <% end %>
</ol> </ol>

5
app/views/case_logs/edit.html.erb

@ -24,6 +24,11 @@
</p> </p>
<% elsif @case_log.status == "not_started" %> <% elsif @case_log.status == "not_started" %>
<p class="govuk-body">This log has not been started.</p> <p class="govuk-body">This log has not been started.</p>
<% elsif @case_log.status == "completed" %>
<strong class="govuk-tag">Completed</strong>
<p class="govuk-body">
You can <a class="govuk-link" href="<%="/logs/#{@case_log.id}/review" %>">review and make changes to this log</a> up to 3 months after the end of the current collection year, which closes on 31 March <%= @case_log.collection_start_year.present? ? @case_log.collection_start_year + 1 : "" %>.
</p>
<% end %> <% end %>
<%= render "tasklist" %> <%= render "tasklist" %>
</div> </div>

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

@ -0,0 +1,34 @@
<% 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" => ""
}) %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds-from-desktop">
<h1 class="govuk-heading-xl">
<%= content_for(:title) %>
</h1>
<p class="govuk-body">
You can review and make changes to this log up to 3 months after the end of the current collection year, which closes on 31 March <%= @case_log.collection_start_year.present? ? @case_log.collection_start_year + 1 : "" %>.
</p>
<% @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>

51
config/forms/2021_2022.json

@ -1110,6 +1110,21 @@
} }
], ],
"pages": { "pages": {
"declaration": {
"header": "",
"description": "",
"questions": {
"declaration": {
"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"
}
}
}
},
"household_members": { "household_members": {
"header": "", "header": "",
"description": "", "description": "",
@ -5684,42 +5699,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 member do
post "form", to: "form#submit_form" post "form", to: "form#submit_form"
get "review", to: "form#review"
end end
FormHandler.instance.forms.each do |_key, form| FormHandler.instance.forms.each do |_key, form|

1
package.json

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

15
spec/features/form/tasklist_page_spec.rb

@ -12,6 +12,14 @@ RSpec.describe "Task List" do
managing_organisation: user.organisation, managing_organisation: user.organisation,
) )
end end
let(:completed_case_log) do
FactoryBot.create(
:case_log,
:completed,
owning_organisation: user.organisation,
managing_organisation: user.organisation,
)
end
let(:empty_case_log) do let(:empty_case_log) do
FactoryBot.create( FactoryBot.create(
:case_log, :case_log,
@ -42,4 +50,11 @@ RSpec.describe "Task List" do
visit("/logs/#{empty_case_log.id}") visit("/logs/#{empty_case_log.id}")
expect(page).to have_link("Skip to next incomplete section", href: /#household-characteristics/) expect(page).to have_link("Skip to next incomplete section", href: /#household-characteristics/)
end end
it "has a review section which has a button that allows the data inputter to review the case log" do
visit("/logs/#{completed_case_log.id}")
expect(page).to have_content("review and make changes to this log")
click_link(text: "review and make changes to this log")
expect(page).to have_current_path("/logs/#{completed_case_log.id}/review")
end
end end

25
spec/requests/form_controller_spec.rb

@ -18,6 +18,24 @@ RSpec.describe FormController, type: :request do
managing_organisation: other_organisation, managing_organisation: other_organisation,
) )
end end
let(:setup_complete_case_log) do
FactoryBot.create(
:case_log,
:about_completed,
status: 1,
startdate: Time.zone.local(2021, 10, 10),
owning_organisation: organisation,
managing_organisation: organisation,
)
end
let(:completed_case_log) do
FactoryBot.create(
:case_log,
:completed,
owning_organisation: organisation,
managing_organisation: organisation,
)
end
let(:headers) { { "Accept" => "text/html" } } let(:headers) { { "Accept" => "text/html" } }
context "when a user is not signed in" do context "when a user is not signed in" do
@ -97,6 +115,13 @@ RSpec.describe FormController, type: :request do
expect(response).to redirect_to("/logs/#{case_log.id}") expect(response).to redirect_to("/logs/#{case_log.id}")
end end
end end
context "when visiting the review page" do
it "renders the review page for the case log" do
get "/logs/#{setup_complete_case_log.id}/review", headers: headers, params: {}
expect(response.body).to match("Review lettings log")
end
end
end end
describe "Submit Form" do describe "Submit Form" do

4
webpack.config.js

@ -43,6 +43,10 @@ module.exports = {
], ],
}, },
resolve: { resolve: {
alias: {
'govuk-frontend-styles': path.resolve(__dirname, 'node_modules/govuk-frontend/govuk/all.scss'),
'govuk-prototype-styles': path.resolve(__dirname, 'node_modules/govuk-prototype-components/x-govuk/all.scss')
},
modules: ['node_modules', 'node_modules/govuk-frontend/govuk'] modules: ['node_modules', 'node_modules/govuk-frontend/govuk']
}, },
output: { output: {

32
yarn.lock

@ -1156,7 +1156,7 @@
resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d" resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d"
integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ== 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" version "2.0.4"
resolved "https://registry.yarnpkg.com/accessible-autocomplete/-/accessible-autocomplete-2.0.4.tgz#e295256c8d268b97c5ab456a1cb084b553ed3eb0" resolved "https://registry.yarnpkg.com/accessible-autocomplete/-/accessible-autocomplete-2.0.4.tgz#e295256c8d268b97c5ab456a1cb084b553ed3eb0"
integrity sha512-2p0txrSpvs5wXFUeQJHMheDPTZVSEmiUHWlEPb7vJnv2Dd1xPfoLnBQQMfNbTSit2pL/9sSQYESuD2Yyohd4Yw== integrity sha512-2p0txrSpvs5wXFUeQJHMheDPTZVSEmiUHWlEPb7vJnv2Dd1xPfoLnBQQMfNbTSit2pL/9sSQYESuD2Yyohd4Yw==
@ -1640,6 +1640,11 @@ events@^3.2.0:
resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400"
integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== 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: execa@^5.0.0:
version "5.1.1" version "5.1.1"
resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd" resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd"
@ -1790,6 +1795,16 @@ govuk-frontend@^4.0.1:
resolved "https://registry.yarnpkg.com/govuk-frontend/-/govuk-frontend-4.0.1.tgz#bceff58ecb399272cba32bd2b357fe16198e3249" resolved "https://registry.yarnpkg.com/govuk-frontend/-/govuk-frontend-4.0.1.tgz#bceff58ecb399272cba32bd2b357fe16198e3249"
integrity sha512-X+B88mqYHoxAz0ID87Uxo3oHqdKBRnNHd3Cz8+u8nvQUAsrEzROFLK+t7sAu7e+fKqCCrJyIgx6Cmr6dIGnohQ== 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: graceful-fs@^4.1.2, graceful-fs@^4.2.4, graceful-fs@^4.2.9:
version "4.2.10" version "4.2.10"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c"
@ -2040,12 +2055,15 @@ lodash.debounce@^4.0.8:
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168= integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168=
lru-cache@^6.0.0: lru-cache@^7.4.0:
version "6.0.0" version "7.8.1"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-7.8.1.tgz#68ee3f4807a57d2ba185b7fd90827d5c21ce82bb"
integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== integrity sha512-E1v547OCgJvbvevfjgK9sNKIVXO96NnsTsFPBlg4ZxjhsJSODoH9lk8Bm0OxvHNm6Vm5Yqkl/1fErDxhYL8Skg==
dependencies:
yallist "^4.0.0" 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: make-dir@^3.0.2, make-dir@^3.1.0:
version "3.1.0" version "3.1.0"

Loading…
Cancel
Save