Skip to content

Commit

Permalink
Merge pull request #841 from aehrc/issue/833
Browse files Browse the repository at this point in the history
Issue/833
  • Loading branch information
fongsean authored Jun 6, 2024
2 parents e4aa555 + f4701cc commit d82fcd9
Show file tree
Hide file tree
Showing 19 changed files with 630 additions and 120 deletions.
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ lib
dist
coverage
build
storybook-static
*.md
*.stories.*
*.cjs
*.js
*.config.*
*.html
2 changes: 1 addition & 1 deletion apps/smart-forms-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"dependencies": {
"@aehrc/sdc-assemble": "^1.2.0",
"@aehrc/sdc-populate": "^2.2.0",
"@aehrc/smart-forms-renderer": "^0.34.2",
"@aehrc/smart-forms-renderer": "^0.35.0",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@fontsource/material-icons": "^5.0.16",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ function ViewExistingResponsesButton() {
navigate('/dashboard/responses');
}

let responseMessage;
if (isFetching && selectedQuestionnaire) {
responseMessage = 'Loading responses';
} else if (existingResponses.length === 0) {
responseMessage = 'No responses found';
} else {
responseMessage = 'View responses';
}

const buttonIsDisabled = !selectedQuestionnaire || existingResponses.length === 0 || isFetching;

