diff --git a/app.js b/app.js index 52e69562..17b4a9c1 100644 --- a/app.js +++ b/app.js @@ -14,35 +14,36 @@ import { renderVerifiedPage } from "./js/pages/verifiedPage.js"; import { firebaseConfig as devFirebaseConfig } from "./dev/config.js"; import { firebaseConfig as stageFirebaseConfig } from "./stage/config.js"; import { firebaseConfig as prodFirebaseConfig } from "./prod/config.js"; -// When doing local development, uncomment this. -// Get the API key file from Box or the DevOps team -// Do not accept PRs with the localDevFirebaseConfig import uncommented -// import { firebaseConfig as localDevFirebaseConfig} from "./local-dev/config.js"; - import conceptIdMap from "./js/fieldToConceptIdMapping.js"; if ("serviceWorker" in navigator) { - navigator.serviceWorker.register("./serviceWorker.js").catch((error) => { - console.error("Service worker registration failed.", error); - return; - }); - + navigator.serviceWorker + .register("./serviceWorker.js") + .then((registration) => { + registration.onupdatefound = () => { + const sw = registration.installing; + if (sw) { + sw.onstatechange = () => sw.state === "activated" && sw.postMessage({ action: "getAppVersion" }); + } + }; + }) + .catch((err) => { + console.error("Service worker registration failed.", err); + }); + navigator.serviceWorker.ready.then(() => { - if (navigator.serviceWorker.controller) { - navigator.serviceWorker.controller.postMessage({ action: "getAppVersion" }); - } + const sw = navigator.serviceWorker.controller; + sw && sw.postMessage({ action: "getAppVersion" }); }); - + navigator.serviceWorker.addEventListener("message", (event) => { - if (event.data.action === "sendAppVersion") { - document.getElementById("appVersion").textContent = event.data.payload; - } + if (event.data.action === "sendAppVersion") { + document.getElementById("appVersion").textContent = event.data.payload; + } }); - -} + } let auth = ''; -// DataDog session management -> tie Connect_ID to DataDog sessions let isDataDogUserSessionSet = false; const datadogConfig = { @@ -93,8 +94,9 @@ window.onload = async () => { window.DD_RUM && window.DD_RUM.init({ ...datadogConfig, env: 'stage' }); } else if (isLocalDev) { - if (typeof localDevFirebaseConfig === 'undefined') { - console.error('Local development requires a localDevFirebaseConfig function to be defined in ./local-dev/config.js.'); + const { firebaseConfig: localDevFirebaseConfig } = await import("./local-dev/config.js"); + if (!localDevFirebaseConfig) { + console.error('Local development requires a firebaseConfig variable defined in ./local-dev/config.js.'); return; } !firebase.apps.length ? firebase.initializeApp(localDevFirebaseConfig) : firebase.app(); diff --git a/i18n/en.js b/i18n/en.js index 57920399..de552d90 100644 --- a/i18n/en.js +++ b/i18n/en.js @@ -728,7 +728,9 @@ const en = { "mainBodyPROMISHeader": "Quality of Life Survey", "mainBodyPROMISDescription": "Questions about your physical, social, and mental health.", "mainBodyExperience2024Header": "2024 Connect Experience Survey", - "mainBodyExperience2024Description": "Questions about your experience with Connect and your preferences for completing study activities, using MyConnect, and getting messages." + "mainBodyExperience2024Description": "Questions about your experience with Connect and your preferences for completing study activities, using MyConnect, and getting messages.", + "mainBodyCancerScreeningHistoryHeader": "Cancer Screening History Survey", + "mainBodyCancerScreeningHistoryDescription": "Questions about past tests you may have had to screen for cancer. These are tests that look for cancer in people without symptoms.", }, "notifications": { "read": "Read", @@ -1694,6 +1696,7 @@ const en = { "modAtHomeMouthwashSampleSurvey": "At-Home Mouthwash Sample Survey", "modQualityofLifeSurvey": "Quality of Life Survey", "mod2024ConnectExperienceSurvey": "2024 Connect Experience Survey", + "modCancerScreeningHistorySurvey": "Cancer Screening History Survey", "sessionInactiveTitle": "Inactive", "sessionInactive": "You were inactive for 20 minutes, would you like to extend your session?
", "homeTitle": "My Connect - Home", diff --git a/i18n/es.js b/i18n/es.js index 37e1d9e9..7b4ec8dd 100644 --- a/i18n/es.js +++ b/i18n/es.js @@ -732,7 +732,9 @@ "mainBodyPROMISHeader": "Encuesta sobre calidad de vida", "mainBodyPROMISDescription": "Preguntas sobre su salud física, social y mental.", "mainBodyExperience2024Header": "2024 Encuesta Sobre Experiencia de Connect", - "mainBodyExperience2024Description": "Preguntas acerca de su experiencia con Connect, y sus preferencias para realizar actividades del estudio, utilizar MyConnect, y recibir mensajes." + "mainBodyExperience2024Description": "Preguntas acerca de su experiencia con Connect, y sus preferencias para realizar actividades del estudio, utilizar MyConnect, y recibir mensajes.", + "mainBodyCancerScreeningHistoryHeader":"Encuesta sobre historial de exámenes de detección de cáncer", + "mainBodyCancerScreeningHistoryDescription": "Preguntas sobre pruebas anteriores para detectar el cáncer. Se trata de pruebas que buscan cáncer en personas sin síntomas.", }, "notifications": { "read": "Leídos", @@ -1698,6 +1700,7 @@ "modAtHomeMouthwashSampleSurvey": "Encuesta sobre muestra de enjuague bucal tomada en el hogar", "modQualityofLifeSurvey": "Encuesta sobre calidad de vida", "mod2024ConnectExperienceSurvey": "2024 Encuesta Sobre Experiencia de Connect", + "modCancerScreeningHistorySurvey": "Encuesta sobre historial de exámenes de detección de cáncer", "sessionInactiveTitle": "Inactivo", "sessionInactive": "Ha estado inactivo durante 20 minutos, ¿desea extender la sesión?", "homeTitle": "My Connect - Inicio", diff --git a/js/event.js b/js/event.js index e7bbfd80..59fd818d 100644 --- a/js/event.js +++ b/js/event.js @@ -1353,17 +1353,6 @@ export const addEventCancerFollowUp = () => { }); } - -export const addEventHideNotification = (element) => { - const hideNotification = element.querySelectorAll('.hideNotification'); - Array.from(hideNotification).forEach(btn => { - btn.addEventListener('click', () => { - btn.parentNode.parentNode.parentNode.parentNode.removeChild(btn.parentNode.parentNode.parentNode); - }); - // setTimeout(() => { btn.dispatchEvent(new Event('click')) }, 5000); - }); -} - export const addEventRetrieveNotifications = () => { const btn = document.getElementById('retrieveNotifications'); if(!btn) return; diff --git a/js/fieldToConceptIdMapping.js b/js/fieldToConceptIdMapping.js index da8184ae..c4683bbf 100644 --- a/js/fieldToConceptIdMapping.js +++ b/js/fieldToConceptIdMapping.js @@ -121,7 +121,8 @@ export default "D_793330426": "ModuleCovid19", "D_390351864": "Mouthwash", "D_601305072": "PROMIS", - "D_506648060": "Experience2024" + "D_506648060": "Experience2024", + "D_369168474": "CancerScreeningHistory" }, "Module1_OLD": { @@ -248,6 +249,16 @@ export default "version": "905236593" }, + CancerScreeningHistory: { + "conceptId": "D_369168474", + "startTs": "609630315", + "completeTs": "389890053", + "statusFlag": "176068627", + "standaloneSurvey": true, + "version": "350996955", + "questVersion": "562804752", + }, + // @deprecated. Retain until migration to Quest2 is complete. External variables passed into Quest that require extra async/await handling. delayedParameterArray: [ "D_761310265", diff --git a/js/pages/myToDoList.js b/js/pages/myToDoList.js index e0f2ed9d..29dd4e06 100644 --- a/js/pages/myToDoList.js +++ b/js/pages/myToDoList.js @@ -1,4 +1,4 @@ -import { hideAnimation, questionnaireModules, storeResponse, isParticipantDataDestroyed, translateHTML, translateText} from "../shared.js"; +import { hideAnimation, questionnaireModules, storeResponse, isParticipantDataDestroyed, translateHTML, translateText, getAdjustedTime } from "../shared.js"; import { blockParticipant, questionnaire } from "./questionnaire.js"; import { renderUserProfile } from "../components/form.js"; import { consentTemplate } from "./consent.js"; @@ -310,18 +310,14 @@ export const myToDoList = async (data, fromUserProfile, collections) => { } const addEventToDoList = () => { - const modules = document.getElementsByClassName('questionnaire-module'); - - Array.from(modules).forEach(module => { - module.addEventListener('click',() => { - - if (!module.classList.contains("btn-disabled")) { - const moduleId = module.getAttribute("module_id"); - questionnaire(moduleId); - } - }); + const enabledButtons = document.querySelectorAll("button.questionnaire-module:not(.btn-disabled)"); + enabledButtons.forEach((btn) => { + if (!btn.hasClickListener) { + btn.addEventListener("click", () => questionnaire(btn.getAttribute("module_id"))); + btn.hasClickListener = true; + } }); -} + }; const renderMainBody = (data, collections, tab) => { let template = `