Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade bootstrap 5 3 3 #859

Merged
merged 7 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"eslint:recommended"
],
"globals": {
"bootstrap": "readonly",
"firebase": "readonly",
"firebaseui": "readonly",
"google":"readonly",
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ temp
.DS_Store
.hintrc
.eslintrc.js
eslint.config.mjs
connectApp-translation
node_modules/
local-dev/
local-dev/
npm-debug.log*
package.json
package-lock.json
84 changes: 42 additions & 42 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getParameters, validateToken, userLoggedIn, getMyData, hasUserData, getMyCollections, showAnimation, hideAnimation, storeResponse, isBrowserCompatible, inactivityTime, urls, appState, processAuthWithFirebaseAdmin, successResponse, logDDRumError, translateHTML, translateText, languageAcronyms } from "./js/shared.js";
import { userNavBar, homeNavBar, languageSelector } from "./js/components/navbar.js";
import { getParameters, validateToken, userLoggedIn, getMyData, hasUserData, getMyCollections, showAnimation, hideAnimation, storeResponse, isBrowserCompatible, inactivityTime, urls, appState, processAuthWithFirebaseAdmin, successResponse, logDDRumError, translateHTML, translateText, languageAcronyms, toggleNavbarMobileView } from "./js/shared.js";
import { userNavBar, homeNavBar, languageSelector, signOutNavBarTemplate } from "./js/components/navbar.js";
import { homePage, joinNowBtn, whereAmIInDashboard, renderHomeAboutPage, renderHomeExpectationsPage, renderHomePrivacyPage } from "./js/pages/homePage.js";
import { addEventPinAutoUpperCase, addEventRequestPINForm, addEventRetrieveNotifications, toggleCurrentPage, toggleCurrentPageNoUser, addEventToggleSubmit, addEventLanguageSelection } from "./js/event.js";
import { addEventPinAutoUpperCase, addEventRequestPINForm, addEventRetrieveNotifications, toggleCurrentPage, toggleCurrentPageNoUser, addEventToggleSubmit, addEventLanguageSelection, environmentWarningModal } from "./js/event.js";
import { requestPINTemplate, duplicateAccountReminderRender } from "./js/pages/healthCareProvider.js";
import { myToDoList } from "./js/pages/myToDoList.js";
import {renderNotificationsPage} from "./js/pages/notifications.js"
Expand All @@ -10,7 +10,6 @@ import { renderSettingsPage } from "./js/pages/settings.js";
import { renderSupportPage } from "./js/pages/support.js";
import { renderPaymentPage } from "./js/pages/payment.js";
import { renderSamplesPage } from "./js/pages/samples.js";
import { footerTemplate } from "./js/pages/footer.js";
import { renderVerifiedPage } from "./js/pages/verifiedPage.js";
import { firebaseConfig as devFirebaseConfig } from "./dev/config.js";
import { firebaseConfig as stageFirebaseConfig } from "./stage/config.js";
Expand All @@ -19,6 +18,7 @@ import { firebaseConfig as prodFirebaseConfig } from "./prod/config.js";
// 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) {
Expand All @@ -29,15 +29,16 @@ if ("serviceWorker" in navigator) {

navigator.serviceWorker.ready.then(() => {
if (navigator.serviceWorker.controller) {
navigator.serviceWorker.controller.postMessage({ action: "getAppVersion" });
navigator.serviceWorker.controller.postMessage({ action: "getAppVersion" });
}
});

navigator.serviceWorker.addEventListener("message", (event) => {
if (event.data.action === "sendAppVersion") {
document.getElementById("appVersion").textContent = event.data.payload;
document.getElementById("appVersion").textContent = event.data.payload;
}
});

}

let auth = '';
Expand Down Expand Up @@ -109,31 +110,25 @@ window.onload = async () => {
auth = firebase.auth();

auth.onAuthStateChanged(async (user) => {
let idToken = '';
if (user) {
idToken = await user.getIdToken();
if (!user.isAnonymous) {
localforage.clear();
inactivityTime();
const firstSignInTime = new Date(user.metadata.creationTime).toISOString();
appState.setState({ participantData: { firstSignInTime } });
}
}
let idToken = '';
if (user) {
idToken = await user.getIdToken();
if (!user.isAnonymous) {
localforage.clear();
const firstSignInTime = new Date(user.metadata.creationTime).toISOString();
appState.setState({ participantData: { firstSignInTime } }); // TODO: potential issue with firstSignInTimestamp
}
}

appState.setState({ idToken });
});
appState.setState({ idToken });

const footer = document.getElementById('footer');
footer.innerHTML = footerTemplate();
// googleTranslateElementInit();

router();
}
await router();

// TODO: 'google is not defined' datadog error - inspect loading sequence/timing.
// const googleTranslateElementInit = () => {
// if(google) new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element');
// }
if (user && !user.isAnonymous) {
inactivityTime();
}
});
}

