|
|
|
@ -10,14 +10,14 @@ export default class extends Controller {
|
|
|
|
|
const selectedValue = this.element.value |
|
|
|
|
const dataInfo = JSON.parse(this.element.dataset.info) |
|
|
|
|
const conditionalFor = dataInfo.conditional_questions |
|
|
|
|
const logType = dataInfo.log_type |
|
|
|
|
const type = dataInfo.type |
|
|
|
|
|
|
|
|
|
Object.entries(conditionalFor).forEach(([targetQuestion, conditions]) => { |
|
|
|
|
if (!conditions.map(String).includes(String(selectedValue))) { |
|
|
|
|
const textNumericInput = document.getElementById(`${logType}-log-${targetQuestion.replaceAll('_', '-')}-field`) |
|
|
|
|
const textNumericInput = document.getElementById(`${type}-${targetQuestion.replaceAll('_', '-')}-field`) |
|
|
|
|
if (textNumericInput == null) { |
|
|
|
|
const dateInputs = [1, 2, 3].map((idx) => { |
|
|
|
|
return document.getElementById(`${logType}_log_${targetQuestion}_${idx}i`) |
|
|
|
|
return document.getElementById(`${type.replaceAll('-', '_')}_${targetQuestion}_${idx}i`) |
|
|
|
|
}) |
|
|
|
|
this.clearDateInputs(dateInputs) |
|
|
|
|
} else { |
|
|
|
|