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

CARDS-1741: Add a "PageStart" extension point to the patient UI #1180

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import makeStyles from '@mui/styles/makeStyles';
import { grey } from '@mui/material/colors';

import { GRID_SPACE_UNIT } from "./QuestionnaireStyle";
import { useMediaQuery } from "@mui/material";
import { useTheme } from '@mui/material/styles';

const useStyles = makeStyles(theme => ({
resourceHeader: {
Expand Down Expand Up @@ -100,6 +102,8 @@ function ResourceHeader (props) {
let { title, breadcrumbs, separator, tags, action, children } = props;

const classes = useStyles();
const theme = useTheme();
const appbarExpanded = useMediaQuery(theme.breakpoints.up('md'));

// Scroll trigger for collapsing the Title and action into the breadcrumbs
const fullBreadcrumbTrigger = useScrollTrigger({
Expand All @@ -110,7 +114,7 @@ function ResourceHeader (props) {

return (
<>
<Grid item xs={12} className={classes.resourceHeader} style={{top: props.contentOffset}} id="cards-resource-header">
<Grid item xs={12} className={classes.resourceHeader} style={ { top: appbarExpanded ? props.contentOffset: 0 }} id="cards-resource-header">
<Grid container direction="row" justifyContent="space-between" alignItems="center" wrap="nowrap">
<Grid item>
<Breadcrumbs separator={separator}>
Expand Down
1 change: 1 addition & 0 deletions modules/demo-banner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<Sling-Initial-Content>
SLING-INF/content/Extensions/PageStart/;path:=/Extensions/PageStart/;overwriteProperties:=true;uninstall:=true,
SLING-INF/content/Extensions/LoginPageStart/;path:=/Extensions/LoginPageStart/;overwriteProperties:=true;uninstall:=true,
SLING-INF/content/Extensions/SurveyPageStart/;path:=/Extensions/SurveyPageStart/;overwriteProperties:=true;uninstall:=true
</Sling-Initial-Content>
</instructions>
</configuration>
Expand Down
6 changes: 5 additions & 1 deletion modules/demo-banner/src/main/frontend/src/demoBanner.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ import WarningIcon from '@mui/icons-material/Warning';

const appbarStyle = theme => ({
root: {
backgroundColor: theme.palette.warning.main
backgroundColor: theme.palette.warning.main,
boxShadow: "none",
[theme.breakpoints.down('md')]: {
position: 'absolute',
},
}
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"jcr:primaryType": "cards:Extension",
"cards:extensionPointId": "patient-portal/surveyPageStart",
"cards:extensionName": "Demo Warning Banner",
"cards:extensionRenderURL": "asset:cards-demo-banner.demoBanner.js"
}
1 change: 1 addition & 0 deletions modules/downtime-warning-banner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
SLING-INF/content/libs/cards/resources/assetDependencies.json;path:=/libs/cards/resources/assetDependencies;overwriteProperties:=true,
SLING-INF/content/Extensions/PageStart/;path:=/Extensions/PageStart/;overwriteProperties:=true;uninstall:=true,
SLING-INF/content/Extensions/LoginPageStart/;path:=/Extensions/LoginPageStart/;overwriteProperties:=true;uninstall:=true,
SLING-INF/content/Extensions/SurveyPageStart/;path:=/Extensions/SurveyPageStart/;overwriteProperties:=true;uninstall:=true,
SLING-INF/content/Extensions/AdminDashboard/;path:=/Extensions/AdminDashboard/;overwriteProperties:=true;uninstall:=true,
SLING-INF/content/Extensions/Views/;path:=/Extensions/Views/;overwriteProperties:=true;uninstall:=true,
</Sling-Initial-Content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ import BuildIcon from '@mui/icons-material/Build';
const appbarStyle = theme => ({
root: {
backgroundColor: theme.palette.info.main,
boxShadow: "none",
[theme.breakpoints.down('md')]: {
position: 'absolute',
},
"& .MuiAvatar-root" : {
backgroundColor: theme.palette.background.paper,
color: theme.palette.info.main
Expand Down Expand Up @@ -68,11 +72,11 @@ export default function DowntimeWarning(props) {
setEnabled(json.enabled == 'true');
if (json.fromDate) {
let date = new Date(json.fromDate);
setFromDate(date.toDateString() + " " + date.toLocaleTimeString().replace(":00 ", " "));
(date != "Invalid Date") && setFromDate(date.toDateString() + " " + date.toLocaleTimeString().replace(":00 ", " "));
}
if (json.toDate) {
let date = new Date(json.toDate);
setToDate(date.toDateString() + " " + date.toLocaleTimeString().replace(":00 ", " "));
(date != "Invalid Date") && setToDate(date.toDateString() + " " + date.toLocaleTimeString().replace(":00 ", " "));
}
})
.catch((error) => {
Expand All @@ -88,7 +92,7 @@ export default function DowntimeWarning(props) {
<StyledAppBar position="fixed" style={props.style} ref={props.onRender}>
<Toolbar>
{error && <Typography color='error'>{errorText}</Typography>}
<Grid container spacing={1} direction="row" alignItems="center" wrap="nowrap">
<Grid container spacing={1} direction="row" justifyContent="center" alignItems="center" wrap="nowrap">
<Grid item><Avatar><BuildIcon/></Avatar></Grid>
<Grid item>
<Typography variant="body2">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"jcr:primaryType": "cards:Extension",
"cards:extensionPointId": "patient-portal/surveyPageStart",
"cards:extensionName": "Downtime Warning Banner",
"cards:extensionRenderURL": "asset:cards-downtime-warning-banner.downtimeBanner.js"
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ const Sidebar = ({ ...props }) => {
PaperProps={ { style: { top: contentOffset + 'px', height: 'calc(100% - ' + contentOffset + 'px)' } } }
>
{brand}
<div className={classes.sidebarWrapper}>
<div className={classes.sidebarWrapper} style={ { height: 'calc(100vh - ' + (75 + contentOffset) + 'px)' } }>
<AdminNavbarLinks closeSidebar={props.handleDrawerToggle}/>
{links}
{adminLinks}
Expand Down
2 changes: 1 addition & 1 deletion modules/login/src/main/frontend/src/styling/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const styles = theme => ({
padding: theme.spacing(2, 3, 3),
},
selfContained: {
marginTop: theme.spacing(10),
marginTop: theme.spacing(14),
marginBottom: theme.spacing(2),
},
form: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//

import React, { useState } from "react";
import PropTypes from 'prop-types';
import PageStart from './PageStart';

import { useMediaQuery } from "@mui/material";
import { useTheme } from '@mui/material/styles';

let PageStartWrapper = (props) => {
let { children, extensionsName } = {...props};
const [ contentOffset, setContentOffset ] = useState(0);

const theme = useTheme();
const appbarExpanded = useMediaQuery(theme.breakpoints.up('md'));

return (<>
<PageStart
extensionsName={extensionsName}
setTotalHeight={(th) => {
if (contentOffset != th) {
setContentOffset(th);
}
}
}
/>
<div id="page-start-wrapper-content" style={ { position: appbarExpanded ? 'relative' : 'absolute', top: contentOffset + 'px' } }>
{ children }
</div>
</>
);
}

PageStartWrapper.propTypes = {
extensionsName: PropTypes.string,
};

export default PageStartWrapper;
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,18 @@ import {
useScrollTrigger,
} from "@mui/material";

import { useMediaQuery } from "@mui/material";
import { useTheme } from '@mui/material/styles';
import makeStyles from '@mui/styles/makeStyles';

import Logo from "../components/Logo";

const useStyles = makeStyles(theme => ({
appbar : {
margin: theme.spacing(-1, -1, 4),
[theme.breakpoints.down('md')]: {
margin: theme.spacing(0, -1),
},
padding: theme.spacing(0, 1),
boxSizing: "content-box",
background: theme.palette.background.paper,
Expand Down Expand Up @@ -118,6 +123,10 @@ function Header (props) {
threshold: 200,
});

const theme = useTheme();
const appbarExpanded = useMediaQuery(theme.breakpoints.up('md'));
const contentOffset = document?.getElementById('page-start-wrapper-content')?.style.top || 0;

let subtitleBar = subtitle ?
<Toolbar variant="dense" className={classes.toolbar}>
<Typography variant="h6" color="textPrimary">{ subtitle }</Typography>
Expand All @@ -132,7 +141,7 @@ function Header (props) {

return (
<>
<AppBar position="sticky" className={classes.appbar}>
<AppBar position="sticky" className={classes.appbar} style={ { top: appbarExpanded ? contentOffset: 0 }}>
<Collapse in={!subtitle || !(scrollTrigger)}>
<Toolbar variant="dense" className={toolbarClassNames.join(' ')}>
<Logo className={classes.logo} maxWidth="160px" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import { portalTheme } from "./portalTheme.jsx";
import QuestionnaireSet from "./QuestionnaireSet.jsx";
import PatientIdentification from "./PatientIdentification.jsx";
import Footer from "./Footer.jsx";
import ErrorPage from "../components/ErrorPage.jsx";
import PageStartWrapper from '../PageStartWrapper';

import { DEFAULT_INSTRUCTIONS, SURVEY_INSTRUCTIONS_PATH } from "./SurveyInstructionsConfiguration.jsx"

Expand Down Expand Up @@ -74,19 +76,40 @@ function PatientPortalHomepage (props) {
setSubject(p?.subject);
}

if (unableToProceed) {
let appName = document.querySelector('meta[name="title"]')?.content;
let message = surveyInstructions?.welcomeMessage?.replaceAll("APP_NAME", appName) || '';
message = `${message}\n\n### To fill out surveys, please follow the personalized link that was emailed to you.`;
return (<>
<PageStartWrapper extensionsName="SurveyPageStart">
<ErrorPage
sx={{maxWidth: 500, margin: "0 auto"}}
title=""
message={message}
messageColor="textPrimary"
/>
<Footer/>
</PageStartWrapper>
</>)
}

if (!subject) {
return (<>
<PatientIdentification onSuccess={onPatientIdentified} displayText={displayText} config={accessConfig}/>
<Footer />
<PageStartWrapper extensionsName="SurveyPageStart">
<PatientIdentification onSuccess={onPatientIdentified} displayText={displayText} config={accessConfig}/>
<Footer />
</PageStartWrapper>
</>);
}

return (<>
<QuestionnaireSet subject={subject} username={username} displayText={displayText} config={{
...accessConfig,
...surveyInstructions
}} />
<Footer />
<PageStartWrapper extensionsName="SurveyPageStart">
<QuestionnaireSet subject={subject} username={username} displayText={displayText} config={{
...accessConfig,
...surveyInstructions
}} />
<Footer />
</PageStartWrapper>
</>);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"jcr:primaryType": "cards:ExtensionPoint",
"cards:extensionPointId": "patient-portal/surveyPageStart",
"cards:extensionPointName": "Content to be displayed on the top of the Patient Portal"
}