const handleVerifyEmail = (auth, actionCode) => {
auth.applyActionCode(actionCode).then(function(resp) {
Expand Down Expand Up @@ -198,8 +193,8 @@ const handleResetPassword = (auth, actionCode) => {
});
}

window.onhashchange = () => {
router();
window.onhashchange = async () => {
await router();
}

const router = async () => {
Expand Down Expand Up @@ -233,7 +228,7 @@ const router = async () => {
renderLanguageSelector();

if (route === '#') {
homePage();
await homePage();
} else if (route === '#about') {
renderHomeAboutPage();
} else if (route === '#expectations') {
Expand Down Expand Up @@ -270,7 +265,7 @@ const router = async () => {
if (route === '#') userProfile();
else if (route === '#dashboard') userProfile();
else if (route === '#messages') renderNotificationsPage();
else if (route === '#sign_out') signOut();
else if (route === '#sign_out') await signOut();
else if (route === '#forms') renderAgreements();
else if (route === '#myprofile') renderSettingsPage();
else if (route === '#support') renderSupportPage();
Expand All @@ -288,8 +283,8 @@ const renderLanguageSelector = () => {
//Add the language Selector Container
languageSelectorContainer = document.createElement('div');
languageSelectorContainer.id = 'languageSelectorContainer';
let navBarAlt = document.getElementById('navbarNavAltMarkup')
navBarAlt.parentNode.insertBefore(languageSelectorContainer, navBarAlt);
let userNavBar = document.getElementById('userNavBarContainer');
userNavBar.parentNode.insertBefore(languageSelectorContainer, userNavBar);
}

languageSelectorContainer.innerHTML = languageSelector();
Expand Down Expand Up @@ -406,7 +401,9 @@ const userProfile = () => {
});
}

const signOut = () => {
export const signOut = async () => {
toggleNavbarMobileView();

// Record a logout action and stop the DataDog session. This or 15 mins of inactivity will create a new session when the next action is taken.
if (!isLocalDev && window.DD_RUM) {
window.DD_RUM.addAction('user_logout', {
Expand All @@ -415,8 +412,10 @@ const signOut = () => {
window.DD_RUM.stopSession();
isDataDogUserSessionSet = false;
}
localforage.clear();

await firebase.auth().signOut();

firebase.auth().signOut();
window.location.hash = '#';
document.title = translateText('shared.homeTitle');
}
Expand All @@ -430,22 +429,23 @@ const toggleNavBar = (route, data) => {
auth.onAuthStateChanged(async user => {
if (user && !user.isAnonymous){
showAnimation();
document.getElementById('navbarNavAltMarkup').innerHTML = userNavBar(data);
document.getElementById('userNavBarContainer').innerHTML = userNavBar(data);
document.getElementById('signOutContainer').innerHTML = signOutNavBarTemplate();
document.getElementById('joinNow') ? document.getElementById('joinNow').innerHTML = joinNowBtn(false) : ``;
document.getElementById('signInWrapperDiv') ? document.getElementById('signInWrapperDiv').style.display = "none" :'';
document.getElementById('nextStepWarning') ? document.getElementById('nextStepWarning').innerHTML = await whereAmIInDashboard() : '';
document.getElementById('nextStepWarning') ? document.getElementById('nextStepWarning').style.display="block": '';
addEventRetrieveNotifications();
toggleCurrentPage(route);
await toggleCurrentPage(route);
hideAnimation();

}
else{
showAnimation();
document.getElementById('navbarNavAltMarkup').innerHTML = homeNavBar();
document.getElementById('userNavBarContainer').innerHTML = homeNavBar();
document.getElementById('signOutContainer').innerHTML = '';
document.getElementById('joinNow') ? document.getElementById('joinNow').innerHTML = joinNowBtn(true) : ``;
document.getElementById('nextStepWarning') ? document.getElementById('nextStepWarning').style.display="none": '';
toggleCurrentPageNoUser(route);
await toggleCurrentPageNoUser(route);
hideAnimation();
}
});
Expand Down Expand Up @@ -505,4 +505,4 @@ const updateFirebaseAuthPhoneTrigger = async (phone) => {
hideAnimation();
throw error;
}
};
};
54 changes: 37 additions & 17 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ a{
#root {
height: 100%;
margin-top:1px;
margin-left:15px;
margin-right:15px;
}

#footer {
Expand Down Expand Up @@ -1471,33 +1469,55 @@ button.connect-secondary {
cursor: pointer;
}

.screen-reader-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0,0,0,0);
border: 0;
}

#languageSelectorContainer {
float: right;
line-height: .9rem;
line-height: 0.9rem;
font-weight: bold;
display: flex;
flex-direction: column;
}

#languageSelectorTitle {
margin: 2px 0;
font-weight: bold;
padding-bottom: 0.25rem;
text-align: center;
}

#languageSelector {
margin-bottom: 2px;
margin-bottom: 0.25rem;
}

@media (max-width: 991.98px) {
.navbar-collapse {
padding-top: 0.75rem;
}

.navbar-toggler {
margin: 0.5rem ;
}

/* Prevent language selector from moving when navbar expands */
.navbar-collapse.show~#languageSelectorContainer,
.navbar-collapse.collapsing~#languageSelectorContainer {
position: absolute;
right: 0.75rem;
top: 0.8rem;
}
}

#appVersion {
color: #fff;
font-size: 0.8rem;
}

.survey-main-body {
border: 1px solid #dee2e6;
padding: 20px;
border-radius: 0 10px 10px 10px;
}

@media (max-width: 768px) {
.survey-main-body {
padding: 10px;
border-width: 0.5px;
}
}
36 changes: 36 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import globals from "globals";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [...compat.extends("eslint:recommended"), {
languageOptions: {
globals: {
...globals.browser,
bootstrap: "readonly",
firebase: "readonly",
firebaseui: "readonly",
google: "readonly",
workbox: "readonly",
importScripts: "readonly",
localforage: "readonly",
pdfjsLib: "readonly",
PDFLib: "readonly",
download: "readonly",
},

ecmaVersion: 2020,
sourceType: "module",
},

rules: {},
}];
8 changes: 4 additions & 4 deletions i18n/en.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading