Browse Source

WIP

CLDC-559-printed-form
Kat 3 years ago
parent
commit
033076ee13
  1. 6
      app/controllers/case_logs_controller.rb
  2. 10
      app/javascript/stylesheets/print.scss
  3. 2
      app/views/form/print.html.erb
  4. 9
      app/views/form/print/_date_question.html.erb
  5. 9
      app/views/form/print/_numeric_question.html.erb

6
app/controllers/case_logs_controller.rb

@ -1,7 +1,7 @@
class CaseLogsController < ApplicationController class CaseLogsController < ApplicationController
# skip_before_action :verify_authenticity_token, if: :json_api_request? skip_before_action :verify_authenticity_token, if: :json_api_request?
# before_action :authenticate, if: :json_api_request? before_action :authenticate, if: :json_api_request?
# before_action :authenticate_user!, unless: :json_api_request? before_action :authenticate_user!, unless: :json_api_request?
def index def index
@completed_case_logs = CaseLog.completed @completed_case_logs = CaseLog.completed

10
app/javascript/stylesheets/print.scss

@ -34,7 +34,7 @@
grid-auto-columns: 1fr 200px; grid-auto-columns: 1fr 200px;
} }
.govuk-heading-s { .print-form-heading {
font-size: small; font-size: small;
margin-bottom: 0; margin-bottom: 0;
margin-top: 5px; margin-top: 5px;
@ -54,4 +54,12 @@
background-color: lightgrey; background-color: lightgrey;
} }
.noprint {display:none;} .noprint {display:none;}
.one-grid {
page-break-inside: avoid;
}
.three-grid {
page-break-inside: avoid;
}
} }

2
app/views/form/print.html.erb

@ -2,7 +2,7 @@
<%= form_with do |f| %> <%= form_with do |f| %>
<% @form.all_subsections.each do |subsection_name, subsection_content| %> <% @form.all_subsections.each do |subsection_name, subsection_content| %>
<p class="govuk-heading-s"><%= subsection_content["label"] %></p> <p class="govuk-heading-s print-form-heading"><%= subsection_content["label"] %></p>
<% 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" %> <% 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" %>
<div class="<%= large_answers %>"> <div class="<%= large_answers %>">
<% @form.questions_for_subsection(subsection_name).each_with_index do |question, index| %> <% @form.questions_for_subsection(subsection_name).each_with_index do |question, index| %>

9
app/views/form/print/_date_question.html.erb

@ -1,8 +1 @@
<div class="cell govuk-body"> <%= render partial: "form/print/text_question", locals: { question_key: question_key, question: question, index: index, f: f, outer_grid: outer_grid } %>
<strong class="cell question_cell">
<%= question["header"].html_safe.present? ? question["header"].html_safe : "missing question header"%>
</strong>
</div>
<div class="cell_answer">
<br/>
</div>

9
app/views/form/print/_numeric_question.html.erb

@ -1,8 +1 @@
<div class="cell govuk-body"> <%= render partial: "form/print/text_question", locals: { question_key: question_key, question: question, index: index, f: f, outer_grid: outer_grid } %>
<strong class="cell question_cell">
<%= question["header"].html_safe.present? ? question["header"].html_safe : "missing question header"%>
</strong>
</div>
<div class="cell_answer">
<br/>
</div>

Loading…
Cancel
Save