From b5ba641e3c972f874d6e5e169a182ad95ab08f80 Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 23 Nov 2021 08:04:21 +0000 Subject: [PATCH] WIP --- Gemfile.lock | 444 ------------------ app/controllers/case_logs_controller.rb | 11 +- app/javascript/packs/application.js | 2 + app/javascript/stylesheets/print.scss | 42 ++ .../form/print/_checkbox_question.html.erb | 11 + app/views/form/print/_date_question.html.erb | 8 + .../form/print/_numeric_question.html.erb | 8 + app/views/form/print/_radio_question.html.erb | 23 + .../form/print/_select_question.html.erb | 11 + app/views/form/print/_text_question.html.erb | 7 + app/views/layouts/application.html.erb | 2 + config/forms/2021_2022.json | 2 + config/routes.rb | 1 + .../users/passwords_controller_spec.rb | 2 - 14 files changed, 125 insertions(+), 449 deletions(-) delete mode 100644 Gemfile.lock create mode 100644 app/javascript/stylesheets/print.scss create mode 100644 app/views/form/print/_checkbox_question.html.erb create mode 100644 app/views/form/print/_date_question.html.erb create mode 100644 app/views/form/print/_numeric_question.html.erb create mode 100644 app/views/form/print/_radio_question.html.erb create mode 100644 app/views/form/print/_select_question.html.erb create mode 100644 app/views/form/print/_text_question.html.erb diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 322fcc403..000000000 --- a/Gemfile.lock +++ /dev/null @@ -1,444 +0,0 @@ -GIT - remote: https://github.com/rspec/rspec-core.git - revision: e36aa2a9ebe68acee3ce05190fc2124947b45925 - branch: main - specs: - rspec-core (3.11.0.pre) - rspec-support (= 3.11.0.pre) - -GIT - remote: https://github.com/rspec/rspec-expectations.git - revision: dba67987c63f551d1bf0f7877f069fa8b72d0461 - branch: main - specs: - rspec-expectations (3.11.0.pre) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (= 3.11.0.pre) - -GIT - remote: https://github.com/rspec/rspec-mocks.git - revision: 17cf86ab61544b93232c4e9ca9784ab212dccbf6 - branch: main - specs: - rspec-mocks (3.11.0.pre) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (= 3.11.0.pre) - -GIT - remote: https://github.com/rspec/rspec-rails.git - revision: d3e7b85877fcbcec63f8a76434d8750e7f3b7aef - branch: main - specs: - rspec-rails (5.1.0.pre) - actionpack (>= 5.2) - activesupport (>= 5.2) - railties (>= 5.2) - rspec-core (= 3.11.0.pre) - rspec-expectations (= 3.11.0.pre) - rspec-mocks (= 3.11.0.pre) - rspec-support (= 3.11.0.pre) - -GIT - remote: https://github.com/rspec/rspec-support.git - revision: 9499cb622f9feef43a53f357809f9e656e7cb6de - branch: main - specs: - rspec-support (3.11.0.pre) - -GEM - remote: https://rubygems.org/ - specs: - actioncable (6.1.4.1) - actionpack (= 6.1.4.1) - activesupport (= 6.1.4.1) - nio4r (~> 2.0) - websocket-driver (>= 0.6.1) - actionmailbox (6.1.4.1) - actionpack (= 6.1.4.1) - activejob (= 6.1.4.1) - activerecord (= 6.1.4.1) - activestorage (= 6.1.4.1) - activesupport (= 6.1.4.1) - mail (>= 2.7.1) - actionmailer (6.1.4.1) - actionpack (= 6.1.4.1) - actionview (= 6.1.4.1) - activejob (= 6.1.4.1) - activesupport (= 6.1.4.1) - mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 2.0) - actionpack (6.1.4.1) - actionview (= 6.1.4.1) - activesupport (= 6.1.4.1) - rack (~> 2.0, >= 2.0.9) - rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.4.1) - actionpack (= 6.1.4.1) - activerecord (= 6.1.4.1) - activestorage (= 6.1.4.1) - activesupport (= 6.1.4.1) - nokogiri (>= 1.8.5) - actionview (6.1.4.1) - activesupport (= 6.1.4.1) - builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - activeadmin (2.9.0) - arbre (~> 1.2, >= 1.2.1) - formtastic (>= 3.1, < 5.0) - formtastic_i18n (~> 0.4) - inherited_resources (~> 1.7) - jquery-rails (~> 4.2) - kaminari (~> 1.0, >= 1.2.1) - railties (>= 5.2, < 6.2) - ransack (~> 2.1, >= 2.1.1) - activejob (6.1.4.1) - activesupport (= 6.1.4.1) - globalid (>= 0.3.6) - activemodel (6.1.4.1) - activesupport (= 6.1.4.1) - activerecord (6.1.4.1) - activemodel (= 6.1.4.1) - activesupport (= 6.1.4.1) - activestorage (6.1.4.1) - actionpack (= 6.1.4.1) - activejob (= 6.1.4.1) - activerecord (= 6.1.4.1) - activesupport (= 6.1.4.1) - marcel (~> 1.0.0) - mini_mime (>= 1.1.0) - activesupport (6.1.4.1) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 1.6, < 2) - minitest (>= 5.1) - tzinfo (~> 2.0) - zeitwerk (~> 2.3) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) - arbre (1.4.0) - activesupport (>= 3.0.0, < 6.2) - ruby2_keywords (>= 0.0.2, < 1.0) - ast (2.4.2) - bcrypt (3.1.16) - bindex (0.8.1) - bootsnap (1.9.1) - msgpack (~> 1.0) - builder (3.2.4) - byebug (11.1.3) - capybara (3.36.0) - addressable - matrix - mini_mime (>= 0.1.3) - nokogiri (~> 1.8) - rack (>= 1.6.0) - rack-test (>= 0.6.3) - regexp_parser (>= 1.5, < 3.0) - xpath (~> 3.2) - chartkick (4.1.2) - childprocess (4.1.0) - coderay (1.1.3) - concurrent-ruby (1.1.9) - crass (1.0.6) - database_cleaner-active_record (2.0.1) - activerecord (>= 5.a) - database_cleaner-core (~> 2.0.0) - database_cleaner-core (2.0.1) - deep_merge (1.2.1) - devise (4.8.0) - bcrypt (~> 3.0) - orm_adapter (~> 0.1) - railties (>= 4.1.0) - responders - warden (~> 1.2.3) - diff-lcs (1.4.4) - discard (1.2.0) - activerecord (>= 4.2, < 7) - docile (1.4.0) - dotenv (2.7.6) - dotenv-rails (2.7.6) - dotenv (= 2.7.6) - railties (>= 3.2) - erubi (1.10.0) - factory_bot (6.2.0) - activesupport (>= 5.0.0) - factory_bot_rails (6.2.0) - factory_bot (~> 6.2.0) - railties (>= 5.0.0) - ffi (1.15.4) - formtastic (4.0.0) - actionpack (>= 5.2.0) - formtastic_i18n (0.7.0) - globalid (0.5.2) - activesupport (>= 5.0) - govuk-components (2.1.4) - activemodel (>= 6.0) - railties (>= 6.0) - view_component (~> 2.39.0) - govuk_design_system_formbuilder (2.7.6) - actionview (>= 6.0) - activemodel (>= 6.0) - activesupport (>= 6.0) - deep_merge (~> 1.2.1) - has_scope (0.8.0) - actionpack (>= 5.2) - activesupport (>= 5.2) - hotwire-rails (0.1.3) - rails (>= 6.0.0) - stimulus-rails - turbo-rails - i18n (1.8.11) - concurrent-ruby (~> 1.0) - inherited_resources (1.13.0) - actionpack (>= 5.2, < 6.2) - has_scope (~> 0.6) - railties (>= 5.2, < 6.2) - responders (>= 2, < 4) - iniparse (1.5.0) - jbuilder (2.11.3) - activesupport (>= 5.0.0) - jquery-rails (4.4.0) - rails-dom-testing (>= 1, < 3) - railties (>= 4.2.0) - thor (>= 0.14, < 2.0) - json-schema (2.8.1) - addressable (>= 2.4) - kaminari (1.2.1) - activesupport (>= 4.1.0) - kaminari-actionview (= 1.2.1) - kaminari-activerecord (= 1.2.1) - kaminari-core (= 1.2.1) - kaminari-actionview (1.2.1) - actionview - kaminari-core (= 1.2.1) - kaminari-activerecord (1.2.1) - activerecord - kaminari-core (= 1.2.1) - kaminari-core (1.2.1) - listen (3.7.0) - rb-fsevent (~> 0.10, >= 0.10.3) - rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.12.0) - crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mail (2.7.1) - mini_mime (>= 0.1.1) - marcel (1.0.2) - matrix (0.4.2) - method_source (1.0.0) - mini_mime (1.1.2) - minitest (5.14.4) - msgpack (1.4.2) - nio4r (2.5.8) - nokogiri (1.12.5-x86_64-linux) - racc (~> 1.4) - orm_adapter (0.5.0) - overcommit (0.58.0) - childprocess (>= 0.6.3, < 5) - iniparse (~> 1.4) - rexml (~> 3.2) - parallel (1.21.0) - parser (3.0.2.0) - ast (~> 2.4.1) - pg (1.2.3) - pry (0.13.1) - coderay (~> 1.1) - method_source (~> 1.0) - pry-byebug (3.9.0) - byebug (~> 11.0) - pry (~> 0.13.0) - public_suffix (4.0.6) - puma (5.5.2) - nio4r (~> 2.0) - racc (1.6.0) - rack (2.2.3) - rack-mini-profiler (2.3.3) - rack (>= 1.2.0) - rack-proxy (0.7.0) - rack - rack-test (1.1.0) - rack (>= 1.0, < 3) - rails (6.1.4.1) - actioncable (= 6.1.4.1) - actionmailbox (= 6.1.4.1) - actionmailer (= 6.1.4.1) - actionpack (= 6.1.4.1) - actiontext (= 6.1.4.1) - actionview (= 6.1.4.1) - activejob (= 6.1.4.1) - activemodel (= 6.1.4.1) - activerecord (= 6.1.4.1) - activestorage (= 6.1.4.1) - activesupport (= 6.1.4.1) - bundler (>= 1.15.0) - railties (= 6.1.4.1) - sprockets-rails (>= 2.0.0) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) - nokogiri (>= 1.6) - rails-html-sanitizer (1.4.2) - loofah (~> 2.3) - railties (6.1.4.1) - actionpack (= 6.1.4.1) - activesupport (= 6.1.4.1) - method_source - rake (>= 0.13) - thor (~> 1.0) - rainbow (3.0.0) - rake (13.0.6) - ransack (2.4.2) - activerecord (>= 5.2.4) - activesupport (>= 5.2.4) - i18n - rb-fsevent (0.11.0) - rb-inotify (0.10.1) - ffi (~> 1.0) - regexp_parser (2.1.1) - responders (3.0.1) - actionpack (>= 5.0) - railties (>= 5.0) - rexml (3.2.5) - roo (2.8.3) - nokogiri (~> 1) - rubyzip (>= 1.3.0, < 3.0.0) - rubocop (1.23.0) - parallel (~> 1.10) - parser (>= 3.0.0.0) - rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml - rubocop-ast (>= 1.12.0, < 2.0) - ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.13.0) - parser (>= 3.0.1.1) - rubocop-govuk (4.2.0) - rubocop (= 1.23.0) - rubocop-ast (= 1.13.0) - rubocop-rails (= 2.12.4) - rubocop-rake (= 0.6.0) - rubocop-rspec (= 2.6.0) - rubocop-performance (1.12.0) - rubocop (>= 1.7.0, < 2.0) - rubocop-ast (>= 0.4.0) - rubocop-rails (2.12.4) - activesupport (>= 4.2.0) - rack (>= 1.1) - rubocop (>= 1.7.0, < 2.0) - rubocop-rake (0.6.0) - rubocop (~> 1.0) - rubocop-rspec (2.6.0) - rubocop (~> 1.19) - ruby-progressbar (1.11.0) - ruby2_keywords (0.0.5) - rubyzip (2.3.2) - sass (3.7.4) - sass-listen (~> 4.0.0) - sass-listen (4.0.0) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - scss_lint (0.59.0) - sass (~> 3.5, >= 3.5.5) - scss_lint-govuk (0.2.0) - scss_lint - selenium-webdriver (4.0.3) - childprocess (>= 0.5, < 5.0) - rexml (~> 3.2, >= 3.2.5) - rubyzip (>= 1.2.2) - semantic_range (3.0.0) - simplecov (0.21.2) - docile (~> 1.1) - simplecov-html (~> 0.11) - simplecov_json_formatter (~> 0.1) - simplecov-html (0.12.3) - simplecov_json_formatter (0.1.3) - sprockets (4.0.2) - concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-rails (3.4.0) - actionpack (>= 5.2) - activesupport (>= 5.2) - sprockets (>= 3.0.0) - stimulus-rails (0.7.2) - rails (>= 6.0.0) - thor (1.1.0) - turbo-rails (0.8.3) - rails (>= 6.0.0) - tzinfo (2.0.4) - concurrent-ruby (~> 1.0) - uk_postcode (2.1.6) - unicode-display_width (2.1.0) - view_component (2.39.0) - activesupport (>= 5.0.0, < 8.0) - method_source (~> 1.0) - warden (1.2.9) - rack (>= 2.0.9) - web-console (4.2.0) - actionview (>= 6.0.0) - activemodel (>= 6.0.0) - bindex (>= 0.4.0) - railties (>= 6.0.0) - webpacker (5.4.3) - activesupport (>= 5.2) - rack-proxy (>= 0.6.1) - railties (>= 5.2) - semantic_range (>= 2.3.0) - websocket-driver (0.7.5) - websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.5) - xpath (3.2.0) - nokogiri (~> 1.8) - zeitwerk (2.5.1) - -PLATFORMS - x86_64-darwin-20 - x86_64-linux - -DEPENDENCIES - activeadmin - bootsnap (>= 1.4.4) - byebug - capybara - chartkick - database_cleaner-active_record - devise - discard - dotenv-rails - factory_bot_rails - govuk-components - govuk_design_system_formbuilder - hotwire-rails - jbuilder (~> 2.7) - json-schema - listen (~> 3.3) - overcommit (>= 0.37.0) - pg (~> 1.1) - pry-byebug - puma (~> 5.0) - rack-mini-profiler (~> 2.0) - rails (~> 6.1.4) - roo - rspec-core! - rspec-expectations! - rspec-mocks! - rspec-rails! - rspec-support! - rubocop-govuk - rubocop-performance - rubocop-rails - scss_lint-govuk - selenium-webdriver - simplecov - turbo-rails (~> 0.8) - tzinfo-data - uk_postcode - web-console (>= 4.1.0) - webpacker (~> 5.0) - -RUBY VERSION - ruby 3.0.2p107 - -BUNDLED WITH - 2.2.22 diff --git a/app/controllers/case_logs_controller.rb b/app/controllers/case_logs_controller.rb index c2b4edc28..d721377ed 100644 --- a/app/controllers/case_logs_controller.rb +++ b/app/controllers/case_logs_controller.rb @@ -1,7 +1,7 @@ class CaseLogsController < ApplicationController - skip_before_action :verify_authenticity_token, if: :json_api_request? - before_action :authenticate, if: :json_api_request? - before_action :authenticate_user!, unless: :json_api_request? + # skip_before_action :verify_authenticity_token, if: :json_api_request? + # before_action :authenticate, if: :json_api_request? + # before_action :authenticate_user!, unless: :json_api_request? def index @completed_case_logs = CaseLog.completed @@ -88,6 +88,11 @@ class CaseLogsController < ApplicationController render "form/check_answers", locals: { subsection: subsection, form: form } end + def print + @form = FormHandler.instance.get_form("2021_2022") + render "form/print", locals: {} + end + form = FormHandler.instance.get_form("2021_2022") form.all_pages.map do |page_key, page_info| define_method(page_key) do |_errors = {}| diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index dc909ede8..361d8453b 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -10,6 +10,8 @@ import * as ActiveStorage from "@rails/activestorage" import "channels" import { initAll } from 'govuk-frontend' import "@hotwired/turbo-rails" +import ('stylesheets/print.scss'); + Rails.start() diff --git a/app/javascript/stylesheets/print.scss b/app/javascript/stylesheets/print.scss new file mode 100644 index 000000000..ad039ab4a --- /dev/null +++ b/app/javascript/stylesheets/print.scss @@ -0,0 +1,42 @@ +.cell { + background-color: lightgrey; +} + +.question_cell { + grid-column: 1; +} + +.grid-row { + border: 0.5px solid rgba(0, 0, 0, 0.8); +} + +.two-grid { + display: grid; + grid-template-columns: auto auto; + font-size: 10px; + grid-auto-columns: 1fr 200px; + +} + + +.three-grid { + display: grid; + grid-template-columns: auto auto auto; + font-size: 10px; + grid-auto-columns: 1fr 200px; + +} + +.print-header { + size: 12px; +} + +@media print { + body { + -webkit-print-color-adjust: exact; + } + .cell { + background-color: lightgrey; + } + +} diff --git a/app/views/form/print/_checkbox_question.html.erb b/app/views/form/print/_checkbox_question.html.erb new file mode 100644 index 000000000..5c2d08fd2 --- /dev/null +++ b/app/views/form/print/_checkbox_question.html.erb @@ -0,0 +1,11 @@ +
+ + <%= question["header"].html_safe.present? ? question["header"].html_safe : "missing question header"%> + +
+
+ <% question["answer_options"].each do |index, answer_option| %> + + + <%end %> +
diff --git a/app/views/form/print/_date_question.html.erb b/app/views/form/print/_date_question.html.erb new file mode 100644 index 000000000..1aca08665 --- /dev/null +++ b/app/views/form/print/_date_question.html.erb @@ -0,0 +1,8 @@ +
+ + <%= question["header"].html_safe.present? ? question["header"].html_safe : "missing question header"%> + +
+
+
+
diff --git a/app/views/form/print/_numeric_question.html.erb b/app/views/form/print/_numeric_question.html.erb new file mode 100644 index 000000000..e31503de5 --- /dev/null +++ b/app/views/form/print/_numeric_question.html.erb @@ -0,0 +1,8 @@ +
+ + <%= question["header"].html_safe.present? ? question["header"].html_safe : "missing question header"%> + +
+
+
+
diff --git a/app/views/form/print/_radio_question.html.erb b/app/views/form/print/_radio_question.html.erb new file mode 100644 index 000000000..ef9044bde --- /dev/null +++ b/app/views/form/print/_radio_question.html.erb @@ -0,0 +1,23 @@ +
+ + <%= question["header"].html_safe.present? ? question["header"].html_safe : "missing question header"%> + +
+
+
+ <% question["answer_options"].each do |index, answer_option| %> + <% if index.to_i.even? %> + +
+ <% end %> + <%end %> +
+
+ <% question["answer_options"].each do |index, answer_option| %> + <% if !index.to_i.even? %> + +
+ <% end %> + <%end %> +
+
diff --git a/app/views/form/print/_select_question.html.erb b/app/views/form/print/_select_question.html.erb new file mode 100644 index 000000000..5c2d08fd2 --- /dev/null +++ b/app/views/form/print/_select_question.html.erb @@ -0,0 +1,11 @@ +
+ + <%= question["header"].html_safe.present? ? question["header"].html_safe : "missing question header"%> + +
+
+ <% question["answer_options"].each do |index, answer_option| %> + + + <%end %> +
diff --git a/app/views/form/print/_text_question.html.erb b/app/views/form/print/_text_question.html.erb new file mode 100644 index 000000000..253438443 --- /dev/null +++ b/app/views/form/print/_text_question.html.erb @@ -0,0 +1,7 @@ + + <%= question["header"].html_safe.present? ? question["header"].html_safe : "missing question header"%>
+
+
+
+
+ diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 34e97e8b9..3b415cf53 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -15,6 +15,8 @@ <%= favicon_link_tag asset_pack_path('media/images/govuk-apple-touch-icon-180x180.png'), rel: 'apple-touch-icon', type: 'image/png', size: '180x180' %> <%= stylesheet_pack_tag 'application', media: 'all' %> <%= javascript_pack_tag 'application', defer: true %> + +

