Browse Source

Hide total field by default

pull/199/head
baarkerlounger 4 years ago
parent
commit
c06a479a38
  1. 2
      app/helpers/conditional_questions_helper.rb
  2. 3
      app/models/form/question.rb
  3. 7
      app/webpacker/controllers/numeric_question_controller.js
  4. 3
      config/forms/2021_2022.json

2
app/helpers/conditional_questions_helper.rb

@ -4,6 +4,6 @@ module ConditionalQuestionsHelper
end end
def display_question_key_div(page, question) def display_question_key_div(page, question)
"style='display:none;'".html_safe if conditional_questions_for_page(page).include?(question.id) "style='display:none;'".html_safe if conditional_questions_for_page(page).include?(question.id) || question.requires_js
end end
end end

3
app/models/form/question.rb

@ -3,7 +3,7 @@ class Form::Question
:type, :min, :max, :step, :width, :fields_to_add, :result_field, :type, :min, :max, :step, :width, :fields_to_add, :result_field,
:conditional_for, :readonly, :answer_options, :page, :check_answer_label, :conditional_for, :readonly, :answer_options, :page, :check_answer_label,
:inferred_answers, :hidden_in_check_answers, :inferred_check_answers_value, :inferred_answers, :hidden_in_check_answers, :inferred_check_answers_value,
:guidance_partial, :prefix, :suffix :guidance_partial, :prefix, :suffix, :requires_js
def initialize(id, hsh, page) def initialize(id, hsh, page)
@id = id @id = id
@ -26,6 +26,7 @@ class Form::Question
@hidden_in_check_answers = hsh["hidden_in_check_answers"] @hidden_in_check_answers = hsh["hidden_in_check_answers"]
@prefix = hsh["prefix"] @prefix = hsh["prefix"]
@suffix = hsh["suffix"] @suffix = hsh["suffix"]
@requires_js = hsh["requires_js"]
@page = page @page = page
end end

7
app/webpacker/controllers/numeric_question_controller.js

@ -1,6 +1,13 @@
import { Controller } from "@hotwired/stimulus" import { Controller } from "@hotwired/stimulus"
export default class extends Controller { export default class extends Controller {
connect() {
const affectedField = this.element.dataset.target;
const targetQuestion = affectedField.split("case-log-")[1].split("-field")[0]
const div = document.getElementById(targetQuestion + "_div");
div.style.display = "block";
}
calculateFields() { calculateFields() {
const affectedField = this.element.dataset.target; const affectedField = this.element.dataset.target;
const fieldsToAdd = JSON.parse(this.element.dataset.calculated).map(x => `case-log-${x.replaceAll("_","-")}-field`); const fieldsToAdd = JSON.parse(this.element.dataset.calculated).map(x => `case-log-${x.replaceAll("_","-")}-field`);

3
config/forms/2021_2022.json

@ -2018,7 +2018,8 @@
"type": "numeric", "type": "numeric",
"min": 0, "min": 0,
"step": 1, "step": 1,
"readonly": true "readonly": true,
"requires_js": true
}, },
"hbrentshortfall": { "hbrentshortfall": {
"check_answer_label": "After housing benefit and/or housing element of UC payment is received, will there be an outstanding amount for basic rent and/or benefit eligible charges?", "check_answer_label": "After housing benefit and/or housing element of UC payment is received, will there be an outstanding amount for basic rent and/or benefit eligible charges?",

Loading…
Cancel
Save