From 417057ee0206299c29cea94d723c9880771d9c73 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar <theskumar@users.noreply.github.com> Date: Tue, 18 Apr 2023 14:25:23 +0530 Subject: [PATCH] Fix report-frequency.js and report-calculator.js (#3358) It shows errors when reporting is not yet displayed on a project Fixes #3310 --- .../static_src/src/javascript/apply/report-calculator.js | 7 +++++-- .../static_src/src/javascript/apply/report-frequency.js | 9 +++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/hypha/static_src/src/javascript/apply/report-calculator.js b/hypha/static_src/src/javascript/apply/report-calculator.js index d74646149..15d4056ba 100644 --- a/hypha/static_src/src/javascript/apply/report-calculator.js +++ b/hypha/static_src/src/javascript/apply/report-calculator.js @@ -1,8 +1,11 @@ (function ($) { 'use strict'; - - const reportData = JSON.parse(document.getElementById('reportData').textContent); + const reportDataEl = document.getElementById('reportData'); + if (!reportDataEl) { + return; + } + const reportData = JSON.parse(reportDataEl.textContent); // Form inputs const frequencyNumberInput = document.getElementById('id_occurrence'); diff --git a/hypha/static_src/src/javascript/apply/report-frequency.js b/hypha/static_src/src/javascript/apply/report-frequency.js index 825486329..3bddda664 100644 --- a/hypha/static_src/src/javascript/apply/report-frequency.js +++ b/hypha/static_src/src/javascript/apply/report-frequency.js @@ -2,8 +2,13 @@ 'use strict'; - const var_repeat = $('#id_does_not_repeat')[0]; - if (var_repeat.checked) { + const var_repeat = $('#id_does_not_repeat'); + + if (!var_repeat.length) { + return; + } + + if (var_repeat[0].checked) { $('.form__group--report-every').hide(); $('.form__group--schedule').hide(); } -- GitLab