From 033076ee13031c1c446488e880882a4b6a5e8bb6 Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 23 Nov 2021 12:31:00 +0000 Subject: [PATCH] WIP --- app/controllers/case_logs_controller.rb | 6 +++--- app/javascript/stylesheets/print.scss | 10 +++++++++- app/views/form/print.html.erb | 2 +- app/views/form/print/_date_question.html.erb | 9 +-------- app/views/form/print/_numeric_question.html.erb | 9 +-------- 5 files changed, 15 insertions(+), 21 deletions(-) diff --git a/app/controllers/case_logs_controller.rb b/app/controllers/case_logs_controller.rb index d721377ed..2fff84580 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 diff --git a/app/javascript/stylesheets/print.scss b/app/javascript/stylesheets/print.scss index 31b110651..de2a45d66 100644 --- a/app/javascript/stylesheets/print.scss +++ b/app/javascript/stylesheets/print.scss @@ -34,7 +34,7 @@ grid-auto-columns: 1fr 200px; } -.govuk-heading-s { +.print-form-heading { font-size: small; margin-bottom: 0; margin-top: 5px; @@ -54,4 +54,12 @@ background-color: lightgrey; } .noprint {display:none;} + + .one-grid { + page-break-inside: avoid; + } + + .three-grid { + page-break-inside: avoid; + } } diff --git a/app/views/form/print.html.erb b/app/views/form/print.html.erb index 9f14a9753..226250235 100644 --- a/app/views/form/print.html.erb +++ b/app/views/form/print.html.erb @@ -2,7 +2,7 @@ <%= form_with do |f| %> <% @form.all_subsections.each do |subsection_name, subsection_content| %> -

<%= subsection_content["label"] %>

+ <% large_answers = @form.questions_for_subsection(subsection_name).any? {|key, info| info["type"]== 'checkbox' || info["type"]== 'radio' && info["answer_options"].keys.length > 4} ? "one-grid" : "three-grid" %>
<% @form.questions_for_subsection(subsection_name).each_with_index do |question, index| %> diff --git a/app/views/form/print/_date_question.html.erb b/app/views/form/print/_date_question.html.erb index 491352380..445ddf8ad 100644 --- a/app/views/form/print/_date_question.html.erb +++ b/app/views/form/print/_date_question.html.erb @@ -1,8 +1 @@ -
- - <%= question["header"].html_safe.present? ? question["header"].html_safe : "missing question header"%> - -
-
-
-
+<%= render partial: "form/print/text_question", locals: { question_key: question_key, question: question, index: index, f: f, outer_grid: outer_grid } %> diff --git a/app/views/form/print/_numeric_question.html.erb b/app/views/form/print/_numeric_question.html.erb index 491352380..445ddf8ad 100644 --- a/app/views/form/print/_numeric_question.html.erb +++ b/app/views/form/print/_numeric_question.html.erb @@ -1,8 +1 @@ -
- - <%= question["header"].html_safe.present? ? question["header"].html_safe : "missing question header"%> - -
-
-
-
+<%= render partial: "form/print/text_question", locals: { question_key: question_key, question: question, index: index, f: f, outer_grid: outer_grid } %>