<%= notice %>

<%= alert %>

diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index 45a31ddc1..d296426e7 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -1111,6 +1111,7 @@ "header": "Property location", "hint_text": "", "type": "radio", + "print_type": "text", "answer_options": { "0": "Adur", "1": "Allerdale", @@ -1871,6 +1872,7 @@ "header": "Which local authority area did the household live in immediately before this letting?", "hint_text": "Includes temporary accommodation", "type": "radio", + "print_type": "text", "answer_options": { "0": "Adur", "1": "Allerdale", diff --git a/config/routes.rb b/config/routes.rb index 2c0b14673..860e42892 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,6 +8,7 @@ Rails.application.routes.draw do ActiveAdmin.routes(self) root to: "test#index" get "about", to: "about#index" + get "form/print", to: "case_logs#print" form_handler = FormHandler.instance form = form_handler.get_form("2021_2022") diff --git a/spec/requests/users/passwords_controller_spec.rb b/spec/requests/users/passwords_controller_spec.rb index 0da90d6e9..ac48332e1 100644 --- a/spec/requests/users/passwords_controller_spec.rb +++ b/spec/requests/users/passwords_controller_spec.rb @@ -29,8 +29,6 @@ RSpec.describe Users::PasswordsController, type: :request do follow_redirect! expect(response.body).to match(/Check your email/) end - - end context "when a password reset is requested the email" do