return (
Expand All @@ -70,11 +79,7 @@ function ViewExistingResponsesButton() {
color={buttonIsDisabled ? 'text.disabled' : 'primary'}
textAlign="center"
sx={{ mt: -0.5, mb: 0.5 }}>
{isFetching && selectedQuestionnaire
? 'Loading responses'
: existingResponses.length === 0
? 'No responses found'
: 'View responses'}
{responseMessage}
</Typography>
</Stack>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,21 @@ export function getResponseToolBarColors(
selectedQuestionnaire: Questionnaire | null,
existingResponses: QuestionnaireResponse[]
) {
return {
...(selected
? {
color: 'primary.main',
bgcolor: 'pale.primary'
}
: selectedQuestionnaire && existingResponses.length > 0
? {
color: 'secondary.main',
bgcolor: 'pale.secondary'
}
: null)
};
if (selected) {
return {
color: 'primary.main',
bgcolor: 'pale.primary'
};
}

if (selectedQuestionnaire && existingResponses.length > 0) {
return {
color: 'secondary.main',
bgcolor: 'pale.secondary'
};
}

return {};
}

export function getQuestionnaireToolBarColors(selected: Questionnaire | null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import {
StyledRoot
} from '../../QuestionnairePage/TableComponents/QuestionnaireListToolbar.styles.ts';
import ResponseListToolbarButtons from './ResponseListToolbarButtons.tsx';
import type { QuestionnaireResponse } from 'fhir/r4';
import type { Questionnaire } from 'fhir/r4';
import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
import ResponseListToolbarLeftSection from './ResponseListToolbarLeftSection.tsx';
import useSelectedQuestionnaire from '../../../../hooks/useSelectedQuestionnaire.ts';

Expand Down
38 changes: 29 additions & 9 deletions documentation/docs/sdc/advanced/question.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -216,31 +216,51 @@ Allows the child items of a group to be displayed in a collapsible form where it

Collapsible is only supported on **group** items.

#### Default Open Usage
#### Non-Group - Default Open Usage

<IframeContainer storyUrl="https://smartforms.csiro.au/storybook/?path=/story/component-sdc-8-1-2-advanced-control-appearance--collapsible-default-open">
<IframeContainer storyUrl="https://smartforms.csiro.au/storybook/?path=/story/component-sdc-8-1-2-advanced-control-appearance--collapsible-single-default-open">
<iframe
src="https://smartforms.csiro.au/storybook/iframe.html?args=&id=component-sdc-8-1-2-advanced-control-appearance--collapsible-default-open"
src="https://smartforms.csiro.au/storybook/iframe.html?args=&id=component-sdc-8-1-2-advanced-control-appearance--collapsible-single-default-open"
width="100%"
height="230"
/>
</IframeContainer>

#### Non-Group - Default Closed Usage

<IframeContainer storyUrl="https://smartforms.csiro.au/storybook/?path=/story/component-sdc-8-1-2-advanced-control-appearance--collapsible-single-default-closed">
<iframe
src="https://smartforms.csiro.au/storybook/iframe.html?args=&id=component-sdc-8-1-2-advanced-control-appearance--collapsible-single-default-closed"
width="100%"
height="230"
/>
</IframeContainer>

#### Group - Default Open Usage

<IframeContainer storyUrl="https://smartforms.csiro.au/storybook/?path=/story/component-sdc-8-1-2-advanced-control-appearance--collapsible-group-default-open">
<iframe
src="https://smartforms.csiro.au/storybook/iframe.html?args=&id=component-sdc-8-1-2-advanced-control-appearance--collapsible-group-default-open"
width="100%"
height="260"
/>
</IframeContainer>

#### Default Closed Usage
#### Group - Default Closed Usage

<IframeContainer storyUrl="https://smartforms.csiro.au/storybook/?path=/story/component-sdc-8-1-2-advanced-control-appearance--collapsible-default-closed">
<IframeContainer storyUrl="https://smartforms.csiro.au/storybook/?path=/story/component-sdc-8-1-2-advanced-control-appearance--collapsible-group-default-closed">
<iframe
src="https://smartforms.csiro.au/storybook/iframe.html?args=&id=component-sdc-8-1-2-advanced-control-appearance--collapsible-default-closed"
src="https://smartforms.csiro.au/storybook/iframe.html?args=&id=component-sdc-8-1-2-advanced-control-appearance--collapsible-group-default-closed"
width="100%"
height="260"
/>
</IframeContainer>

#### Nested Usage
#### Group - Nested Usage

<IframeContainer storyUrl="https://smartforms.csiro.au/storybook/?path=/story/component-sdc-8-1-2-advanced-control-appearance--collapsible-nested">
<IframeContainer storyUrl="https://smartforms.csiro.au/storybook/?path=/story/component-sdc-8-1-2-advanced-control-appearance--collapsible-group-nested">
<iframe
src="https://smartforms.csiro.au/storybook/iframe.html?args=&id=component-sdc-8-1-2-advanced-control-appearance--collapsible-nested"
src="https://smartforms.csiro.au/storybook/iframe.html?args=&id=component-sdc-8-1-2-advanced-control-appearance--collapsible-group-nested"
width="100%"
height="760"
/>
Expand Down
2 changes: 1 addition & 1 deletion documentation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"typecheck": "tsc"
},
"dependencies": {
"@aehrc/smart-forms-renderer": "^0.34.2",
"@aehrc/smart-forms-renderer": "^0.35.0",
"@docusaurus/core": "3.3.2",
"@docusaurus/preset-classic": "3.3.2",
"@docusaurus/theme-live-codeblock": "^3.3.2",
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion packages/smart-forms-renderer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aehrc/smart-forms-renderer",
"version": "0.34.2",
"version": "0.35.0",
"description": "FHIR Structured Data Captured (SDC) rendering engine for Smart Forms",
"main": "lib/index.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ function CustomDateTimeItem(props: CustomDateTimeItemProps) {

if (newDateInput === '') {
onQrItemChange(createEmptyQrItem(qItem));
return;
}

if (!validateDateInput(newDateInput)) {
Expand All @@ -126,7 +127,8 @@ function CustomDateTimeItem(props: CustomDateTimeItemProps) {
setPeriodInput(newPeriodInput);

if (newTimeInput === '') {
onQrItemChange(createEmptyQrItem(qItem));
updateQRDateTime(dateInput, '', '', false);
return;
}

const { timeIsValid, is24HourNotation } = validateTimeInput(newTimeInput, newPeriodInput);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import type {
PropsWithIsRepeatedAttribute,
PropsWithParentIsReadOnlyAttribute,
PropsWithParentIsRepeatGroupAttribute,
PropsWithQrItemChangeHandler
PropsWithQrItemChangeHandler,
PropsWithQrRepeatGroupChangeHandler
} from '../../../interfaces/renderProps.interface';
import type { PropsWithQrRepeatGroupChangeHandler } from '../../../interfaces/renderProps.interface';
import type { Tabs } from '../../../interfaces/tab.interface';
import GroupHeading from './GroupHeading';
import { GroupCard } from './GroupItem.styles';
Expand Down Expand Up @@ -74,9 +74,9 @@ function GroupItemView(props: GroupItemViewProps) {

// Render collapsible group item
// If group item is a repeating instance, do not render group item as collapsible
const groupIsCollapsible = getGroupCollapsible(qItem);
if (groupIsCollapsible && !isRepeated) {
const isDefaultOpen = groupIsCollapsible === 'default-open';
const groupCollapsibleValue = getGroupCollapsible(qItem);
if (groupCollapsibleValue && !isRepeated) {
const isDefaultOpen = groupCollapsibleValue === 'default-open';
return (
<GroupAccordion
disableGutters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ function RepeatGroupView(props: RepeatGroupViewProps) {
);
}

const groupIsCollapsible = getGroupCollapsible(qItem);
if (groupIsCollapsible) {
const isDefaultOpen = groupIsCollapsible === 'default-open';
const groupCollapsibleValue = getGroupCollapsible(qItem);
if (groupCollapsibleValue) {
const isDefaultOpen = groupCollapsibleValue === 'default-open';
return (
<GroupAccordion
disableGutters
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright 2024 Commonwealth Scientific and Industrial Research
* Organisation (CSIRO) ABN 41 687 119 230.
*
* Licensed 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 { styled } from '@mui/material/styles';
import { AccordionSummary } from '@mui/material';
import Accordion from '@mui/material/Accordion';
import Box from '@mui/material/Box';

export const NestedSingleItemAccordionWrapper = styled(Box, {
shouldForwardProp: (prop) => prop !== 'isRepeated'
})<{ isRepeated: boolean }>(({ isRepeated }) => ({
marginBottom: isRepeated ? 0 : '28px'
}));

export const NestedSingleItemAccordion = styled(Accordion, {
shouldForwardProp: (prop) => prop !== 'elevation'
})<{ elevation: number }>(({ elevation }) => ({
paddingTop: '8px',
paddingBottom: '4px',
paddingLeft: elevation === 1 ? '10px' : '8px',
paddingRight: elevation === 1 ? '10px' : '8px'
}));

export const NestedSingleItemAccordionSummary = styled(AccordionSummary)(() => ({
minHeight: '28px',
'.MuiAccordionSummary-expandIconWrapper': {
'&:hover:not(.Mui-disabled)': {
cursor: 'pointer'
}
},
'.MuiAccordionSummary-content': {
marginBottom: 0
},
'&.Mui-focusVisible': {
backgroundColor: 'transparent'
},
'&:hover:not(.Mui-disabled)': {
cursor: 'default'
}
}));
Loading

0 comments on commit d82fcd9

Please sign in to comment.